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

Closed
opened 2026-09-12 06:14:34 +00:00 by matou-build-agent · 3 comments

Follow-up from #1411 (the git-setup.sh transient-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):

bash .sandcastle/claim-next-task.sh → ~1 tokens

claim-next-task.sh correctly fails closed on a lister fault (lister_rc propagates, ~line 172; only timeout'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/or claim-next-task.sh, both factory-vendored (FACTORY_MANIFEST, owned by Matou/dev-factory) — so the #891/#931/#1394/#1411 pattern applies: land upstream, bump FACTORY_REF, re-vendor, never an in-repo edit (the #932 drift gate blocks it). Likely session-standing work.

Evidence

  • worker-logs.txt lines 190-215 in the #1411 heal bundle (/tmp/matou-heal-Matou-idss.xufeXE), heal run heal-Matou-idss-1789187471-2125383, signature e920609ff288.
  • Sibling surfaces of the same "a failed network step must not render as an empty/clean result" family: #1359 (preflight), #1394 (drift check), #1411 (git-setup), #1424 (Mattermost 5xx reds the run).

Filed by the #1411 standing session under ADR 0174 — a tracker follow-up for a documented out-of-scope finding; veto anytime.

**Follow-up from #1411** (the `git-setup.sh` transient-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`): ``` bash .sandcastle/claim-next-task.sh → ~1 tokens ``` `claim-next-task.sh` correctly **fails closed** on a lister fault (`lister_rc` propagates, ~line 172; only `timeout`'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/or `claim-next-task.sh`, both **factory-vendored** (`FACTORY_MANIFEST`, owned by `Matou/dev-factory`) — so the #891/#931/#1394/#1411 pattern applies: **land upstream, bump `FACTORY_REF`, re-vendor**, never an in-repo edit (the #932 drift gate blocks it). Likely **session-standing** work. ## Evidence - `worker-logs.txt` lines 190-215 in the #1411 heal bundle (`/tmp/matou-heal-Matou-idss.xufeXE`), heal run `heal-Matou-idss-1789187471-2125383`, signature `e920609ff288`. - Sibling surfaces of the same "a failed network step must not render as an empty/clean result" family: #1359 (preflight), #1394 (drift check), #1411 (git-setup), #1424 (Mattermost 5xx reds the run). _Filed by the #1411 standing session under ADR 0174 — a tracker follow-up for a documented out-of-scope finding; veto anytime._
Author
Member

This was generated by AI during triage.

Triage — bug + ready-for-session

Ruled 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, both bug.

State — ready-for-session, not ready-for-agent. Verified the fix cannot be done by a swarm worker:

  • Both touch-points are factory-vendored — claim-next-task.sh (.sandcastle/FACTORY_MANIFEST:11) and main.mts (:31), with the seam test tests/claim-next-task-test.sh (:72). They are canonical in Matou/dev-factory.
  • The #932 drift gate (.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 pin FACTORY_REF = 26f142c….
  • So the fix is cross-repo (upstream land in Matou/dev-factory) + a bump/re-vendor of protected .sandcastle/ paths — exactly the standing ready-for-session marks per ADR 0174 §5 and docs/agents/triage-labels.md. The swarm queue (.sandcastle/list-ready-tasks.sh:157) reads only ready-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.sh seam 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 [], bump FACTORY_REF, re-vendor, and extend tests/claim-next-task-test.sh to assert a fault does not render as an empty queue.

No needs-design gate (no UX flow/wireframe referenced); no needs_human_decision residue.

> *This was generated by AI during triage.* ## Triage — `bug` + `ready-for-session` **Ruled 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, both `bug`. **State — `ready-for-session`, not `ready-for-agent`.** Verified the fix cannot be done by a swarm worker: - Both touch-points are **factory-vendored** — `claim-next-task.sh` (`.sandcastle/FACTORY_MANIFEST:11`) and `main.mts` (`:31`), with the seam test `tests/claim-next-task-test.sh` (`:72`). They are canonical in `Matou/dev-factory`. - The **#932 drift gate** (`.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 pin `FACTORY_REF = 26f142c…`. - So the fix is cross-repo (upstream land in `Matou/dev-factory`) + a bump/re-vendor of protected `.sandcastle/` paths — exactly the standing `ready-for-session` marks per ADR 0174 §5 and `docs/agents/triage-labels.md`. The swarm queue (`.sandcastle/list-ready-tasks.sh:157`) reads only `ready-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.sh` seam 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 `[]`, bump `FACTORY_REF`, re-vendor, and extend `tests/claim-next-task-test.sh` to assert a fault does not render as an empty queue. No `needs-design` gate (no UX flow/wireframe referenced); no `needs_human_decision` residue.
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

Diagnosis of the witnessed surface (run 22225, worker-logs.txt:190-215): the ~1 tokens render is [] (2 chars -> 1 token), so the claim step took a graceful echo '[]'; exit 0 path, not the exit "$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 stop claim-next-task.sh laundering a transport fault into a graceful []. The lister-fault path (exit "$lister_rc", #52/GOTCHAS 7, test T-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 a PromptError the 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.sh seam (red->green). No credential, security-posture, trust-accept, destruction, or spend. Lands upstream in Matou/dev-factory -> FACTORY_REF bump -> 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.

**Ruled by agent under ADR 0174 — veto anytime.** Diagnosis of the witnessed surface (run 22225, `worker-logs.txt:190-215`): the `~1 tokens` render is `[]` (2 chars -> 1 token), so the claim step took a **graceful `echo '[]'; exit 0` path**, not the `exit "$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 stop `claim-next-task.sh` laundering a **transport fault** into a graceful `[]`. The lister-fault path (`exit "$lister_rc"`, #52/GOTCHAS 7, test `T-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 a `PromptError` the 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.sh` seam (red->green). No credential, security-posture, trust-accept, destruction, or spend. Lands upstream in `Matou/dev-factory` -> `FACTORY_REF` bump -> 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.
Author
Member

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 graceful echo '[]'; 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.0 surfaces a non-zero shell-expansion exit as a PromptError (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-factory e195b21 — sandcastle: a faulted alive-runs fetch in claim-next-task.sh fails LOUD, not a laundered [] (origin idss #1425).
  • Matou/idss 0cfe1114000500fe37e165ac3b71acecfb24c7fe — re-vendor, FACTORY_REF 26f96ce → 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 named alive-runs stderr reason; verified RED on pre-fix code, GREEN after; 4 repeat runs clean).
  • bash .sandcastle/check-harness-drift.sh → OK against e195b21 (every vendored file byte-identical to the new pin).
  • Sibling suites green: claim-lib-test 76/0, list-ready-tasks-test PASS (23), schedule-lib-test 17 groups, rehearsal-report-test PASS (50), run-swarm-ready-list-test 4 scenarios, actions-endpoint-test 5/0 (echo avoids the literal actions/tasks slug 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.

## 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 graceful `echo '[]'; 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.0` surfaces a non-zero shell-expansion exit as a `PromptError` (`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-factory` `e195b21` — `sandcastle: a faulted alive-runs fetch in claim-next-task.sh fails LOUD, not a laundered [] (origin idss #1425)`. - `Matou/idss` `0cfe1114000500fe37e165ac3b71acecfb24c7fe` — re-vendor, **FACTORY_REF `26f96ce` → `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 named `alive-runs` stderr reason; verified RED on pre-fix code, GREEN after; 4 repeat runs clean). - `bash .sandcastle/check-harness-drift.sh` → OK against `e195b21` (every vendored file byte-identical to the new pin). - Sibling suites green: `claim-lib-test` 76/0, `list-ready-tasks-test` PASS (23), `schedule-lib-test` 17 groups, `rehearsal-report-test` PASS (50), `run-swarm-ready-list-test` 4 scenarios, `actions-endpoint-test` 5/0 (echo avoids the literal `actions/tasks` slug 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1425
No description provided.