swarm harness: the #574 swarm.db attempt-telemetry parse has the same worker-stdout fragility #2106 fixed for the reconcile #2110

Closed
opened 2026-10-30 11:45:06 +00:00 by matou-build-agent · 2 comments

Split off from #2106 (which fixed the #283 stranded-close reconcile).

While fixing #2106 — the landing_reopen_stranded_closes reconcile reading the SANDCASTLE_ATTEMPT line only out of the worker's stdout, which a worker's own | tail/| head on close-report can truncate away (run 57327 stranded #2099) — I found the SAME fragility in a second, independent consumer of that line:

#574's swarm.db telemetry parse. main.mts (the if (swarmDbRunId) block, ~L505) hands result.stdout to record-run-result.sh, which pairs close-report.sh's SANDCASTLE_ATTEMPT marker lines (parsed out of the combined stdout) against result.iterations in order to write the attempts/spend tables. That result.stdout is the SAME worker stdout a | tail/| head on close-report can truncate — so a worker that pipes close-report truncates its attempt/spend telemetry out of swarm.db, silently.

Why it was left out of #2106: #2106 is scoped to the stranded-close reconcile (losing landed-looking WORK is high-stakes — a closed issue whose commits are not on main). The #574 path is attempts/spend ACCOUNTING — lower stakes, no work lost — so widening #2106 to it would have been scope creep. Filed here instead.

The fix shape #2106 already laid down: #2106 added a host-mounted WRITABLE sink (main.mts's run-scoped HOST_ATTEMPTS_DIR at /run/host-attempts, exported host-side as SWARM_HOST_ATTEMPTS_DIR/EXECUTE_ATTEMPTS_SINK) that close-report.sh appends every SANDCASTLE_ATTEMPT line to, independent of its stdout piping. record-run-result.sh (run host-side by main.mts) could read that same sink instead of / in union with result.stdout, but its pairing logic keys lines against result.iterations in order with no issue number of its own, so it is not a drop-in and needs a design pass on how to pair sink lines to iterations.

Vendored-file note (ADR 0180): close-report.sh, execute-lib.sh, main.mts, run-swarm.sh and record-run-result.sh are all factory-vendored, so like #2106 the fix lands via a dev-factory backport branch + re-vendor, not an in-repo edit.

Split off from #2106 (which fixed the #283 stranded-close reconcile). While fixing #2106 — the `landing_reopen_stranded_closes` reconcile reading the `SANDCASTLE_ATTEMPT` line only out of the worker's stdout, which a worker's own `| tail`/`| head` on close-report can truncate away (run 57327 stranded #2099) — I found the SAME fragility in a second, independent consumer of that line: **#574's swarm.db telemetry parse.** `main.mts` (the `if (swarmDbRunId)` block, ~L505) hands `result.stdout` to `record-run-result.sh`, which pairs `close-report.sh`'s `SANDCASTLE_ATTEMPT` marker lines (parsed out of the combined stdout) against `result.iterations` in order to write the `attempts`/`spend` tables. That `result.stdout` is the SAME worker stdout a `| tail`/`| head` on close-report can truncate — so a worker that pipes close-report truncates its attempt/spend telemetry out of swarm.db, silently. **Why it was left out of #2106:** #2106 is scoped to the stranded-close *reconcile* (losing landed-looking WORK is high-stakes — a closed issue whose commits are not on `main`). The #574 path is attempts/spend ACCOUNTING — lower stakes, no work lost — so widening #2106 to it would have been scope creep. Filed here instead. **The fix shape #2106 already laid down:** #2106 added a host-mounted WRITABLE sink (`main.mts`'s run-scoped `HOST_ATTEMPTS_DIR` at `/run/host-attempts`, exported host-side as `SWARM_HOST_ATTEMPTS_DIR`/`EXECUTE_ATTEMPTS_SINK`) that `close-report.sh` appends every `SANDCASTLE_ATTEMPT` line to, independent of its stdout piping. `record-run-result.sh` (run host-side by main.mts) could read that same sink instead of / in union with `result.stdout`, but its pairing logic keys lines against `result.iterations` *in order* with no issue number of its own, so it is not a drop-in and needs a design pass on how to pair sink lines to iterations. **Vendored-file note (ADR 0180):** `close-report.sh`, `execute-lib.sh`, `main.mts`, `run-swarm.sh` and `record-run-result.sh` are all factory-vendored, so like #2106 the fix lands via a dev-factory backport branch + re-vendor, not an in-repo edit.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: category bug, state ready-for-session (not ready-for-agent, not needs-design).

Why a two-way door. Hardening the #574 swarm.db telemetry parse against the worker-stdout truncation #2106 already fixed for the reconcile 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. It is revertible (git revert the idss re-vendor commit + reset the dev-factory backport branch, exactly as #2106/#2104 were ruled) and provable by the harness's own offline suites (the execute-lib-test.sh / record-run-result seams, red-before-green in the #2106 shape).

Why ready-for-session and not ready-for-agent. The whole deliverable lives in factory-vendored .sandcastle/ files — close-report.sh, execute-lib.sh, main.mts, run-swarm.sh, record-run-result.sh (all in FACTORY_MANIFEST). The #445 protected-paths boundary fingerprints .sandcastle/ around every worker run and rolls back + fails loud on any introduced change, so a swarm worker cannot land this at all (and list-ready-tasks.sh reads only ready-for-agent). Like #2106/#2104 it lands via a dev-factory backport branch + re-vendor — cross-repo push standing a swarm worker lacks. Consistent with those parents.

Why not needs-design. needs-design is for a missing/proposed UX flow, wireframe or seam contract (docs/ux/flows, docs/ux/wireframes, docs/seams). The open question here — how to pair sink lines to result.iterations with no issue number of their own — is a harness implementation decision the standing session makes inline, not a design-tier artifact that must exist first.

What proves it. The #2106 sink (SANDCASTLE_ATTEMPT_SINK / /run/host-attempts) already exists and is written by close-report.sh independent of its stdout piping; the session unions record-run-result.sh's result.stdout parse with that sink (or replaces it), driven red-before-green by the harness suites, exactly as #2106's reconcile fix was. Revert on idss + the backport branch if wrong.

No origin marker — this is not an app-report descendant (it split from #2106).

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** category `bug`, state `ready-for-session` (not `ready-for-agent`, not `needs-design`). **Why a two-way door.** Hardening the #574 swarm.db telemetry parse against the worker-stdout truncation #2106 already fixed for the reconcile 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. It is revertible (`git revert` the idss re-vendor commit + reset the dev-factory backport branch, exactly as #2106/#2104 were ruled) and provable by the harness's own offline suites (the `execute-lib-test.sh` / `record-run-result` seams, red-before-green in the #2106 shape). **Why `ready-for-session` and not `ready-for-agent`.** The whole deliverable lives in factory-vendored `.sandcastle/` files — `close-report.sh`, `execute-lib.sh`, `main.mts`, `run-swarm.sh`, `record-run-result.sh` (all in `FACTORY_MANIFEST`). The #445 protected-paths boundary fingerprints `.sandcastle/` around every worker run and rolls back + fails loud on any introduced change, so a swarm worker cannot land this at all (and `list-ready-tasks.sh` reads only `ready-for-agent`). Like #2106/#2104 it lands via a dev-factory backport branch + re-vendor — cross-repo push standing a swarm worker lacks. Consistent with those parents. **Why not `needs-design`.** `needs-design` is for a missing/`proposed` UX flow, wireframe or seam contract (`docs/ux/flows`, `docs/ux/wireframes`, `docs/seams`). The open question here — how to pair sink lines to `result.iterations` with no issue number of their own — is a harness implementation decision the standing session makes inline, not a design-tier artifact that must exist first. **What proves it.** The #2106 sink (`SANDCASTLE_ATTEMPT_SINK` / `/run/host-attempts`) already exists and is written by `close-report.sh` independent of its stdout piping; the session unions `record-run-result.sh`'s `result.stdout` parse with that sink (or replaces it), driven red-before-green by the harness suites, exactly as #2106's reconcile fix was. Revert on idss + the backport branch if wrong. No origin marker — this is not an app-report descendant (it split from #2106).
Author
Member

Close report — landed on main (push mode)

What landed: record-run-result.sh's #574 attempts/spend telemetry parse now reads the SANDCASTLE_ATTEMPT markers from the #2106 host sink in preference to the worker's stdout — the same fragility #2106 fixed for the #283 reconcile, here lower-stakes (accounting, no work lost) but it also silently misaligned the positional zip for every iteration after a truncated one.

The design pass the ticket asked for (how to pair sink lines to iterations): the sink's append order is iteration order — close-report.sh runs once per iteration, in order, so main.mts reads the sink into the payload as .attemptsSink and record-run-result.sh's existing markers[i] → iterations[i] positional zip is a drop-in over it, complete where stdout was lossy. Preferred, not sort -u-unioned the way the reconcile does: that consumer needs only the SET and may reorder; this one needs the ORDER. Falls back to .stdout when no sink was captured (bare pnpm run sandcastle, or a best-effort sink skip ⇒ exactly pre-#2110). The #200 account-fp lines stay on .stdout — close-report.sh does not emit them to the sink.

Why main.mts reads the sink, not record-run-result.sh: record-run-result.sh runs after driveMirrorStop() has already rmSync'd HOST_ATTEMPTS_DIR, so it cannot read the file itself — main.mts captures it into the payload before the teardown.

Commits

  • idss 328ec114 — vendored fix + STATUS.md, FACTORY_REF edde808→e77a951, pushed to main.
  • dev-factory backport/idss-2110 e77a951cc3eaa43cebdd3b5f349eab3f0777b344 (off the pin edde808, stacked on #2106) — main.mts + record-run-result.sh + the test.

Proof (red-before-green, offline, real script + real swarm-db.py):

  • New record-run-result-test.sh group: a worker piped close-report through | tail, so iteration 1's 901 marker never reached .stdout; only 902's did. RED before the fix (FAIL: ... MUST be recovered from the sink); GREEN after — 901 recovered from the sink, both attempts recorded, and the zip correctly pairs 901→iteration 1 (111 input tokens), 902→iteration 2 (222), no stranded issue-NULL row.
  • New empty-.attemptsSink group proves the stdout fallback (pre-#2110) still holds.
  • Suite record-run-result: 14 groups passed (was 12). execute-lib-test.sh / close-report-test.sh green. Vendor drift-gate OK, FACTORY_MANIFEST no churn, clean # Source: (no token leak).

Follow-up filed: #2112 — #2106's execute-lib.sh sink read is defeated in production by the same driveMirrorStop teardown (it reads EXECUTE_ATTEMPTS_SINK after main.mts has rmSync'd the dir on exit; the offline test shims pnpm so the real deletion never runs). Out of #2110's scope (the reconcile consumer) — ready-for-session.

Ruled by agent under ADR 0174 — veto anytime. Revertible: git revert 328ec114 + reset backport/idss-2110. Provable: the vendored red-before-green suite above.

## Close report — landed on `main` (push mode) **What landed:** `record-run-result.sh`'s `#574` attempts/spend telemetry parse now reads the `SANDCASTLE_ATTEMPT` markers from the #2106 host sink in preference to the worker's stdout — the same fragility #2106 fixed for the #283 reconcile, here lower-stakes (accounting, no work lost) but it *also* silently misaligned the positional zip for every iteration after a truncated one. **The design pass the ticket asked for** (how to pair sink lines to iterations): the sink's append order **is** iteration order — `close-report.sh` runs once per iteration, in order, so `main.mts` reads the sink into the payload as `.attemptsSink` and `record-run-result.sh`'s existing `markers[i] → iterations[i]` positional zip is a drop-in over it, complete where stdout was lossy. Preferred, **not** `sort -u`-unioned the way the reconcile does: that consumer needs only the SET and may reorder; this one needs the ORDER. Falls back to `.stdout` when no sink was captured (bare `pnpm run sandcastle`, or a best-effort sink skip ⇒ exactly pre-#2110). The `#200` account-fp lines stay on `.stdout` — `close-report.sh` does not emit them to the sink. **Why `main.mts` reads the sink, not `record-run-result.sh`:** `record-run-result.sh` runs *after* `driveMirrorStop()` has already `rmSync`'d `HOST_ATTEMPTS_DIR`, so it cannot read the file itself — `main.mts` captures it into the payload before the teardown. **Commits** - idss `328ec114` — vendored fix + STATUS.md, `FACTORY_REF edde808→e77a951`, pushed to `main`. - dev-factory `backport/idss-2110` `e77a951cc3eaa43cebdd3b5f349eab3f0777b344` (off the pin `edde808`, stacked on #2106) — `main.mts` + `record-run-result.sh` + the test. **Proof (red-before-green, offline, real script + real swarm-db.py):** - New `record-run-result-test.sh` group: a worker piped close-report through `| tail`, so iteration 1's `901` marker never reached `.stdout`; only `902`'s did. **RED** before the fix (`FAIL: ... MUST be recovered from the sink`); **GREEN** after — `901` recovered from the sink, both attempts recorded, and the zip correctly pairs `901`→iteration 1 (111 input tokens), `902`→iteration 2 (222), no stranded issue-NULL row. - New empty-`.attemptsSink` group proves the stdout fallback (pre-#2110) still holds. - Suite `record-run-result: 14 groups passed` (was 12). `execute-lib-test.sh` / `close-report-test.sh` green. Vendor drift-gate OK, `FACTORY_MANIFEST` no churn, clean `# Source:` (no token leak). **Follow-up filed:** #2112 — #2106's `execute-lib.sh` sink read is defeated in production by the *same* `driveMirrorStop` teardown (it reads `EXECUTE_ATTEMPTS_SINK` after `main.mts` has `rmSync`'d the dir on exit; the offline test shims `pnpm` so the real deletion never runs). Out of #2110's scope (the reconcile consumer) — `ready-for-session`. Ruled by agent under ADR 0174 — veto anytime. Revertible: `git revert 328ec114` + reset `backport/idss-2110`. Provable: the vendored red-before-green suite above.
matou-build-agent 2026-10-30 12:29:36 +00:00
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#2110
No description provided.