GeezerVison is showing github.com — opencode-claimant(claimant.py): every OpenCode server call is unauthenticated — session create always 401s, and the delete gate trusts curl's exit status · Issue #7367 · developing-today/code
opencode-claimant(claimant.py): every OpenCode server call is unauthenticated — session create always 401s, and the delete gate trusts curl's exit status #7367DescriptionSummary
pm-stack/opencode-claimant/poll.py reaches the laptop OpenCode server with HTTP Basic auth read from ~/.local/state/opencode/service-prod.json (_server_get). pm-stack/opencode-claimant/claimant.py reaches the same server on the same port with plain curl -s and no auth at all — every one of its six server calls (session create, per-id get, messages, delete ×3).
Verified against http://127.0.0.1:13420 on 2026-11-08:
$ curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:13420/api/session
401
$ curl -s -o /dev/null -w '%{http_code}' -X POST -H 'Content-Type: application/json' -d '{}' http://127.0.0.1:13420/api/session
401
$ curl -s -o /dev/null -w '%{http_code}' -X DELETE http://127.0.0.1:13420/api/session/nope
401
body: {"_tag":"UnauthorizedError","message":"Authentication required"}
$ curl -s -m 5 -o /dev/null ... # curl exit status
0 # <- 401 is still a "successful" curl
Consequences in the live path
- Session creation cannot succeed.
POST /api/session returns {"_tag":"UnauthorizedError",...} with no id. launch_step therefore takes session_id = None, falls into the location check, and records the skip session_wrong_location — a wrong reason for a wrong cause. Live mode can never create a session, so it can never bind, so the claimant's whole live path is a no-op against this server.
returncode == 0 is not a success test for the delete. supervision_step gates its delete on delete_result.returncode == 0. A 401 satisfies that. Today the zero-message gate happens to block it (len(json.loads('{"_tag":...,"message":...}')) == 2, not 0), so the recovery path does not fire — but the only thing preventing "clear the binding while the session still exists" (the duplicate-execution defect the delete-before-reclaim ordering exists to prevent) is an accidental len() of an error body. That is exactly the fail-open shape the packet's step 1b forbids.
- The same applies to
GET /api/session/<id> and /messages: an error body is parsed as JSON, so any code that reads returncode alone will treat an auth failure as a session/zero-message fact.
Note the correct credentialed path already exists in this repo: pm-stack/dispatch/src/opencode.ts sends the Basic header on the same v2 API.
Suggested acceptance
- One transport helper in
claimant.py (Basic auth from the same auth file poll.py uses, honouring OPENCODE_AUTH_FILE), used by every server call; no bare curl without the header.
- Judge every server response by status/body shape, never by
curl exit status alone: a non-2xx or an _tag error body is an unknown/failed read, not "gone" and not "deleted".
- Test that fails today: with the stub transport returning 401 for
POST /api/session, assert the skip reason names auth/transport, not session_wrong_location; and with 401 for a session GET + messages read, assert the task is left bound (unknown state, fail closed) with no recovery bind argv emitted.
- No credential value in logs — the helper may report which auth source was used, never the token.
Found by the laptop opencode-lane claimant fire 2026-11-08 (shadow), #3026 slice 1. Related: #7366 (mode not enforced), #7356 (missing launch steps), #4912 (session contract), #7085 (dispatch auth-file parsing).
Acceptance criteria
- Every
claimant.py call to the OpenCode server (session create, per-id get, messages, delete ×3) carries the same HTTP Basic auth poll.py reads from ~/.local/state/opencode/service-prod.json — no unauthenticated curl -s remains in the claimant.
- A non-2xx response is never treated as success anywhere in the claimant: the delete/recovery gate checks the HTTP status (and body), not curl's exit code, so a 401 can never read as a completed step.
- A live-mode fire against the laptop server (127.0.0.1:13420) creates a session successfully (today it always 401s), and the recovery path's gates behave identically under a stubbed 401.
Activitydeveloping-today commented on Nov 8, 2026 dezren39 commented on Nov 8, 2026 Cross-ref from the 2026-11-08 16:17Z laptop fire (shadow): fixing the transport alone does not make the zero-message gate correct.
claimant.py:253 also calls the wrong path. The v2 server serves the singular /api/session/<id>/message (envelope {"data": [...], "cursor": ...}); /messages is a 404 with an empty body. Verified on 127.0.0.1:13420:
GET /api/session/ses_e5e441...977/message -> 200 data[50]
GET /api/session/ses_e5e441...977/messages -> 404 (empty body)
So even with Basic auth added, the step-1a read still returns nothing — and len(json.loads(stdout or "[]")) == 0 then reports zero messages for any session, which is the fail-open direction (recovery would DELETE-then-clear over a session holding 50 messages). The or "[]" was written for a timeout; a 404 on curl -s is exit 0 with an empty body, so it lands on the same branch.
Filed separately as #7760 (path + empty-body-reads-as-zero, with the fail-closed acceptance for step 1a). The transport item in this issue should carry the path in the same helper so the two cannot be fixed apart. dezren39 commented on Nov 8, 2026
🤖 Agent note · design-architect pass 74 — adopted as a phase of design #7770
added kind/bugSomething isn't working (prefixed form of the classic bug label) effort/sSmall: expected under 2 hours of work meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added on Nov 8, 2026dezren39 commented on Nov 8, 2026 Intake review
Related: #7760 (the zero-message gate half of this chain, enriched last run); #7366 (launch_step mode) and #7356 (launch_step prompt) are the same function's siblings; seam-contract design #7770 lists this filing.
Live check: filer's live probes today show 401 on create/get/delete against the real server while curl exits 0; no merged fix in this run's scan.
Notes / risks: this is the destructive-path member of the claimant family: an unauthenticated delete gate that trusts curl's exit status would act on a session it never verified. Fix auth AND status handling together — auth alone leaves the exit-code trust armed for the next error class.
Suggested approach: route all claimant server calls through one authenticated helper mirroring poll.py's _server_get, check status codes explicitly, and add a stubbed-401 regression test for the gate.
— fleet monitor (repo-fleet-monitor), 2026-11-08 12:12 CST run: acceptance criteria appended to the body, labels normalized, meta/enriched applied. developing-today commented on Nov 9, 2026 🤖 Agent note · triaged
Triage verdict: the reported defect is FIXED on current main; one narrowed residual remains.
Verified on current main (~/git/code @ 1f5ac11276):
_auth_header_args() exists in pm-stack/opencode-claimant/claimant.py (line ~61): reads the same auth file poll.py uses, honours OPENCODE_AUTH_FILE, value never logged.
- Every curl call site carries it: session get (line 233), messages (lines 269, 393), deletes (lines 299, 555, 581), prompt POST (line 374, also
-f), session create (line 529).
- Session create now raises when the response carries no
id — a 401 error body can no longer fall through to the misleading session_wrong_location skip (issue consequence 1 closed).
_get_messages returns None on transport/non-JSON/error responses — an unreadable session is UNKNOWN, never zero-message (issue consequence 3 closed for the prompt path).
- Live check: unauthenticated
GET http://127.0.0.1:13420/api/session still returns 401, as expected; the credential file exists at the path the helper reads.
Residual (narrowed from issue consequence 2): the supervision recovery delete (line ~299) still gates the recovery bind on delete_result.returncode == 0 with no -f and no HTTP-status/body verification — curl exits 0 on HTTP errors, so if auth ever fails (e.g. credential unreadable → helper returns no header), the delete can silently not happen while recovery proceeds. The session-get path (line ~240) likewise treats an error body as "session gone". A scoped small_fix follow-up has been enqueued for exactly this fail-open residue; the rest of issue #7367 needs no further work.
Note: lane rows this shift still show session_id=null for opencode-assigned tasks — live launching remains unproven for reasons outside this issue's scope (see design #7770 phases / task 13488 escalation); this triage does not claim the claimant is live, only that the unauthenticated-transport defect named here is fixed on main.
dezren39 commented on Nov 9, 2026 🤖 Agent note · done — PR opened (task 14229)
- Agent: queue worker (repo-worker-code), lane code-p
- Session / ID: cron repo-queue-worker-shift-p run 2026-11-08 22:57 CST; task 14229 (small_fix, direct execution lane)
- Task: opencode-claimant(claimant.py): every OpenCode server call is unauthenticated — session create always 401s, and the delete gate trusts curl's exit status #7367 residual — claimant supervision delete gate trusts curl exit code (fail-open on HTTP error).
- Fix: PR fix(claimant): fail closed on HTTP errors in supervision recovery (#7367) #7960 (branch queue/14229-7367-claimant-delete-gate, commit e423ba3, vs main 129df4a). Session GET in supervision_step now reads the HTTP status via
curl -w: only 404 = genuinely gone; 401/403/5xx, transport failure, or a 200 with no session object = unknown state, binding left alone. Recovery DELETE now uses curl -f, so an HTTP error (401 → rc 22) fails the gate: the failure is recorded and the recovery bind is NOT attempted.
- Tests (oracle: an HTTP error is unknown state, never absence): test_claimant.py 12/12 OK on the laptop (2 new tests: 401 session GET leaves the binding alone; simulated 401 DELETE never binds), test_poll.py 50/50 OK.
- State: PR fix(claimant): fail closed on HTTP errors in supervision recovery (#7367) #7960 OPEN, MERGEABLE, basic checks QUEUED at completion, no Codex review posted yet. Resume: merge PR fix(claimant): fail closed on HTTP errors in supervision recovery (#7367) #7960 once its checks settle green and any Codex findings are dispositioned, then this residual is fully landed.
- Links: task 14229 · issue opencode-claimant(claimant.py): every OpenCode server call is unauthenticated — session create always 401s, and the delete gate trusts curl's exit status #7367 · PR fix(claimant): fail closed on HTTP errors in supervision recovery (#7367) #7960
dezren39 commented on Nov 11, 2026 🤖 Agent note · Phase 4 evidence (design #7770 closing audit, issue #7772, task 14782)
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|