#327 regressed: the fleet-pick-task mirror never arms without a pick, and #370's stale cache makes every cron-backstop tick red with claim rc 124 #381

Closed
opened 2026-11-20 03:27:56 +00:00 by matou-build-agent · 3 comments

Filed by the healer from run https://git.matou.nz/Matou/matou-app/actions/runs/55500 (leg swarm (matou-workstation), task Matou-matou-app-55500-951470). Signature 2196e4460dad — the same signature as #327, which was closed with only half of its own recommendation implemented. Evidence bundle: /tmp/matou-heal-Matou-matou-app.YryWUL on matou-dev-server-01.

Symptom

run-verdict.txt / .sandcastle/logs/sandcastle-worker-20261120031909-951470-worker.log:

Setting up sandbox done (2.9s)
Expanding shell expressions
Failed to resolve prompt: Command `bash .sandcastle/claim-next-task.sh` exited with code 124:
claim-next-task: the lister exceeded its 12s wall-clock bound — failing LOUD ...

Root cause — two landed changes that compose badly

1. #327's fix is still gated on a pick. schedule-lib.sh:284 opens with
[ -n "${SCHEDULE_FLEET_PICK:-}" ] || return 0, so neither /run/host-signals/fleet-pick nor the #327 fleet-pick-task object is written when the host has no fleet view. #327's own preferred direction was "mirror the host's ready-set … on every path, not only when SCHEDULE_FLEET_PICK is set"; what landed mirrors the richer object but keeps the guard. So on a no-fleet-view host the in-sandbox lister still pays the full page (issues?labels=ready-for-agent&limit=50 + /pulls + one /dependencies per candidate) inside CLAIM_LISTER_MAX_TIME=12 (claim-next-task.sh:86) — exactly the path #327 was filed about.

2. #370's stale cache turned "no fleet view" from rare into permanent. The ADR 0009 dispatcher stand-down (fleet-queue.sh:104-107, idss af63c7c8) exit 0s before fleet_queue_cache_write. On matou-workstation every tick since 21:20Z on 2026-11-19 has logged a live dispatcher acknowledged … standing this tick's dispatch down (~/swarm/logs/fleet-queue.log), and ~/swarm/state/fleet-queue.json has an mtime of 2026-11-19 21:18:08Z — ~6 h stale against FLEET_QUEUE_CACHE_TTL=600. fleet_queue_cache_head therefore returns rc 1 on every cron/closed backstop leg. #370 already lists "The stale fleet-queue.json under a live dispatcher is either refreshed or ruled harmless" as acceptance; this run is the proof that it is not harmless.

Proof it was the no-pick path

swarm.db events for Matou-matou-app-55500-951470:

03:16:50  host       host=matou-dev-server-01 runner=matou-workstation
03:18:36  ready-set  16 ready task(s)

run-swarm.sh emits ready-set after schedule_fleet_pick. A pick narrows $ready to one element, so a pick would have logged 1 ready task(s). 16 means SCHEDULE_FLEET_PICK was empty → no signal files → full-page lister in the sandbox. event for every leg of run 55500 is schedule (runs.json), i.e. the 15,45 cron backstop, which carries no inputs.ticket.

Latency (healer probe, 03:30Z, same host/token)

read time
issues?state=open&labels=ready-for-agent&limit=50 (28 issues, 97 KB) 2.50s / 2.56s / 6.98s
pulls?state=open&limit=50 4.26s
issues/<n>/dependencies ~0.74s each
whole host-side list-ready-tasks.sh (0 survivors) 4.26-4.92s

The forge is healthy and the host-side lister already costs 4-9s with a single page read swinging to 7s. With 16 surviving candidates, plus docker NAT and a sandbox competing with the run's pnpm install, 12s has no margin at all. This is no longer a "slow-forge window" fault (#327's framing) — on a host with a permanently stale cache it reds every cron tick that finds work. Runs 55457/55474/55483/55491 were all green only because they ended no-ready-tasks; 55500 was the first tick since the dispatcher went live that actually had work.

Suggested direction (a design call)

  1. Drop the guard in schedule_fleet_pick_signal — mirror the host's verified ready-set as fleet-pick-task on every path, picked or not. The host computes it outside the 30s prompt-expansion budget and throws it away today; this is #327 direction 1, finished. The in-sandbox lister then never re-fetches the page, and the budget race is gone for every host regardless of fleet view.
  2. Refresh the cache before the ADR 0009 stand-down (move fleet_queue_cache_write above the gate, or have the dispatcher write the host cache) — closes #370's open acceptance item and restores the pick path. Good on its own merits, but it leaves the no-fleet-view host (a host not enrolled with a dispatcher, or one whose cache is cold) still exposed, so it is not a substitute for (1).
  3. Raising CLAIM_LISTER_MAX_TIME alone is still not recommended — see #327 and the CLAIM_NEXT_DEADLINE arithmetic at claim-next-task.sh:60-74; it converts rc 124 into PromptExpansionTimeoutError against Sandcastle's hard-coded 30s.

Acceptance

  • A cron/closed swarm leg on a host with no fleet view (stale or absent fleet-queue.json) resolves claim-next-task.sh without rc 124, with the ready-set mirrored rather than re-fetched.
  • tests/claim-next-task-test.sh + the list-ready tests assert the no-pick case: a fleet-pick-task signal present with no fleet-pick number, and the lister emitting it with zero forge reads.
  • #370's "stale fleet-queue.json under a live dispatcher" item is closed out one way or the other, with the reason written down.
  • A docs/GOTCHAS.md row: the in-sandbox lister's 12s bound is only safe because the host mirrors its verdict — any path that skips the mirror re-arms this fault.

Notes for whoever takes it

  • The fix is in the factory source at the repo root (schedule-lib.sh / list-ready-tasks.sh / fleet-queue.sh). A root change does not reach a consumer's running .sandcastle/ copy until a human re-vendors (bash onboarding/onboard.sh vendor .sandcastle <sha>, GOTCHAS 4) — matou-app is pinned at FACTORY_REF d468efc and does not even carry the ADR 0009 gate, yet is affected, because the host tick runs the first checkout's copy (FLEET_QUEUE_REPOS → Matou/idss, at 8ed0e00). So every repo this host serves shares the one stale cache.
  • Interacts with #370 (open, ready-for-human), #327 (closed, incomplete), #357 (the dispatcher flip) and #350.
  • The healer made no repair: matou-app lands every change by reviewed PR (idss ADR 0267), and the faulty code is factory-owned and vendored, not matou-app's.
Filed by the healer from run https://git.matou.nz/Matou/matou-app/actions/runs/55500 (leg `swarm (matou-workstation)`, task `Matou-matou-app-55500-951470`). Signature `2196e4460dad` — **the same signature as #327**, which was closed with only half of its own recommendation implemented. Evidence bundle: `/tmp/matou-heal-Matou-matou-app.YryWUL` on matou-dev-server-01. ## Symptom `run-verdict.txt` / `.sandcastle/logs/sandcastle-worker-20261120031909-951470-worker.log`: ``` Setting up sandbox done (2.9s) Expanding shell expressions Failed to resolve prompt: Command `bash .sandcastle/claim-next-task.sh` exited with code 124: claim-next-task: the lister exceeded its 12s wall-clock bound — failing LOUD ... ``` ## Root cause — two landed changes that compose badly **1. #327's fix is still gated on a pick.** `schedule-lib.sh:284` opens with `[ -n "${SCHEDULE_FLEET_PICK:-}" ] || return 0`, so **neither** `/run/host-signals/fleet-pick` **nor** the #327 `fleet-pick-task` object is written when the host has no fleet view. #327's own preferred direction was *"mirror the host's ready-set … on **every** path, not only when `SCHEDULE_FLEET_PICK` is set"*; what landed mirrors the richer object but keeps the guard. So on a no-fleet-view host the in-sandbox lister still pays the **full page** (`issues?labels=ready-for-agent&limit=50` + `/pulls` + one `/dependencies` per candidate) inside `CLAIM_LISTER_MAX_TIME=12` (`claim-next-task.sh:86`) — exactly the path #327 was filed about. **2. #370's stale cache turned "no fleet view" from rare into permanent.** The ADR 0009 dispatcher stand-down (`fleet-queue.sh:104-107`, idss `af63c7c8`) `exit 0`s **before** `fleet_queue_cache_write`. On matou-workstation every tick since 21:20Z on 2026-11-19 has logged `a live dispatcher acknowledged … standing this tick's dispatch down` (`~/swarm/logs/fleet-queue.log`), and `~/swarm/state/fleet-queue.json` has an mtime of **2026-11-19 21:18:08Z** — ~6 h stale against `FLEET_QUEUE_CACHE_TTL=600`. `fleet_queue_cache_head` therefore returns rc 1 on every cron/`closed` backstop leg. #370 already lists *"The stale `fleet-queue.json` under a live dispatcher is either refreshed or ruled harmless"* as acceptance; **this run is the proof that it is not harmless.** ## Proof it was the no-pick path `swarm.db` events for `Matou-matou-app-55500-951470`: ``` 03:16:50 host host=matou-dev-server-01 runner=matou-workstation 03:18:36 ready-set 16 ready task(s) ``` `run-swarm.sh` emits `ready-set` **after** `schedule_fleet_pick`. A pick narrows `$ready` to one element, so a pick would have logged `1 ready task(s)`. **16** means `SCHEDULE_FLEET_PICK` was empty → no signal files → full-page lister in the sandbox. `event` for every leg of run 55500 is `schedule` (`runs.json`), i.e. the `15,45` cron backstop, which carries no `inputs.ticket`. ## Latency (healer probe, 03:30Z, same host/token) | read | time | | --- | --- | | `issues?state=open&labels=ready-for-agent&limit=50` (28 issues, 97 KB) | 2.50s / 2.56s / **6.98s** | | `pulls?state=open&limit=50` | 4.26s | | `issues/<n>/dependencies` | ~0.74s each | | whole host-side `list-ready-tasks.sh` (0 survivors) | 4.26-4.92s | The forge is *healthy* and the host-side lister already costs 4-9s with a single page read swinging to 7s. With 16 surviving candidates, plus docker NAT and a sandbox competing with the run's `pnpm install`, 12s has no margin at all. This is no longer a "slow-forge window" fault (#327's framing) — on a host with a permanently stale cache it reds **every cron tick that finds work**. Runs 55457/55474/55483/55491 were all green only because they ended `no-ready-tasks`; 55500 was the first tick since the dispatcher went live that actually had work. ## Suggested direction (a design call) 1. **Drop the guard in `schedule_fleet_pick_signal`** — mirror the host's verified ready-set as `fleet-pick-task` on every path, picked or not. The host computes it outside the 30s prompt-expansion budget and throws it away today; this is #327 direction 1, finished. The in-sandbox lister then never re-fetches the page, and the budget race is gone for every host regardless of fleet view. 2. **Refresh the cache before the ADR 0009 stand-down** (move `fleet_queue_cache_write` above the gate, or have the dispatcher write the host cache) — closes #370's open acceptance item and restores the pick path. Good on its own merits, but it leaves the no-fleet-view host (a host not enrolled with a dispatcher, or one whose cache is cold) still exposed, so it is not a substitute for (1). 3. Raising `CLAIM_LISTER_MAX_TIME` alone is still **not recommended** — see #327 and the `CLAIM_NEXT_DEADLINE` arithmetic at `claim-next-task.sh:60-74`; it converts rc 124 into `PromptExpansionTimeoutError` against Sandcastle's hard-coded 30s. ## Acceptance - A cron/`closed` swarm leg on a host with **no** fleet view (stale or absent `fleet-queue.json`) resolves `claim-next-task.sh` without rc 124, with the ready-set mirrored rather than re-fetched. - `tests/claim-next-task-test.sh` + the list-ready tests assert the **no-pick** case: a `fleet-pick-task` signal present with no `fleet-pick` number, and the lister emitting it with zero forge reads. - #370's "stale `fleet-queue.json` under a live dispatcher" item is closed out one way or the other, with the reason written down. - A `docs/GOTCHAS.md` row: the in-sandbox lister's 12s bound is only safe because the host mirrors its verdict — any path that skips the mirror re-arms this fault. ## Notes for whoever takes it - The fix is in the factory **source** at the repo root (`schedule-lib.sh` / `list-ready-tasks.sh` / `fleet-queue.sh`). A root change does not reach a consumer's running `.sandcastle/` copy until a human re-vendors (`bash onboarding/onboard.sh vendor .sandcastle <sha>`, GOTCHAS 4) — matou-app is pinned at `FACTORY_REF` `d468efc` and does not even carry the ADR 0009 gate, yet is affected, because the host tick runs the **first** checkout's copy (`FLEET_QUEUE_REPOS` → `Matou/idss`, at `8ed0e00`). So every repo this host serves shares the one stale cache. - Interacts with #370 (open, `ready-for-human`), #327 (closed, incomplete), #357 (the dispatcher flip) and #350. - The healer made **no repair**: matou-app lands every change by reviewed PR (idss ADR 0267), and the faulty code is factory-owned and vendored, not matou-app's.
Author
Member

swarm-claim host=bens-mac-04 run=29031
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=29031 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

⏩ independent reviewer for #381 — verdict unauthenticated

review JSON
{
  "verdict": "unauthenticated",
  "findings": []
}
:fast_forward: **independent reviewer** for #381 — verdict `unauthenticated` <details><summary>review JSON</summary> ```json { "verdict": "unauthenticated", "findings": [] } ``` </details>
Author
Member

close-report for #381 — status success

✅ close-report gates passed — every claim verified against the pushed worker branch sandcastle/worker/20261120032838-3834852 (pre-land — the host promotes it to main only after its post-run verify, #193/#283); issue closed.

envelope
{
  "issue": 381,
  "status": "success",
  "commits": [
    "4afc3980b141681fae9fe969efc73d7439e44319"
  ],
  "changed_files": [
    "docs/GOTCHAS.md",
    "docs/gotchas/381-lister-12s-bound-safe-only-while-host-mirrors-its-verdict.md",
    "docs/journal/2026-11-20-381.md",
    "run-swarm.sh",
    "schedule-lib.sh",
    "tests/claim-next-task-test.sh",
    "tests/list-ready-tasks-test.sh",
    "tests/schedule-lib-test.sh",
    "tests/ticket-landing-test.sh"
  ],
  "tests": [
    {
      "command": "bash tests/schedule-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/ticket-landing-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/list-ready-tasks-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/claim-next-task-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/run-swarm-stages-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/docs-budget-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A cron/closed swarm leg on a host with no fleet view (stale or absent fleet-queue.json) resolves claim-next-task.sh without rc 124, with the ready-set mirrored rather than re-fetched": "schedule-lib.sh schedule_fleet_pick_signal drops the SCHEDULE_FLEET_PICK guard and mirrors the host's full verified ready-set as fleet-pick-task on the no-pick path; run-swarm.sh writes it (narrowed by schedule_apply_run_landing). claim-next-task-test.sh T-#381 drives the REAL lister with a no-pick task signal end-to-end: it claims the head, exits 0 (never rc 124), and the lister re-fetches NO ready-for-agent page and runs NO dependency fan-out.",
    "tests/claim-next-task-test.sh + the list-ready tests assert the no-pick case: a fleet-pick-task signal present with no fleet-pick number, and the lister emitting it with zero forge reads": "claim-next-task-test.sh T-#381 (no fleet-pick number file, zero ready-for-agent/dependencies reads in calls.log, exit 0); list-ready-tasks-test.sh case 6g (multi-ticket no-pick task signal, no number file, whole set emitted with an EMPTY curl log); schedule-lib-test.sh no-pick group (full ready-set mirrored as fleet-pick-task with NO fleet-pick number).",
    "#370's stale fleet-queue.json under a live dispatcher item is closed out one way or the other, with the reason written down": "Ruled HARMLESS under ADR 0174 (two-way door): the every-path mirror removes the rc-124 fault the stale cache caused, so no refresh is implemented (direction 2 would force a full fleet collect on every stand-down tick). Reason written in docs/journal/2026-11-20-381.md and docs/gotchas/381-*, and posted as a comment on #370. fleet-queue.sh is unchanged.",
    "A docs/GOTCHAS.md row: the in-sandbox lister's 12s bound is only safe because the host mirrors its verdict — any path that skips the mirror re-arms this fault": "docs/GOTCHAS.md index row #381 + body docs/gotchas/381-lister-12s-bound-safe-only-while-host-mirrors-its-verdict.md; docs-budget-test.sh green (39131/40960 B)."
  },
  "summary": "schedule_fleet_pick_signal now mirrors the host's verified ready-set as fleet-pick-task on every path (not only when a fleet pick exists), narrowed run-landing-parity-correct by schedule_apply_run_landing, so a no-fleet-view cron leg emits the host's verdict with zero forge reads instead of re-fetching the full page and REDing claim-next-task.sh with rc 124.",
  "blockers": []
}
**close-report** for #381 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against the pushed worker branch `sandcastle/worker/20261120032838-3834852` (pre-land — the host promotes it to `main` only after its post-run verify, #193/#283); issue closed. <details><summary>envelope</summary> ```json { "issue": 381, "status": "success", "commits": [ "4afc3980b141681fae9fe969efc73d7439e44319" ], "changed_files": [ "docs/GOTCHAS.md", "docs/gotchas/381-lister-12s-bound-safe-only-while-host-mirrors-its-verdict.md", "docs/journal/2026-11-20-381.md", "run-swarm.sh", "schedule-lib.sh", "tests/claim-next-task-test.sh", "tests/list-ready-tasks-test.sh", "tests/schedule-lib-test.sh", "tests/ticket-landing-test.sh" ], "tests": [ { "command": "bash tests/schedule-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/ticket-landing-test.sh", "exit_code": 0 }, { "command": "bash tests/list-ready-tasks-test.sh", "exit_code": 0 }, { "command": "bash tests/claim-next-task-test.sh", "exit_code": 0 }, { "command": "bash tests/run-swarm-stages-test.sh", "exit_code": 0 }, { "command": "bash tests/docs-budget-test.sh", "exit_code": 0 } ], "criteria": { "A cron/closed swarm leg on a host with no fleet view (stale or absent fleet-queue.json) resolves claim-next-task.sh without rc 124, with the ready-set mirrored rather than re-fetched": "schedule-lib.sh schedule_fleet_pick_signal drops the SCHEDULE_FLEET_PICK guard and mirrors the host's full verified ready-set as fleet-pick-task on the no-pick path; run-swarm.sh writes it (narrowed by schedule_apply_run_landing). claim-next-task-test.sh T-#381 drives the REAL lister with a no-pick task signal end-to-end: it claims the head, exits 0 (never rc 124), and the lister re-fetches NO ready-for-agent page and runs NO dependency fan-out.", "tests/claim-next-task-test.sh + the list-ready tests assert the no-pick case: a fleet-pick-task signal present with no fleet-pick number, and the lister emitting it with zero forge reads": "claim-next-task-test.sh T-#381 (no fleet-pick number file, zero ready-for-agent/dependencies reads in calls.log, exit 0); list-ready-tasks-test.sh case 6g (multi-ticket no-pick task signal, no number file, whole set emitted with an EMPTY curl log); schedule-lib-test.sh no-pick group (full ready-set mirrored as fleet-pick-task with NO fleet-pick number).", "#370's stale fleet-queue.json under a live dispatcher item is closed out one way or the other, with the reason written down": "Ruled HARMLESS under ADR 0174 (two-way door): the every-path mirror removes the rc-124 fault the stale cache caused, so no refresh is implemented (direction 2 would force a full fleet collect on every stand-down tick). Reason written in docs/journal/2026-11-20-381.md and docs/gotchas/381-*, and posted as a comment on #370. fleet-queue.sh is unchanged.", "A docs/GOTCHAS.md row: the in-sandbox lister's 12s bound is only safe because the host mirrors its verdict — any path that skips the mirror re-arms this fault": "docs/GOTCHAS.md index row #381 + body docs/gotchas/381-lister-12s-bound-safe-only-while-host-mirrors-its-verdict.md; docs-budget-test.sh green (39131/40960 B)." }, "summary": "schedule_fleet_pick_signal now mirrors the host's verified ready-set as fleet-pick-task on every path (not only when a fleet pick exists), narrowed run-landing-parity-correct by schedule_apply_run_landing, so a no-fleet-view cron leg emits the host's verdict with zero forge reads instead of re-fetching the full page and REDing claim-next-task.sh with rc 124.", "blockers": [] } ``` </details>
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/dev-factory#381
No description provided.