harness: a failed claim-next-task renders as an EMPTY ready-tasks queue — fail-closed at the script, fail-OPEN at the worker (the #1411 second surface) #1425
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#1425
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Follow-up from #1411 (the
git-setup.shtransient-5xx retry / TRANSPORT fix) — the second surface the healer flagged in that report and explicitly left unfiled to keep #1411 scoped to its two-way work. Filing it here so the hazard has a tracker home.Symptom
A failed claim step renders as an EMPTY ready-tasks queue — which the worker's "Done" instructions treat as a completion candidate. Witnessed in the same window as #1411 (swarm run 22225,
worker-logs.txt:190-215):claim-next-task.shcorrectly fails closed on a lister fault (lister_rcpropagates, ~line 172; onlytimeout's rc 124 gets the graceful[]). But Sandcastle's prompt shell-expansion swallowed the non-zero exit and inserted the (empty) output, so the worker opened its iteration with an empty ready-tasks block.Why it matters — fail-closed at the script, fail-OPEN at the surface
A fail-closed claim step whose failure is rendered as "no work" is fail-open at the surface that matters: a less careful worker would read the empty block as "all done" and emit the completion signal on what is actually a transport fault, quietly stopping the lane.
The run 22225 worker handled it exactly right — it re-ran the lister, got
#1408 / #1410 / #1409, and refused to signal completion (worker-logs.txt:206-215) — but it burned an iteration, and the correct behaviour should not depend on the worker noticing.Likely shape of the fix
The prompt shell-expansion that inserts
$(bash .sandcastle/claim-next-task.sh)must not discard the command's exit status — a non-zero claim exit should become a named error block (distinct from a legitimately empty[]queue), never a silent empty insertion. This touches Sandcastle's prompt render (main.mts) and/orclaim-next-task.sh, both factory-vendored (FACTORY_MANIFEST, owned byMatou/dev-factory) — so the #891/#931/#1394/#1411 pattern applies: land upstream, bumpFACTORY_REF, re-vendor, never an in-repo edit (the #932 drift gate blocks it). Likely session-standing work.Evidence
worker-logs.txtlines 190-215 in the #1411 heal bundle (/tmp/matou-heal-Matou-idss.xufeXE), heal runheal-Matou-idss-1789187471-2125383, signaturee920609ff288.Filed by the #1411 standing session under ADR 0174 — a tracker follow-up for a documented out-of-scope finding; veto anytime.
Triage —
bug+ready-for-sessionRuled by agent under ADR 0174 — veto anytime.
Ruling:
bug(category) +ready-for-session(state).Category —
bug. This is a genuine fail-open defect, not a feature ask: a failed claim step is rendered as an empty ready-tasks block, and the "Done" instructions treat an empty queue as a completion candidate. That is the repo's documented "a failed network step must not render as an empty/clean result" family — consistent with its confirmed siblings #1394 and #1411, bothbug.State —
ready-for-session, notready-for-agent. Verified the fix cannot be done by a swarm worker:claim-next-task.sh(.sandcastle/FACTORY_MANIFEST:11) andmain.mts(:31), with the seam testtests/claim-next-task-test.sh(:72). They are canonical inMatou/dev-factory..sandcastle/check-harness-drift.sh:129, enforced at pre-push) blocks an in-repo edit: "land the fix THERE, bump FACTORY_REF, and re-vendor." Current pinFACTORY_REF = 26f142c….Matou/dev-factory) + a bump/re-vendor of protected.sandcastle/paths — exactly the standingready-for-sessionmarks per ADR 0174 §5 anddocs/agents/triage-labels.md. The swarm queue (.sandcastle/list-ready-tasks.sh:157) reads onlyready-for-agent, so this stays invisible to workers by construction.Why this is a two-way door. The fix is revertible by a later commit / FACTORY_REF bump, and provable by the existing
tests/claim-next-task-test.shseam test plus the same drive/heal evidence that filed it (run 22225,worker-logs.txt:190-215). It is not on the one-way-door list — no personal credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend.What proves it / brief for the session: the issue body already carries a durable brief (Symptom → Why → Likely shape of the fix → Evidence). No grilling needed. Next step for a session: land the exit-status-preserving render upstream so a non-zero claim exit becomes a named error block distinct from a legitimate
[], bumpFACTORY_REF, re-vendor, and extendtests/claim-next-task-test.shto assert a fault does not render as an empty queue.No
needs-designgate (no UX flow/wireframe referenced); noneeds_human_decisionresidue.Ruled by agent under ADR 0174 — veto anytime.
Diagnosis of the witnessed surface (run 22225,
worker-logs.txt:190-215): the~1 tokensrender is[](2 chars -> 1 token), so the claim step took a gracefulecho '[]'; exit 0path, not theexit "$lister_rc"path at ~line 172 the filing points to. Since the worker then re-ran the lister fast and got#1408/#1410/#1409, the lister leg was healthy — the fault was in the alive-runs (actions/tasks) fetch leg:claim-next-task.sh:186[ "$alive_rc" -eq 0 ] || { echo '[]'; exit 0; }(Ben's fail-closed ruling, 2026-08-11). A transient 5xx on that required read is laundered into an empty queue.Note the current pinned library (
@ai-hero/sandcastle@0.12.0) already fails loud on a non-zero shell-expansion exit (PromptPreprocessor:exitCode !== 0 -> PromptError,index.js:97) — it does not silently insert empty output. So the fix is not in the render: it is to stopclaim-next-task.shlaundering a transport fault into a graceful[]. The lister-fault path (exit "$lister_rc", #52/GOTCHAS 7, testT-idss#1195e) already fails loud; the alive-runs-fault path does not. The fix makes line 186 symmetric — fail LOUD (exit non-zero, no laundered[]) so the surface renders as aPromptErrorthe backstop re-fires, never as "nothing to do". Exiting before the walk preserves the anti-double-claim fail-CLOSED property untouched — only the loudness changes.Two-way door: a one-line behaviour change in a factory-vendored script + its test, reverted by a later commit, proven by the offline
claim-next-task-test.shseam (red->green). No credential, security-posture, trust-accept, destruction, or spend. Lands upstream inMatou/dev-factory->FACTORY_REFbump -> re-vendor (the #932 drift gate forbids an in-repo edit).Scope note: kept surgical to the alive-runs fault (the witnessed #1411 second surface). The wall-clock backoff paths (lister-timeout 124, budget, deadline — idss#1195/#77) deliberately emit graceful
[]to stay inside the 30 s prompt-expansion budget and are not faults; sweeping them in would regress that hard-won design. If those need the same treatment it is a separate ticket.Close report — landed & proven
Fix:
.sandcastle/claim-next-task.sh's alive-runs (actions-API tasks list) fetch-fault path no longer laundered the transport fault into a gracefulecho '[]'; exit 0. It now fails LOUD — exits non-zero with a named stderr reason — symmetric with the already-loud lister-fault path (exit "$lister_rc", #52/GOTCHAS 7). The pinned@ai-hero/sandcastle@0.12.0surfaces a non-zero shell-expansion exit as aPromptError(exitCode !== 0,index.js:97), so the surface now renders as a loud error the backstop re-fires, never as an empty ready queue a worker's "Done" check reads as "nothing to do". Exiting before the walk keeps the anti-double-claim fail-CLOSED property untouched (no claim posted) — only the loudness changes.Scope: surgical to the fault leg. The wall-clock backoff paths (lister-timeout 124, budget, deadline — idss#1195/#77) deliberately emit graceful
[]inside the 30 s prompt-expansion budget and are not faults; left as-is (noted in the ADR-0174 ruling above).Landed upstream + re-vendored (the #932 drift gate forbids an in-repo
.sandcastle/edit):Matou/dev-factorye195b21—sandcastle: a faulted alive-runs fetch in claim-next-task.sh fails LOUD, not a laundered [] (origin idss #1425).Matou/idss0cfe1114000500fe37e165ac3b71acecfb24c7fe— re-vendor, FACTORY_REF26f96ce→e195b21(also adopts the intervening dev-factory #142 / #1426 harness commits). Changed:.sandcastle/FACTORY_REF,.sandcastle/claim-next-task.sh,.sandcastle/tests/claim-next-task-test.sh,STATUS.md.Proof (all offline, on the workstation):
bash .sandcastle/tests/claim-next-task-test.sh→pass=44 fail=0(T5 rewritten red-before-green: was "emits []" → now asserts non-zero exit, no laundered[], and a namedalive-runsstderr reason; verified RED on pre-fix code, GREEN after; 4 repeat runs clean).bash .sandcastle/check-harness-drift.sh→ OK againste195b21(every vendored file byte-identical to the new pin).claim-lib-test76/0,list-ready-tasks-testPASS (23),schedule-lib-test17 groups,rehearsal-report-testPASS (50),run-swarm-ready-list-test4 scenarios,actions-endpoint-test5/0 (echo avoids the literalactions/tasksslug so its untimed-reader scanner stays green).Ruled by agent under ADR 0174 — veto anytime. Two-way door throughout (revertible harness change + pin bump, proven red-before-green offline). Advances #1425.