fix: allow cold managed service discovery only at stage admission

This commit is contained in:
2026-10-20 21:53:18 +01:00
parent bb98bde4fc
commit d3c7e6e784
10 changed files with 276 additions and 6 deletions
+18 -4
View File
@@ -1,8 +1,18 @@
# Stage export uses the execution service
V2 stage admission reads the existing local CLI service registration and pins
every `opencode api` subprocess with `--server` and private inherited auth.
Missing registration fails closed; stage execution does not provision a service.
V2 stage admission reads the local CLI service registration and pins every
session `opencode api` subprocess with `--server` and private inherited auth.
When registration is missing, only the admission path (`OpenStage`) first runs
the selected CLI's `api get /api/info` in the stage directory. This uses normal
CLI discovery/start of its managed service without creating a session or making
a provider request. The [V2 API guide](https://opencode.ai/v2/docs/api) documents
this discovery behavior and the [CLI guide](https://opencode.ai/v2/docs/cli)
documents the shared background service default.
Admission then requires the existing private registration before session work;
CLI success without registration is not enough. Invalid or insecure existing
registration fails closed without running discovery. Export, repair, evidence,
and restart interruption use read-only `Open`/reference resolution, never this
admission-only helper, and never start a service when registration is missing.
The chat broker's `PIPELINES_OPENCODE_ENDPOINT` and password-file overrides do
not select stage execution or export.
@@ -20,4 +30,8 @@ remains failed/pending evidence rather than being recreated or replayed.
Isolated HTTP A/B tests cover endpoint separation, authenticated export,
reference recovery, wrong credentials and changed endpoints. Fake-CLI tests
cover matching endpoint/auth/directory and ownership before prompt admission.
cover matching endpoint/auth/directory and ownership before prompt admission,
cold registration discovery, refusal when discovery leaves no private
registration, and no discovery from retained-session read paths.
Reference-writing fixtures set both scratch `HOME` and `XDG_CACHE_HOME`, since
macOS's `os.UserCacheDir` uses `HOME/Library/Caches` regardless of XDG overrides.