schedule-backstop adds a queued-runs guard (#289) #291

Closed
matou-build-agent wants to merge 1 commit from agent/issue-289 into main

closes #289

What

schedule-backstop.sh's in-flight guard read only the CLAIMED-only
actions/tasks view. A task row exists only once a runner has PICKED the job
(CreateTaskForRunner), so a run still queued behind a stalled or saturated
runner has no task row at all — the guard read "idle" precisely when the queue
was deepest and re-dispatched on every tick. On 2026-10-15 a silently-stalled
matou-workstation runner turned this into a ~4x dispatch flood
(backstop.log 04Z = 101 dispatches / 15 skips vs a normal 24 / 92) which, on
Forgejo 15's single oldest-first queue, became a 1h45m global lag. The #238
guard's "status":"waiting" branch could only ever match the test fixtures,
never the live tasks view.

Fix

  • Keep the name-keyed tasks guard unchanged — its per-host suffix
    discrimination (GOTCHAS 62) must stay, since every per-host swarm.yml leg
    shares one workflow_id and keying that guard on workflow_id would let one
    host's running leg starve another's dispatch.
  • Add a second, fail-closed read of
    actions/runs?status=waiting&limit=50&page=1 — the one actions/runs read the
    actions-endpoint-test.sh ratchet admits (GOTCHAS 34), bounded by the
    status=waiting filter, page=1, and api()'s --max-time. A queued run of
    this workflow file suppresses the dispatch, keyed on .workflow_id == $wf
    (a run queues as a whole; an unpicked per-host leg means the pool cannot take
    more). On any failure of the new read, skip the dispatch (fail closed). The two
    guards compose; neither replaces the other.

Acceptance

  • A queued run of this workflow (in runs?status=waiting, absent from the
    tasks view) SUPPRESSES the dispatch, even with an idle tasks view.
  • A queued run of a DIFFERENT workflow does NOT suppress this one
    (.workflow_id keying).
  • .workflow_id keying exercised for a non-swarm workflow (resume-asks) as
    well as swarm.
  • A failed/unavailable runs?status=waiting read skips the dispatch (fail
    closed).
  • The existing per-host name-keyed guard behaviour is unchanged.
  • tests/schedule-backstop-test.sh carries the four new scenarios; offline
    suite green (22 scenarios), including tests/actions-endpoint-test.sh.
  • GOTCHAS 78 body + index row, docs/journal/2026-10-20-289.md, and the
    STATUS.md self-consumer surface row, all in the same commit.

Tests

$ bash tests/schedule-backstop-test.sh
schedule-backstop: 22 scenarios passed
$ bash tests/actions-endpoint-test.sh
pass=5 fail=0

Full offline suite green except two pre-existing unrelated reds on a clean tree
(tests/list-ready-tasks-test.sh, tests/run-swarm-ready-list-test.sh —
ready-list area, not this slice).

Rollout

Root-only; INERT until a human bumps FACTORY_REF + re-vendors and the host tick
checkouts pull it (pull-only, GOTCHAS 4). Out of scope: a liveness restart for a
runner that stops fetching (the ignition — a separate follow-up) and the
coa-builds wait (a downstream symptom).

Screenshots: none — this is a backstop dispatch-guard in a bash script with
no visible/UI surface; the behaviour is proven by the four new offline scenarios
in tests/schedule-backstop-test.sh (output above).

closes #289 ## What `schedule-backstop.sh`'s in-flight guard read only the CLAIMED-only `actions/tasks` view. A task row exists only once a runner has PICKED the job (`CreateTaskForRunner`), so a run still **queued** behind a stalled or saturated runner has no task row at all — the guard read "idle" precisely when the queue was deepest and re-dispatched on every tick. On 2026-10-15 a silently-stalled `matou-workstation` runner turned this into a **~4x dispatch flood** (`backstop.log` 04Z = 101 dispatches / 15 skips vs a normal 24 / 92) which, on Forgejo 15's single oldest-first queue, became a **1h45m global lag**. The #238 guard's `"status":"waiting"` branch could only ever match the test fixtures, never the live tasks view. ## Fix - **Keep** the name-keyed tasks guard unchanged — its per-host suffix discrimination (GOTCHAS 62) must stay, since every per-host `swarm.yml` leg shares one `workflow_id` and keying *that* guard on `workflow_id` would let one host's running leg starve another's dispatch. - **Add** a second, fail-closed read of `actions/runs?status=waiting&limit=50&page=1` — the one `actions/runs` read the `actions-endpoint-test.sh` ratchet admits (GOTCHAS 34), bounded by the `status=waiting` filter, `page=1`, and `api()`'s `--max-time`. A queued run of **this workflow file** suppresses the dispatch, keyed on `.workflow_id == $wf` (a run queues as a whole; an unpicked per-host leg means the pool cannot take more). On any failure of the new read, skip the dispatch (fail closed). The two guards compose; neither replaces the other. ## Acceptance - [x] A queued run of this workflow (in `runs?status=waiting`, absent from the tasks view) SUPPRESSES the dispatch, even with an idle tasks view. - [x] A queued run of a DIFFERENT workflow does NOT suppress this one (`.workflow_id` keying). - [x] `.workflow_id` keying exercised for a non-swarm workflow (resume-asks) as well as swarm. - [x] A failed/unavailable `runs?status=waiting` read skips the dispatch (fail closed). - [x] The existing per-host name-keyed guard behaviour is unchanged. - [x] `tests/schedule-backstop-test.sh` carries the four new scenarios; offline suite green (22 scenarios), including `tests/actions-endpoint-test.sh`. - [x] GOTCHAS 78 body + index row, `docs/journal/2026-10-20-289.md`, and the `STATUS.md` self-consumer surface row, all in the same commit. ## Tests ``` $ bash tests/schedule-backstop-test.sh schedule-backstop: 22 scenarios passed $ bash tests/actions-endpoint-test.sh pass=5 fail=0 ``` Full offline suite green except two pre-existing unrelated reds on a clean tree (`tests/list-ready-tasks-test.sh`, `tests/run-swarm-ready-list-test.sh` — ready-list area, not this slice). ## Rollout Root-only; INERT until a human bumps `FACTORY_REF` + re-vendors and the host tick checkouts pull it (pull-only, GOTCHAS 4). Out of scope: a liveness restart for a runner that stops fetching (the ignition — a separate follow-up) and the `coa-builds` wait (a downstream symptom). **Screenshots:** none — this is a backstop dispatch-guard in a bash script with no visible/UI surface; the behaviour is proven by the four new offline scenarios in `tests/schedule-backstop-test.sh` (output above).
sandcastle: #289 — schedule-backstop adds a queued-runs guard (GOTCHAS 78), INERT until re-vendor
All checks were successful
ci / static (pull_request) Successful in 2m32s
ci / test (pull_request) Successful in 5m20s
384a1906d9
The in-flight guard read only the CLAIMED-only actions/tasks view. A task row
exists only once a runner has PICKED the job (CreateTaskForRunner), so a run
still queued behind a stalled/saturated runner has no task row — the guard read
"idle" precisely when the queue was deepest and re-dispatched every tick. On
2026-10-15 a silently-stalled matou-workstation runner turned that into a ~4x
dispatch flood (backstop.log 04Z = 101 dispatches / 15 skips vs a normal
24 / 92); on Forgejo 15's single oldest-first queue it became a 1h45m global
lag. The #238 guard's "status":"waiting" branch could only ever match the test
fixtures, never the live tasks view.

Fix (root schedule-backstop.sh + tests/schedule-backstop-test.sh):
- Keep the name-keyed tasks guard unchanged (its per-host suffix, GOTCHAS 62,
  must stay — every per-host swarm leg shares one workflow_id, so keying THAT
  guard on workflow_id would let one host's running leg starve another's).
- Add a second, fail-closed read of actions/runs?status=waiting&limit=50&page=1
  — the one actions/runs read the actions-endpoint ratchet admits (GOTCHAS 34),
  bounded by the status=waiting filter, page=1, and api()'s --max-time. A queued
  run of THIS workflow FILE suppresses the dispatch, keyed on .workflow_id==$wf
  (a run queues as a whole; an unpicked per-host leg says the pool is full) — the
  deliberate opposite of the name-keyed guard; the two compose. A failed read
  skips the dispatch (fail closed).

Tests (red-first, same commit; +4 -> 22 scenarios): a queued run suppresses even
with an idle tasks view; a different workflow's queued run does not; .workflow_id
keying for the non-swarm resume-asks case; a failed read fails closed. Full
offline suite green except two pre-existing unrelated reds on a clean tree
(tests/list-ready-tasks-test.sh, tests/run-swarm-ready-list-test.sh — ready-list
area, not this slice); actions-endpoint ratchet stays green.

Docs: GOTCHAS 78 (body + index row), docs/journal/2026-10-20-289.md, STATUS.md
self-consumer row (owed a re-vendor + host tick-script pull). Out of scope /
owed: a liveness restart for a runner that stops fetching (the ignition — a
separate follow-up); the coa-builds wait (a downstream symptom); consumers +
host checkouts get the fix only at the next FACTORY_REF bump + re-vendor
(pull-only, GOTCHAS 4) — a human pin-bump step after this lands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Factory-Account: d631bd58e1e9
Author
Member
close-report gates passed for #289 — every claim verified; this PR is cleared for merge.
<!-- close-report: gates-passed --> close-report gates passed for #289 — every claim verified; this PR is cleared for merge.
Owner

Closed unmerged 2026-10-21: the same fix landed on main as PR #290 (a2dc353); #289 is closed.

Closed unmerged 2026-10-21: the same fix landed on main as PR #290 (`a2dc353`); #289 is closed.
ben closed this pull request 2026-10-21 14:18:13 +00:00
All checks were successful
ci / static (pull_request) Successful in 2m32s
ci / test (pull_request) Successful in 5m20s

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!291
No description provided.