CB-547b: opencode session identity — resume (-s) + post-hoc session discovery #18

Merged
ltms merged 1 commits from worker/cb-547-opencode-session-identity-6e6318-3 into main 2026-08-13 19:41:07 +02:00
Member

CB-547b — opencode session identity: resume (-s) + post-hoc session discovery (opencode side).

Implements the opencode half of the cross-adapter identity fix, and adds the shared contract
files (SpawnRequest/PeerHandle/Capability) with exactly the CB-547a text so the two branches merge.

What changed

  • Resume spawn: when SpawnRequest.resumeSessionId is present, the launch argv gains opencode's
    -s <id> (resume that conversation); a fresh spawn passes no session flag.
  • Post-hoc discovery (OpenCodeSessionDiscovery, new): matches the worker's cwd (its git
    worktree — structurally unique per bridged worker) against opencode's on-disk storage
    ~/.local/share/opencode/session/<projectID>/<ses_*>.json, preferring the most recently
    modified record. Isolated behind ONE seam (version-coupled layout; opencode also ships a headless
    HTTP server we may switch to later — see class javadoc). Never throws: a record that doesn't
    exist yet (opencode writes it lazily) or a missing root yields null, so a spawn never blocks on
    identity.
  • Handle: the returned PeerHandle's agentSessionId() lazily re-scans discovery each call
    (null until the record appears; retried by the caller). Capability: SESSION_RESUME declared;
    SESSION_NAME deliberately NOT declared (opencode has no display-name flag).

Tests

  • OpenCodeSessionDiscoveryTest (6): publishes into a TEMP storage root (never the operator's real
    ~/.local/share/opencode); matching cwd found; non-matching -> null; most-recent wins; missing /
    empty root -> null not throw; malformed record skipped.
  • OpenCodeLauncherTest (+3): resume spawn passes -s <id>; fresh spawn carries no session flag;
    handle discovers the session id for the worker's cwd after the record appears.

Build

Tests run: 483, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

(mvn clean install, unpiped, from bridged/)

CB-547b — opencode session identity: resume (-s) + post-hoc session discovery (opencode side). Implements the opencode half of the cross-adapter identity fix, and adds the shared contract files (SpawnRequest/PeerHandle/Capability) with exactly the CB-547a text so the two branches merge. What changed - **Resume spawn**: when `SpawnRequest.resumeSessionId` is present, the launch argv gains opencode's `-s <id>` (resume that conversation); a fresh spawn passes no session flag. - **Post-hoc discovery** (`OpenCodeSessionDiscovery`, new): matches the worker's cwd (its git worktree — structurally unique per bridged worker) against opencode's on-disk storage `~/.local/share/opencode/session/<projectID>/<ses_*>.json`, preferring the most recently modified record. Isolated behind ONE seam (version-coupled layout; opencode also ships a headless HTTP server we may switch to later — see class javadoc). Never throws: a record that doesn't exist yet (opencode writes it lazily) or a missing root yields null, so a spawn never blocks on identity. - **Handle**: the returned PeerHandle's `agentSessionId()` lazily re-scans discovery each call (null until the record appears; retried by the caller). Capability: `SESSION_RESUME` declared; `SESSION_NAME` deliberately NOT declared (opencode has no display-name flag). Tests - OpenCodeSessionDiscoveryTest (6): publishes into a TEMP storage root (never the operator's real ~/.local/share/opencode); matching cwd found; non-matching -> null; most-recent wins; missing / empty root -> null not throw; malformed record skipped. - OpenCodeLauncherTest (+3): resume spawn passes `-s <id>`; fresh spawn carries no session flag; handle discovers the session id for the worker's cwd after the record appears. Build ``` Tests run: 483, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS ``` (mvn clean install, unpiped, from bridged/)
ltms added 1 commit 2026-08-13 19:40:59 +02:00
CB-547b: opencode session identity — resume (-s) + post-hoc session discovery
CI / contract (pull_request) Successful in 42s
CI / build (pull_request) Successful in 1m16s
cd18887b69
ltms force-pushed worker/cb-547-opencode-session-identity-6e6318-3 from 6d64bdaf50 to cd18887b69 2026-08-13 19:40:59 +02:00 Compare
ltms merged commit 86cf4c285a into main 2026-08-13 19:41:07 +02:00
ltms deleted branch worker/cb-547-opencode-session-identity-6e6318-3 2026-08-13 19:41:07 +02:00
Sign in to join this conversation.