forward-port the backport/idss-2145 chain (#2106/#2110/#2112/#2119/#2134/#2145) onto main — idss #2147 #322

Closed
matou-build-agent wants to merge 0 commits from fp/idss-2147 into main

Forward-ports the backport/idss-2145 chain (built off the idss FACTORY_REF pin afc0303, the #1684 cheap-backport route) onto dev-factory main. Tracks idss #2147 (the #2053 standing forward-port debt for this chain).

Commits (6)

# fix files
#2106 #283 stranded-close reconcile reads a host-mounted sink (EXECUTE_ATTEMPTS_SINK), not only the worker's piped stdout close-report.sh execute-lib.sh main.mts run-swarm.sh
#2110 the #574 swarm.db telemetry parse reads the host sink (.attemptsSink), not only the worker's stdout main.mts record-run-result.sh
#2112 the reconcile reads a sink that OUTLIVES main.mts's driveMirrorStop teardown (persisted to SWARM_HOST_ATTEMPTS_SINK outside the mount), not one inside the torn-down mount main.mts run-swarm.sh
#2119 the reconcile also runs on the land-SUCCESS path, not only on a rollback landing-lib.sh
#2134 gate-lib prunes .sandcastle/worktrees/ from the Go/gofmt scans gate-lib.sh
#2145 the in-sandbox lister fetches ONLY the fleet pick (GET /issues/<n>); rc 124 from the lister leg fails LOUD (no laundered [], finishing #1425) claim-next-task.sh list-ready-tasks.sh

Deliberately EXCLUDED — #2104 (06f6576)

The chain's base commit 06f6576 (#445 protected-path boundary: attribute by origin/main) is NOT forward-ported. dev-factory main already decided against it: a divergent #2104 fix was pushed to main as 0456fd3 and then reverted (6142899) — "that commit was an erroneous push to main … #2104 stays fixed via the backport." main subsequently adopted a different design for the same false-attribution problem (#321 5b42a83, truncated-snapshot degrade; #320 20ce86b). Re-introducing #2104 would recreate the exact duplicate-divergent-trunk-fix the revert warned against and conflict with #321 — a design decision reserved for a human, not a mechanical forward-port.

The one conflict this caused (#2112's on_exit cleanup in run-swarm.sh, which sat next to a #2104-only line) was resolved by keeping main's #761 VERIFY_PP_RUNDIR snapshot-cleanup line, dropping the #2104 VERIFY_PP_BEFORE_DIRTY line, and adding only #2112's SWARM_HOST_ATTEMPTS_SINK cleanup. No #2104 / PP_CANONICAL / BEFORE_DIRTY symbols are introduced by this PR.

Verification (offline, this branch)

Green: list-ready-tasks-test claim-next-task-test gate-lib-test (the idss #2147 named proof) + execute-lib-test close-report-test record-run-result-test landing-lib-test run-swarm-stages-test run-swarm-landing-test run-swarm-reconcile-summary-test run-swarm-ready-list-test verify-lib-test protected-paths-lib-test. main.mts symbol-checked (HOST_ATTEMPTS_DIR, readFileSync/writeFileSync imports resolve; no duplicated #2106 blocks). shellcheck not installed locally — CI runs it.

Note for the reviewer: idss #2147's body states "dev-factory is LANDING=pr"; that premise is stale (dev-factory is LANDING=push since #276). This is filed as a PR anyway to honour idss #2147's inherited landing-pr policy (ADR 0267) — this work lands by a human-reviewed merge.

🤖 Generated with Claude Code

Forward-ports the `backport/idss-2145` chain (built off the idss `FACTORY_REF` pin `afc0303`, the #1684 cheap-backport route) onto dev-factory `main`. Tracks idss **#2147** (the #2053 standing forward-port debt for this chain). ## Commits (6) | # | fix | files | |---|-----|-------| | #2106 | `#283` stranded-close reconcile reads a host-mounted sink (`EXECUTE_ATTEMPTS_SINK`), not only the worker's piped stdout | `close-report.sh` `execute-lib.sh` `main.mts` `run-swarm.sh` | | #2110 | the `#574` swarm.db telemetry parse reads the host sink (`.attemptsSink`), not only the worker's stdout | `main.mts` `record-run-result.sh` | | #2112 | the reconcile reads a sink that OUTLIVES `main.mts`'s `driveMirrorStop` teardown (persisted to `SWARM_HOST_ATTEMPTS_SINK` outside the mount), not one inside the torn-down mount | `main.mts` `run-swarm.sh` | | #2119 | the reconcile also runs on the land-SUCCESS path, not only on a rollback | `landing-lib.sh` | | #2134 | `gate-lib` prunes `.sandcastle/worktrees/` from the Go/gofmt scans | `gate-lib.sh` | | #2145 | the in-sandbox lister fetches ONLY the fleet pick (`GET /issues/<n>`); rc 124 from the lister leg fails LOUD (no laundered `[]`, finishing #1425) | `claim-next-task.sh` `list-ready-tasks.sh` | ## Deliberately EXCLUDED — #2104 (`06f6576`) The chain's base commit `06f6576` (`#445` protected-path boundary: attribute by `origin/main`) is **NOT** forward-ported. dev-factory `main` already decided against it: a divergent #2104 fix was pushed to main as `0456fd3` and then **reverted** (`6142899`) — "that commit was an erroneous push to main … #2104 stays fixed via the backport." main subsequently adopted a *different* design for the same false-attribution problem (#321 `5b42a83`, truncated-snapshot degrade; #320 `20ce86b`). Re-introducing #2104 would recreate the exact duplicate-divergent-trunk-fix the revert warned against and conflict with #321 — a design decision reserved for a human, not a mechanical forward-port. The one conflict this caused (#2112's `on_exit` cleanup in `run-swarm.sh`, which sat next to a #2104-only line) was resolved by keeping main's #761 `VERIFY_PP_RUNDIR` snapshot-cleanup line, dropping the #2104 `VERIFY_PP_BEFORE_DIRTY` line, and adding only #2112's `SWARM_HOST_ATTEMPTS_SINK` cleanup. No #2104 / `PP_CANONICAL` / `BEFORE_DIRTY` symbols are introduced by this PR. ## Verification (offline, this branch) Green: `list-ready-tasks-test` `claim-next-task-test` `gate-lib-test` (the idss #2147 named proof) **+** `execute-lib-test` `close-report-test` `record-run-result-test` `landing-lib-test` `run-swarm-stages-test` `run-swarm-landing-test` `run-swarm-reconcile-summary-test` `run-swarm-ready-list-test` `verify-lib-test` `protected-paths-lib-test`. `main.mts` symbol-checked (`HOST_ATTEMPTS_DIR`, `readFileSync`/`writeFileSync` imports resolve; no duplicated #2106 blocks). shellcheck not installed locally — CI runs it. > Note for the reviewer: idss #2147's body states "dev-factory is LANDING=pr"; that premise is stale (dev-factory is `LANDING=push` since #276). This is filed as a PR anyway to honour idss #2147's inherited `landing-pr` policy (ADR 0267) — this work lands by a human-reviewed merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The SANDCASTLE_ATTEMPT protocol line was #283's ONLY sandbox->host channel:
close-report.sh echoes it to stdout, `pnpm run sandcastle | tee $log` captures
it on the host, and execute-lib greps it out of $log into EXECUTE_ATTEMPTS_FILE
for landing_reopen_stranded_closes. A worker that pipes close-report through
`| tail`/`| head` truncates the line away before it reaches $log (run 57327:
`close-report.sh 2099 … 2>&1 | tail -40` pushed the line out of the last-40
window), so the capture came up empty and the reconcile never fired on a
genuinely stranded close — the protected-path rollback stranded #2099's close
and a human reopened it by hand. A reconcile that a worker's own trailing pipe
can defeat is not a reconcile.

Fix: give the attempt record a second crossing independent of the worker's
stdout piping. close-report.sh ALSO appends the line to a host-mounted sink
(SANDCASTLE_ATTEMPT_SINK, default /run/host-attempts/attempts.log) — a file
write no `| tail`/`| head` on its stdout can drop; one short line via a single
append is atomic under PIPE_BUF so two concurrent workers (ADR 0184) never
interleave. main.mts mounts a run-scoped WRITABLE HOST_ATTEMPTS_DIR there
(symmetric to the read-only host-signals mount) and removes it on exit;
run-swarm.sh exports SWARM_HOST_ATTEMPTS_DIR (shared with main.mts) and
EXECUTE_ATTEMPTS_SINK; execute-lib unions the log grep with the sink and
sort -u's them, so a line on both channels dedupes and a run with no sink
degrades to the old log grep exactly as before.

Red-before-green: execute-lib-test 1d (a tail-swallowed line recovered from the
sink) + 1e (both-channels dedupe); close-report-test T1b (the line lands in the
sink, stdout echo retained).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit edde808561)
The SANDCASTLE_ATTEMPT protocol line close-report.sh emits is parsed by TWO
independent host-side consumers. #2106 fixed the first — the #283 stranded-close
reconcile — to read the line from a host-mounted sink close-report appends to,
because a worker that pipes close-report through `| tail`/`| head` truncates the
line out of the combined worker stdout before it reaches the host. record-run-result.sh
(the #574 attempts/spend writer) had the SAME fragility: it built its `$markers`
from `.stdout` only, so a truncating worker both lost that iteration's attempt/spend
rows AND misaligned the positional zip (markers[i] -> iteration i) for every later
iteration — silently.

Fix: main.mts reads the sink (HOST_ATTEMPTS_DIR/attempts.log) into the payload as
`.attemptsSink` BEFORE driveMirrorStop tears the mount down — record-run-result.sh
runs after that teardown, so it cannot read the file itself. record-run-result.sh
then builds `$markers` from `.attemptsSink` when non-empty, falling back to `.stdout`
(a bare run, or a best-effort sink skip => exactly pre-#2110). Preferred, NOT sort -u
unioned the way the reconcile does: the reconcile needs only the SET and may reorder;
this consumer needs the per-iteration ORDER, which the sink's append order preserves
(close-report runs once per iteration, in order). The #200 account-fp lines stay on
`.stdout` — close-report does not emit them to the sink.

Red-before-green: record-run-result-test.sh gains a truncated-stdout/complete-sink
group (901's marker `| tail`'d from stdout, recovered from the sink + correctly
zipped) and an empty-sink stdout-fallback group.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit e77a951cc3)
#2106 taught execute-lib.sh's execute_sandcastle_run to read close-report's
SANDCASTLE_ATTEMPT line from a host-mounted sink (EXECUTE_ATTEMPTS_SINK) in
union with the sandcastle-log grep, so a worker that pipes close-report through
`| tail`/`| head` no longer starves #283's false-green reconcile. In production
that sink read always came up empty: EXECUTE_ATTEMPTS_SINK pointed inside
SWARM_HOST_ATTEMPTS_DIR, and main.mts's driveMirrorStop() rmSync's that
run-scoped dir on EVERY exit path — but execute-lib reads the sink only AFTER
`pnpm run sandcastle` (main.mts) returns, by which time the dir and its
attempts.log are gone. So the union silently degraded back to the very log grep
#2106 set out to stop trusting, and the reconcile was still defeated by a
trailing `| tail`. The offline suite missed it because execute-lib-test shims
pnpm, so the real main.mts (and its deletion) never runs.

Fix (symmetric to #2110's read-before-teardown): run-swarm.sh points
EXECUTE_ATTEMPTS_SINK at a durable host file OUTSIDE the mount
(SWARM_HOST_ATTEMPTS_SINK, mktemp'd, cleaned by the EXIT trap); main.mts, after
reading the sink into memory for #2110 and BEFORE driveMirrorStop, PERSISTS that
content to SWARM_HOST_ATTEMPTS_SINK — a path the teardown does not touch — so the
post-run read finds it. Best-effort throughout: a bare run (no env var) or a
write error leaves the sink empty and execute-lib falls back to the log grep,
exactly as before #2106.

execute-lib.sh is unchanged (it already reads EXECUTE_ATTEMPTS_SINK post-run).
run-swarm.sh drops the local var to keep under the stage-extraction line cap.

Red-before-green: execute-lib-test.sh gains case 1f, whose pnpm shim MODELS the
real exit ordering — it persists the mounted sink to the host path and then
rmSync's the run-scoped mount dir (driveMirrorStop) before execute-lib reads —
so the regression can no longer re-hide behind a pre-written, never-deleted sink.
With the pre-fix wiring (sink inside the mount, no persist) the attempt is lost;
with the fix it survives the teardown. run-swarm-stages/-landing,
record-run-result, close-report suites all green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

(cherry picked from commit 40d60ac5e7)
A push-mode promote can return 0 while advancing nothing: `git push origin
HEAD:main` answers "Everything up-to-date" when the worker's commit never
reached the runner HEAD (the mirror dropped it). landing_stage then returns 0,
main stays put, and the two #283 reconciles in run-swarm.sh — both wired to the
FAILURE exits only — never run. The sandbox close-report had already closed the
issue against the un-promoted worker branch, so it is left `closed success` with
its commits reachable from no `main` (idss #2100/#2102 stranded 2026-10-31;
#2097/#2099 before them, reopened by hand).

landing_stage now re-runs landing_reopen_stranded_closes on its own success
path, but ONLY when the promote was SHA-preserving: landing_push_main_with_rescue
sets LANDING_PROMOTE_CLEAN on a first-try fast-forward/no-op push and leaves it
cleared on the rebase ladder (which rewrites the worker SHAs onto main, where a
by-SHA reachability check would false-reopen genuinely-landed work). It reads the
same exported EXECUTE_ATTEMPTS_FILE the failure-path reconciles use and refetches
origin/main so a sibling-promoted commit reads as reachable. `|| true` keeps a
clean land's summary path intact.

Tests (offline, landing-lib-test.sh): the flag is set on a first-try push and
cleared on a rebase landing; a no-op promote with an unreachable claimed commit
reopens the stranded close on the success path; a commit that IS on main is left
closed; pr mode never sets the flag and so never runs the success-path reconcile.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 4dc855df49)
The host gofmt gate (gate_gofmt_tree_go_files, Gate 3b #1458) and the
sandbox Go seam (gate_go_default_cmd) scanned the whole tree pruning only
node_modules/ and .sandcastle/nix-store/. They did NOT prune
.sandcastle/worktrees/ — the gitignored dir holding every SIBLING worker's
live worktree — so one worker's in-flight un-gofmt'd Go refused every other
concurrent Go worker's push at random (idss run 59079, push-rescue-unreachable).

A sibling's worktree is the same class of foreign tree as nix-store: files
this repo does not own and cannot fix. Add -not -path './.sandcastle/worktrees/*'
to both scans. Prune the input, never the exit status — the gate still fails
closed on real debt and on an empty scan.

Red-before-green: tests/gate-lib-test.sh seeds a sibling worker's worktree
with gofmt debt and asserts it neither blocks a clean push nor appears in the
verdict for the repo's own debt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 6da7606377)
sandcastle: the in-sandbox lister fetches ONLY the fleet pick; rc 124 fails loud (idss #2145)
Some checks failed
ci / test (pull_request) Failing after 7m10s
ci / static (pull_request) Failing after 3m12s
7f9d8e13a5
The swarm claimed NOTHING for hours while 8 tickets were ready: the host runs
list-ready-tasks.sh OUTSIDE the sandbox's 30s prompt-expansion budget and, under
the #301 fleet queue, has already chosen this run's ONE ticket — yet the
in-sandbox lister (run inside claim-next-task.sh, under that hard 30s budget)
re-fetched the WHOLE ready-for-agent page and narrowed to the pick only at the
foot. That page is the forge's dominant cost (8-22s to serialise ~20 full-body
issues); page + claim walk could not both fit 30s, so a slow-forge tick blew
claim-next-task.sh's CLAIM_LISTER_MAX_TIME (12s) and rc 124 was laundered into a
graceful [] — which the prompt renders as an EMPTY ready queue a worker reads as
"nothing to do". Fail-closed at the script, fail-OPEN at the surface (the
idss#1425 shape, on the leg idss#1425 left open).

list-ready-tasks.sh: when the fleet-pick signal names this run's one ticket,
fetch just that issue (GET /issues/<n>, ~2s) instead of the page — the
dependency check, the agent-working/standing-drive/rehearsal-marker filters, the
open-PR drop, the run-landing parity and the fleet-pick narrowing all run
UNCHANGED on the 1-element batch, so the OUTPUT is identical to the full-page
path (which already narrowed to exactly this pick); only the fetch cost changes.
The standing-drive listing is skipped on this path (ordering a 1-element queue is
meaningless). No pick (a host with no fleet view) → the full page, byte-identical
to before.

claim-next-task.sh: finish idss#1425 on the lister leg — rc 124 now exits
non-zero (no []), exactly like the alive-runs arm, so a lister that genuinely
cannot complete surfaces as a NAMED fault the healer sees, never a silent idle
lane.

Tests: list-ready-tasks-test.sh proves the fast path GETs /issues/<n> and
touches neither the ready-for-agent page nor the standing-drive listing, and a
gone pick still answers [] + names it; claim-next-task-test.sh's slow-lister case
now asserts a non-empty-queue timeout fails LOUD, not [].

Carries 6da7606 (idss #2134 gofmt-scan prune) as its parent — continues the
linear backport/idss-* chain off backport/idss-2134.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 4e8316c2f9)
Owner

Landed on main as merge 9517ff2 (2026-11-04, inside de5ebb8); Forgejo did not detect the merge. Closing.

Landed on main as merge `9517ff2` (2026-11-04, inside `de5ebb8`); Forgejo did not detect the merge. Closing.
ben closed this pull request 2026-11-18 04:11:43 +00:00
Some checks failed
ci / test (pull_request) Failing after 7m10s
ci / static (pull_request) Failing after 3m12s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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/dev-factory!322
No description provided.