CB-547b: opencode session identity — resume (-s) + post-hoc session discovery #18
Reference in New Issue
Block a user
Delete Branch "worker/cb-547-opencode-session-identity-6e6318-3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
SpawnRequest.resumeSessionIdis present, the launch argv gains opencode's-s <id>(resume that conversation); a fresh spawn passes no session flag.OpenCodeSessionDiscovery, new): matches the worker's cwd (its gitworktree — structurally unique per bridged worker) against opencode's on-disk storage
~/.local/share/opencode/session/<projectID>/<ses_*>.json, preferring the most recentlymodified 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.
agentSessionId()lazily re-scans discovery each call(null until the record appears; retried by the caller). Capability:
SESSION_RESUMEdeclared;SESSION_NAMEdeliberately NOT declared (opencode has no display-name flag).Tests
~/.local/share/opencode); matching cwd found; non-matching -> null; most-recent wins; missing /
empty root -> null not throw; malformed record skipped.
-s <id>; fresh spawn carries no session flag;handle discovers the session id for the worker's cwd after the record appears.
Build
(mvn clean install, unpiped, from bridged/)
6d64bdaf50tocd18887b69