claim-next-task.sh cannot hold the 30s prompt-expansion budget — deadline + per-candidate call sizing (factory-vendored, needs a dev-factory push) #1194
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#1194
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Filed by the swarm healer (hook mode, signature
0fd2fa26ccd7, run https://git.matou.nz/Matou/idss/actions/runs/17201). Class: harness-infra. Not repaired in-repo — the fix lands on a factory-vendored path, so it needs aMatou/dev-factorypush + re-vendor, which is a human call (blast radius = every consumer repo).Fault
sandcastle run (workers) :: PromptExpansionTimeoutError: Shell expressionbash .sandcastle/claim-next-task.shtimed out after 30004ms(run-verdict.txt).The outer 30s is a hard-coded library constant —
@ai-hero/sandcastle/dist/index.js: PROMPT_EXPANSION_TIMEOUT_MS = 3e4. A shell expression gets no per-expression override the way a lifecycle hook getstimeoutMs(.sandcastle/main.mts, #1142). Soclaim-next-task.shmust prove it returns first. Its existing#77/#28bounds don't, in three ways.(a) Overshoot — the actual red
CLAIM_NEXT_BUDGET=22is tested only at the top of each candidate; nothing re-checks the clock once a candidate is admitted. An admitted candidate then makes up to ~4CLAIM_API_MAX_TIME-bounded calls (claim_post→_claim_comments→ loser'sDELETE, or winner'sclaim_label_id+ label write).21 + 10 = 31 > 30, and a full candidate is21 + 30 = 51. The guard is arithmetically incapable of holding the script under 30s.Run 17201's iteration 3 matches exactly: ~10s prefetch, candidate admitted at ~20s, two
claim_postcalls each burning the 10s cap, dead at 30.004s — and no claim comment left on either #1191 or #1192 (verified live), which is what a timed-out/failed POST leaves behind.(b) The per-call cap is set below the endpoint's own latency
CLAIM_API_MAX_TIME=10, butclaim_alive_runsmust readactions/tasks?limit=100&page=1, measured live on this forge 2026-09-03: 8.54 / 10.29 / 10.60 / 12.10 / 12.22 s — 3 of 5 over the cap. So the#28fail-closed arm fires on a healthy-but-slow forge, not just a stall, and the iteration claims nothing.This is visible in run 17201 iterations 1–2: both expanded in 10.2s and injected an empty list, and the agent then wrote "The top-of-prompt ready list was empty, so per the Done procedure I re-ran
list-ready-tasks.sh. It now returns two fresh tasks" — it re-ran the lister (30s cap) and saw work the claim wrapper (10s cap) had just fail-closed on. Two of three iterations spent doing nothing, mis-attributed to "tasks unblocked mid-iteration".(c) The lister leg is unbounded relative to the 30s budget
ready="$(bash "$lister")"is untimed.list-ready-tasks.shretries each read with backoff atLIST_READY_MAX_TIME=30s apiece (#52) — worst case ~96s inside a 30s expansion.For reference, healthy claim-path calls on this forge are ~1.0–1.5s (
issues/N/comments,labels,dependencies), so the budget is dominated entirely by the ~11sactions/tasksprefetch.Fix (written and verified — patch attached below)
Replace the fixed budget with a deadline + per-candidate call sizing, so the worst case is arithmetic rather than hope:
CLAIM_NEXT_DEADLINE=26— self-deadline under the library's 30s, with margin for thedocker execround trip the library clock includes but the script cannot see.cap = (DEADLINE - SECONDS) / CLAIM_CANDIDATE_CALLS(5, leaving a spare for a second labels page), stop at aCLAIM_CALL_FLOOR=2floor. A candidate admitted atStherefore lands by the deadline even if every call burns its full cap._claim_apireads the var at call time, so the shrinking cap applies per candidate.CLAIM_ALIVE_MAX_TIME=14for the prefetch leg — sized over the measured 12.2s tail, so fail-closed is a safety net again instead of a routine outcome.CLAIM_LISTER_MAX_TIME=12— bound the lister from outside viatimeout, leaving #52's retry tuning untouched. Only rc 124 (timeoutkilled it) gets the graceful[]; every other non-zero rc still propagates, preserving #52/GOTCHAS #7 (a real listing outage must fail loud and be re-keyed to the "list ready tasks" stage, not laundered into "nothing to do").CLAIM_NEXT_BUDGETbecomes an optional extra ceiling (unset by default); an explicitCLAIM_API_MAX_TIMEstays absolute and un-clamped (the#77ceyes-open seam).Emitting
[]is the same outcome as losing every race — no claim, no Claude tokens, cron/backstop re-fires — versus REDing the tick.Verification
.sandcastle/tests/claim-next-task-test.sh: 42 pass / 0 fail with the patch (28 pass baseline + 14 new). The 6 discriminating new assertions fail against the pre-fix script and pass after, one guard per defect above:Observed caps on the real argv after the fix:
actions/tasks→--max-time 14; each walk call →--max-time 5(26/5 atSECONDS=0), worst-case candidate5 x 5 = 25 <= 26.Why this was not landed by the healer
claim-next-task.shandtests/claim-next-task-test.share both in.sandcastle/FACTORY_MANIFEST(lines 11 and 72) — vendored byte-for-byte fromMatou/dev-factory@11264ede. Verified:check-harness-drift.shis green on the pristine clone and FAILS with the patch applied. Landing it in idss alone would red the drift gate and be wiped by the next re-vendor.What a human needs to decide: push this to
Matou/dev-factory, then bumpFACTORY_REF+ re-vendor here (the04aa72dfpattern). It changes the claim path for every consumer repo (matou-app, coa, matou-website, dev-factory, idss all share this harness perrunner-journal.txt), which is past what the healer charter allows it to decide.Residual, not fixed here
The real constraint is that
actions/tasks?limit=100costs ~11s of a 30s budget on the critical path (it must be reaped before the walk). The patch makes that survivable, not cheap — the walk is left ~12s, so per-call caps land at 2–5s. Making claiming genuinely comfortable means making alive-runs cheaper (host-side cache, or a narrower endpoint), which is a design question, not a bug fix. Related: GOTCHAS 16.Patch (also at
claim-next-task-budget-fix.patchin the incident evidence dir)Ruled by agent under ADR 0174 — veto anytime.
Ruling: two-way door — landed. This is (a) revertible by a single
FACTORY_REF-bump revert commit, (b) provable by the offlineclaim-next-task-test.shsuite, and (c) not on the one-way-door list: the hostFORGEJO_TOKENalready has write toMatou/dev-factory(no personal credential), this is a timeout/deadline fix (no security-posture widening), and it touches no member-/public-facing trust surface, no data, no spend. The healer flagged "blast radius = every consumer repo" as past its charter — but that is the healer's narrower bar, not a one-way door: consumers pinFACTORY_REFand re-vendor deliberately, so a dev-factory commit does not auto-propagate. ADR 0174 rule 5 names protected.sandcastle/paths as session (not human) work.What made it cheaper than the ticket assumed: the fix was already pushed to
Matou/dev-factorymain as49dc562("claim-next-task: the 30s prompt-expansion budget becomes provable arithmetic — deadline + per-candidate call sizing (idss #1195, run 17201)"). So no upstream push was needed — this reduced to a scoped re-vendor, which also sidesteps theFACTORY_MANIFESTtoken-leak trap (re-vendored anonymously from the clean URL).What landed:
.sandcastle/from11264ede→49dc562viaonboard.sh vendor(2 files updated:claim-next-task.sh,tests/claim-next-task-test.sh;FACTORY_REF+FACTORY_MANIFESTbumped). Deliberately vendored to49dc562exactly, not dev-factory HEAD3a107e6— HEAD carries an unrelated container-sweep (#122) that also touches idss-vendoredsweep-lib.sh/report-lib.sh, out of scope for this ticket.check-harness-drift.shnotes idss is 1 commit behind main (the #122 gap, intentional; not a failure).CLAIM_NEXT_DEADLINE=26+ per-candidatecap = (DEADLINE − SECONDS) / CLAIM_CANDIDATE_CALLS(5)down toCLAIM_CALL_FLOOR=2(a candidate is admitted only when the clock left bounds ALL its calls; worst case5×5=25 ≤ 26);CLAIM_ALIVE_MAX_TIME=14over the measured 12.2sactions/taskstail;CLAIM_LISTER_MAX_TIME=12bounding the lister from outside viatimeout(only rc 124 → graceful[]; every other rc still fails loud per #52/GOTCHAS 7);CLAIM_NEXT_BUDGETdemoted to an optional ceiling; an explicitCLAIM_API_MAX_TIMEkept absolute (#77c).STATUS.mdupdated in the same commit.Proof:
.sandcastle/tests/claim-next-task-test.sh→ 42 pass / 0 fail (28 baseline + 14 new; the 6 discriminating assertions are red-by-defect against the pre-fix script)..sandcastle/check-harness-drift.sh→ OK at49dc562(would have RED with the patch applied in-repo — proof it had to route through dev-factory).5110363bonmain(pushed;git pull --rebaseclean).Residual (filed as context, not fixed here):
actions/tasks?limit=100still costs ~11s of the 30s on the critical path — the patch makes that survivable, not cheap. Making claiming genuinely comfortable (host-side cache / a narrower endpoint) is a design question, not a bug fix. Related: GOTCHAS 16.Closing with this report.