External-server requests can target the wrong repo; teardown can kill a user-managed server (H-04)
Surfaced by the gpt-5.6-sol final review, verified locally against OpenCode 1.17.15.
OpencodeServerClient never appends the invoking directory to project-scoped requests or the /event subscription, yet the real OpenAPI document accepts a directory query on ~119 operations (all /session* routes, /config, /event, file routes). A session created without it inherits the server process's launch directory — only safe for plugin-owned servers spawned with cwd set.
Ownership is not persisted either: the job record stores serverUrl but not whether the server was external. interruptServerTurn() (opencode.mjs) recomputes serverExternal by comparing the recorded URL with the current process's OPENCODE_COMPANION_SERVER_URL; handleCancel (opencode-companion.mjs) then calls teardownServerSession whenever the flag is falsy. A cancel process without the env var will dispose/kill a shared, user-managed server.
Fix:
- Make the client directory-aware; attach the canonical workspace directory to every project-scoped request and the event subscription.
- Persist immutable ownership (
owned vs external) in job and server-session records at job start; never infer historical ownership from the current environment.
- Gate
/global/dispose and PID termination on plugin ownership.
Tests: two-workspace test against one external server; cancel test whose environment differs from the job-start environment.
Source: gpt-5.6-sol final review H-04 (opencode-plugin-cc-analysis.md).
External-server requests can target the wrong repo; teardown can kill a user-managed server (H-04)
Surfaced by the gpt-5.6-sol final review, verified locally against OpenCode 1.17.15.
OpencodeServerClientnever appends the invokingdirectoryto project-scoped requests or the/eventsubscription, yet the real OpenAPI document accepts adirectoryquery on ~119 operations (all/session*routes,/config,/event, file routes). A session created without it inherits the server process's launch directory — only safe for plugin-owned servers spawned withcwdset.Ownership is not persisted either: the job record stores
serverUrlbut not whether the server was external.interruptServerTurn()(opencode.mjs) recomputesserverExternalby comparing the recorded URL with the current process'sOPENCODE_COMPANION_SERVER_URL;handleCancel(opencode-companion.mjs) then callsteardownServerSessionwhenever the flag is falsy. A cancel process without the env var will dispose/kill a shared, user-managed server.Fix:
ownedvsexternal) in job and server-session records at job start; never infer historical ownership from the current environment./global/disposeand PID termination on plugin ownership.Tests: two-workspace test against one external server; cancel test whose environment differs from the job-start environment.
Source: gpt-5.6-sol final review H-04 (
opencode-plugin-cc-analysis.md).