claim-next-task: the 30s prompt-expansion budget is arithmetically unholdable — deadline + per-candidate call sizing (healer patch, dev-factory vendored path) #1195
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#1195
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)LANDED end to end — closing.
dev-factory@49dc562— the healer's patch verbatim, ticket refs normalized to this issue; its 42-check suite green (6 discriminating checks fail against the pre-fix script).b668fbb7(onboard.sh vendor→ FACTORY_REF49dc562...), suite green in-place, drift gate OK.11264ede, vendored by another hand minutes earlier) — so the claim fix AND the one-fault-one-ticket reporter fix reach the fleet together; tonight's #1179/#1193 dup class ends on the next runs.Full credit to the swarm healer: complete diagnosis, measured evidence (5 live latency samples), a provably-bounded rewrite, and a correct charter refusal — only its delivery was stranded (API 529). The session was the courier, not the author.