Skip to content

fix(codex): preserve historical session peer during startup sweep - #6406

Merged
t0saki merged 1 commit into
volcengine:mainfrom
fancyboi999:fix/6402-unscoped-session-peer
Nov 13, 2026
Merged

t0saki merged 1 commit into
volcengine:mainfrom
fancyboi999:fix/6402-unscoped-session-peer

Conversation

@fancyboi999

@fancyboi999 fancyboi999 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Starting Codex in project B can assign uncaptured turns from an older, unscoped session to B during the startup sweep. The batch payload falls back from the historical session's empty workspacePeerId to the new session's activePeerId. The shared HTTP client also sends B's actor-peer header when sweeping a session pinned to project A.

Bind catch-up and commit requests to the historical session's persisted peer, including an empty user-level pin. Persist explicit peers at SessionStart as well as derived workspace peers, so a later sweep has the identity used by the session. Current-session profile injection continues to use the current peer.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Fixes #6402.

Related prior work: #3620 was closed without merging. #5755 addresses the startup state writer's locking, separately from this routing defect.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Save the effective peer in the existing session-state field, including explicitly configured peers.
  • Build a per-session HTTP client under the existing sweep lock. Use the same saved peer for message attribution, batch requests, and commit requests. Do not mutate the current session's client.
  • Extend the existing child-process/HTTP sweep contract test to cover unscoped and pinned historical sessions against unscoped and scoped startup contexts. Keep its cursor, assistant-turn, commit, and marker assertions; also check current profile routing and explicit-peer persistence. Isolate the test's pending directory.
  • Bump the Codex plugin from upstream 0.11.17 to 0.11.18 as required by the plugin-version gate.

Testing (Original Implementation)

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Commands and results:

  • In a Linux node:24-slim container, from examples/codex-memory-plugin: node --test scripts/*.test.mjs servers/*.test.mjs — 206 passed, 0 failed, 0 skipped.
  • On macOS, Node 24: node --test examples/memory-plugin-shared/sync.test.mjs examples/memory-plugin-shared/ov-http.test.mjs examples/memory-plugin-shared/batch-send.test.mjs examples/memory-plugin-shared/workspace-peer.test.mjs — 62 passed, 0 failed, 0 skipped.
  • node examples/memory-plugin-shared/sync.mjs — no additional tracked changes. git diff --check and bash .github/scripts/check-plugin-version-bumps.sh origin/main passed.
  • The four peer-matrix cases were run against unmodified main f8d36722ab4caa38e482210e8d98ec802536901c: 1 passed, 3 failed. All four pass with this change.
  • Local-only ablations independently removed payload routing, request routing, commit routing, and explicit-peer persistence. Each incomplete fix failed the same contract test. No diagnostic or reproduction scripts are included in this PR.
  • Against an unmodified, isolated OpenViking 0.5.1.1 HTTP server on macOS: ran the actual SessionStart entrypoint for both baseline and candidate, with separate storage and synthetic transcripts. Eight cases per build covered empty pins, project-A pins, invalidated legacy pins, and explicit project-A pins written by the hook itself; each was swept from both an unscoped context and project B. Raw archive content read through the public API reproduced four baseline data-attribution failures and zero candidate failures. Candidate batch/commit headers also matched the historical pin. Repeated startup sent no further writes. All eight candidate archives were read back unchanged after restarting the service.

The native-service test disabled extraction and working memory, used a loopback synthetic embedding provider, and made zero LLM requests. It verifies capture, commit, persisted attribution, and restart durability; it does not measure extraction quality or recall ranking. The server emitted an existing optional python-ldap warning; LDAP was not exercised. Windows was not tested.

Conflict Resolution Verification (2026-10-28)

Merged upstream main at a8e334c31c9df168983e6bd72422a3c8431715b3 into this branch. The only textual conflict was the plugin manifest version; it is now 0.11.18 (upstream: 0.11.17). The session routing implementation and HTTP regression tests merged without conflicts.

Current verification on macOS, Node 24.22.1:

  • Complete Codex script/server suite: 202 passed, 0 failed, 0 skipped.
  • Shared synchronization, HTTP, batch-send and workspace-peer suites: 62 passed, 0 failed, 0 skipped.
  • Running the same four peer-routing HTTP cases with the unmodified upstream SessionStart implementation produced 1 pass and 3 failures. All four pass in the merged branch as part of the full suite.
  • Shared runtime regeneration, plugin-version gate, and git diff --check passed.

The native-service durability checks documented above belong to the original implementation and were not repeated for this manifest conflict resolution. Windows was not tested.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Documentation is unchanged: the documented user-level behavior outside repositories and project-peer behavior are being restored. There are no prerequisite PRs.

Screenshots (if applicable)

N/A — lifecycle hook and HTTP API behavior.

Additional Notes

The fallback used by catch-up was introduced with #4429. This change retains its lock, unreadable-transcript, incomplete-batch, cursor-retention, and commit-retry behavior. Existing tests for those paths pass.

No state schema or peer-pin-version change is needed. A pin already cleared by the existing legacy migration stays empty; historical identity cannot safely be reconstructed from the newly opened workspace. This fix prevents future misattribution and does not rewrite existing archives. Actor-peer provenance is within the same account/user namespace; this is not a cross-tenant authorization claim.

@ZaynJarvis ZaynJarvis added the agent-plugins Agent harness and plugin integrations label Oct 23, 2026
@fancyboi999
fancyboi999 force-pushed the fix/6402-unscoped-session-peer branch from 72feec8 to 2283b02 Compare November 6, 2026 01:27
@t0saki
t0saki merged commit 24100ce into volcengine:main Nov 13, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-plugins Agent harness and plugin integrations

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex startup catch-up assigns an unscoped historical session to the new workspace peer

3 participants