Repository navigation
Description
Summary
The zero-message verification in pm-stack/opencode-claimant/claimant.py (prompt.md step 1a, the #4758 / design #4912 recovery rule) calls an endpoint the v2 server does not have:
claimant.py:253 GET http://127.0.0.1:13420/api/session/<id>/messages
The live server serves the singular /message (returning {"data": [...], "cursor": ...}). /messages is a 404 with an empty body — verified on http://127.0.0.1:13420 on 2026-11-08:
GET /api/session/ses_e5e441ca753ffdMse0Sd5IZ977/message -> 200 data[50], cursor
GET /api/session/ses_e5e441ca753ffdMse0Sd5IZ977/messages -> 404 (empty body)
poll.py and the fire probe already use the singular form (fire-probe.py session_messages()); only claimant.py — and the stub in test/test_claimant.py:75, which pins the wrong path — use /messages.
Why this is fail-open, not merely inert
The block at claimant.py:250-265 is:
messages_response = subprocess.run(["curl", "-s", "-m", "5",
f"http://127.0.0.1:13420/api/session/{session_id}/messages"], ...)
if messages_response.returncode == 0:
message_count = len(json.loads(messages_response.stdout or "[]"))
if message_count == 0:
recovery_candidates.append(...)curl -s exits 0 on a 404, and the 404 body is empty, so:
returncode == 0→ true,stdout or "[]"→"[]"(theorwas written for a timeout producing empty output),message_count == 0→ every stuck-bound row passes the zero-message gate.
The session GET immediately above it has the same shape (claimant.py:217-231): an unauthenticated curl -s returns a 401 {"_tag": ...} body, which is parsed and has no id, so the session is treated as gone. Chained together in live mode, the step-1 path is:
session GET → 401 body, no id → "gone" → attempts remain → messages read → 404 empty body → "0 messages" → recovery candidate → DELETE (401, returncode == 0, recorded as success — #7367) → bind --launched-by opencode-claimant-recovery:zero-message-deleted clears both bindings.
That is precisely the ordering the packet's step 1b forbids: an un-deleted session holding messages, with its binding cleared, leaving the task launchable for a second session while the first may still be alive. Today the only thing preventing it is that supervision_step's candidate list comes from repo-queue list parsed as JSON, which fails (#7325), so the list is empty. The safety is incidental, not structural.
Not covered by the open issues
- opencode-claimant(claimant.py): every OpenCode server call is unauthenticated — session create always 401s, and the delete gate trusts curl's exit status #7367 (open) covers the missing Basic-auth header and "returncode is not a success test" for the delete. It does not cover the wrong path: with auth fixed,
/messagesstill 404s and the empty-bodyor "[]"still reads as zero messages. - opencode-claimant(claimant.py): launch_step binds a session and never sends the prompt — every live launch creates a zero-message bound session #7356 (open) covers
launch_stepnever sending the prompt. - opencode-claimant: bound session that never received its prompt (task 6722) has no recovery path — stuck claimed forever #4758 is closed against the rule's design, not against this implementation.
Fix direction
- One transport helper (per opencode-claimant(claimant.py): every OpenCode server call is unauthenticated — session create always 401s, and the delete gate trusts curl's exit status #7367) with a path constant, using
GET /api/session/<id>/messageand readingdatafrom the envelope. - Treat an empty body, a non-2xx status, or a body that is not a message list as unknown, never as zero: the step-1a rule already says "if the message read is unavailable/incomplete, treat the state as unknown … leave it bound and stop". The current
stdout or "[]"inverts that. test/test_claimant.py:75must stub the singular path, and the fail-closed test should assert that a 404/empty messages read emits nobindargv and leaves the binding intact (it currently stubs an empty-body-free"[]", so it cannot fail).
Acceptance
- With the stub transport returning 404 + empty body for the messages read (and a live session object for the per-id GET), no recovery
bindis emitted and noDELETEis issued. - With the stub returning
{"data": [ ... 50 messages ... ]}, no recovery candidate is produced. - With the stub returning
{"data": []}and every other stuck-bound fact true, the DELETE and atomic recoverybindare emitted, in that order. grep -rn '/messages' pm-stack/opencode-claimant/returns nothing outside the retired implementation docs (README.md:96, IMPLEMENTATION_CHECKLIST.md:206 also name the wrong path).
Found by the laptop opencode-lane claimant fire 2026-11-08 (shadow, #3026 slice 1). Shadow report: ~/.local/state/opencode-claimant/shadow-fire-20261108T161653Z.json.
Acceptance criteria
- The zero-message gate in
pm-stack/opencode-claimant/claimant.pyqueries the endpoint the v2 server actually serves (singular/message), matchingpoll.pyandfire-probe.py. - An HTTP error status (404/401) or an empty/unparseable body can never be read as 'zero messages': the gate fails closed and the session is not added to recovery candidates.
- The session-exists check above it has the same fail-closed property: an error body without an
idis not treated as 'session gone'. - The stub in
test/test_claimant.pypins the correct path, and a regression test feeds a 404-empty-body response and asserts no recovery candidate (and no DELETE / binding clear) results.
Activity
developing-today commentedon Nov 8, 2026
CODE-2306
dezren39 commentedon Nov 8, 2026
Intake review
Related: #7367 (unauthenticated claimant calls — the DELETE-401 half of the chain in this issue's evidence); #4758 / design #4912 (the recovery rule this gate implements); sibling claimant defects filed today: #7732 (cap_room log), #7706 (yield-field mismatch, enriched last run).
Live check: the filer's live probe (2026-11-08) shows
/messagesreturning 404-empty while/messagereturns 200 on the same session; no merged PR in this run's search fixes the claimant path.Notes / risks: this is fail-open on a destructive path — DELETE plus binding clear on a session that may hold messages is exactly the ordering the packet's step 1b forbids. Fix the endpoint AND the error handling; fixing only the path leaves the 401 variant armed.
Suggested approach: switch to the singular endpoint, treat non-200 and empty bodies as gate failures (skip recovery, log the status), and add the 404 regression case to the claimant tests.
— fleet monitor (repo-fleet-monitor), 2026-11-08 10:12 CST run: acceptance criteria appended to the body, labels normalized,
meta/enrichedapplied.dezren39 commentedon Nov 8, 2026
🤖 Agent note · design-architect pass 74 — adopted as a phase of design #7770
files/designs/code-claimant-seam-contract.mdin the keep-the-four-repos-healthy goal workspace. Audit at origin/mainb64288a567.dezren39 commentedon Nov 9, 2026
Live confirmation from the 2026-11-09 12:27-12:30Z claimant fires (primary clone, mode=live, standing server 127.0.0.1:13420):
GET /api/session/<id>/messages→ HTTP 404, empty body (today, on a real bound session).GET /api/session/<id>/message→ the message list for that same session.claimant.pysupervision reads the plural endpoint withcurl -s(no-f), thenjson.loads(body or "[]")→[]→len == 0, so every read that 404s is classified as zero messages and proceeds toDELETE+ atomic bind-clear. Because that check only runs for sessions that carry a terminal marker (time.idle/outcome), the practical case is: a bound session that finished a turn is deleted and its task reclaimed regardless of how many messages it holds — the fail-open path into duplicate execution this issue names.Fix appears to be commit
1797b0c19b("read session messages from /message and fail closed on unknown") plus the delete-gate hardening ine423ba3b72(origin/queue/14229-7367-claimant-delete-gate); neither is an ancestor oforigin/main, so the deployed claimant still has the bug.dezren39 commentedon Nov 10, 2026
🤖 Agent note · triaged
dezren39 commentedon Nov 11, 2026
🤖 Agent note · Phase 4 evidence (design #7770 closing audit, issue #7772, task 14782)
pm-stack/opencode-claimant/README.md(PR claimant: #7770 Phase 4 closing audit — seam contract, fire-log unknowns, stub-shape fix (#7772) #8367): every OpenCode-server call inclaimant.pygoes through the one authenticated transport_server_request(status captured via curl's-wtrailer; a curl exit code is never a verdict); gone is only a 404 from the per-id GET; zero messages is only a 2xx with an emptydatalist from the singular/message. Call-level dispositions live in Phase 4 (audit) of #4912 — closing server-call inventory + contract statement for the opencode-claimant #4916's landed inventory (cross-referenced, not duplicated).test_claimant.pystub mirrors the transport writer correctly (status trailer, rc 0 on 401);test/test_claimant.py's stub still mirrored the pre-Act only on a verified read — one seam contract for the opencode-claimant #7770 reader assumption (bare bodies, no status) and 2 of its 5 tests failed against the verified transport — fixed in PR claimant: #7770 Phase 4 closing audit — seam contract, fire-log unknowns, stub-shape fix (#7772) #8367, with the stub docstring now naming the writer.