docs/spec/implementation/requirements/the-script-10.md
Requirements
Section titled “Requirements”The Script — requirements, continued (part 10 of 13; 9–17d: Failure handling and execution control…)
Section titled “The Script — requirements, continued (part 10 of 13; 9–17d: Failure handling and execution control…)”-
Failure handling. If any stage times out, exits non-zero, or returns an unparseable summary: kill that stage’s process group, log
attempt-failedwith enough detail for a future cycle to know the item is blocked and what would unblock it, and — if a draft PR was already opened — comment on it that the agent has abandoned it and why, leaving the PR and branch for the human to keep or discard.Naming that pull request is the Script’s job, not the failed stage’s, and it tries four things in order, each less dependent on the stage than the last: the
pr_urlof a parseable final message; a pull-request URL grepped from the stage’s output; the.git/agent-ops-pr-urlbreadcrumb in the clone (requirement 23); and finally an open pull request whose head is the branch this cycle claimed (requirement 17a), asked of GitHub directly. The last of those is the one that must exist, because the first three are all things the Implementer had to remember to do, and a stage that emitted no parseable final message is exactly a stage that may have remembered none of them — whereas the branch was computed and pushed by the Script before the stage began. Each lookup coming up empty is an ordinary outcome, not an error: undererrexita non-zero from any of them kills the cycle before it logs the very failure this requirement is about (see Gotchas).The consequences of failing to name it are not confined to this requirement, which is why the fourth lookup is required rather than merely sensible: no stage-failure comment reaches the pull request (above), no
pr_urltravels on theattempt-failedevent (requirement 32a), and so the Enabler’s one power to clear this kind of block by act rather than by verdict —complete_handoff, gated on that field (requirement 32b) — is unavailable for precisely the failure it exists to recover. 9a. A reported verdict is not a failure. A stage that runs to completion and ends with{"status": "blocked", …}or{"status": "void", …}(requirement 27) has not failed: it has spent a full model run establishing something worth keeping. Record it against the selected item, carrying the stage’s own words verbatim, rather than routing it through requirement 9’s path (which would file it as “exited 0”, discarding what it found) or, worse, dropping it. This is what stops the pipeline buying the same discovery every cycle for as long as the item exists. 9b.blockedandvoidare different states and must not share one. This is the requirement most likely to be read as pedantry and collapsed into “an item that can’t proceed”. Do not.blocked— the work is real, something is in the way for now (an unmerged dependency, a red check, a decision nobody has taken). Recordattempt-failedwith the stage’sreasonandunblock_condition. The Co-Ordinator is expected to re-check these and clear them (unblocked) when the impediment lifts.void— there is no work: the premise is false, almost always because the item is already done ondefault_branch. Pass the stage’sreasonandevidencethrough requirement 34d’s shared corroboration guard first; recorditem-voidonly if it passes,attempt-failed(outcomevoid-refused) if it does not. No agent may ever clear a recorded void; only a human, by appendingunvoidedto the log by hand. The failure mode if you merge them is specific, silent, and was found in production rather than in review. An already-done recommendation is filed asblocked. The next Co-Ordinator, obeying its standing instruction to clear blockers that have gone away, checks the item, finds the work is done, correctly concludes that nothing is in its way, and logsunblocked. The item returns to the pool, is selected, is rediscovered as already done, and is filed again — indefinitely. Every component behaves exactly as specified. The bug is that one channel carried two meanings, so the evidence that should have shut the item forever (the work is done) was the very evidence that reopened it. If a state can be cleared by the same fact that ought to make it permanent, it is the wrong state. 9c. A signal is a failure with a record. The Script trapsTERM,INTandHUPfrom the moment its cleanup trap is armed. The kills that reach it are real and routine — a peer taking over a stale lock TERMs the whole process group (requirement 1), an operator stops a container, a--oncerun is interrupted at the terminal — and before this requirement any of them ended bash between one statement and the next: noattempt-failed, no claim release, nocycle-end, and the in-flight stage’s own process group (detached from the Script’s by design, so the timeout can kill it whole) left running a model for a cycle that was already dead. The handler, in an order that is itself the requirement:
- kills the in-flight stage’s process group, if any, with KILL — the signaller’s patience is unknown and may be two seconds, and a stage whose cycle is dead has nothing left to negotiate;
- logs
attempt-failedagainst the selected repo+item where one exists (so requirement 34’s blocked extract sees the death), with detail<stage> terminated by SIG<name>naming the stage that was in flight — orcyclewhen none was — and carryingpr_urlwhen the requirement-23 breadcrumb identifies one (read before the clone is deleted, since the breadcrumb dies with it); - releases the claim (
have-prwhen a PR is known,no-protherwise), time-bounded to 8 seconds — releasing now beats waiting out the gc’sclaim_ttl_hours, but not at the price of the exit record — and - exits
128+nthrough the ordinaryexit, so the EXIT trap still writescycle-endwith a truthful code, releases the lock and pushes state, andmaybe_run_enabler’s cycle_rc guard skips the Enabler without being asked. A stage that had already ended cleanly is never blamed: the stage pid/name pair is advertised only while a stage is in flight. A signal landing during cleanup itself must not re-enter the handler.review-cycle.shcarries the same discipline as R7a of its own spec. 9d. Visible attribution. Every pull-request or issue comment this system posts — fromagent-cycle.shdirectly, and from the Implementer, Reviewer, Enabler and Refiner — opens with a leading bold line naming the Actor that wrote it and the node it ran on:
**<Display>** · autonomous pipeline · node `<node>`then a blank line, then the comment’s own prose. The Actor is whichever stage wrote the comment, not the one it is about — the Script’s own stage-failure note carries
**Script**, with the stage that failed named in the prose (The Implementer stopped on this PR: …), spelled from the same token→display map below, and no other preamble. This exists because requirement 3e’s own text already states the reason no other signal can: every pipeline write lands underwarwickallen, the same GitHub account a human also comments as, so the author field cannot tell a human’s comment from the pipeline’s, including which comments are a human’s own.lib/pipeline-marker.sh’spipeline_comment_header ACTOR NODEprints the line;pipeline_actor_label TOKENis the token→display map, matching this document’s,docs/spec/review/README.md’s anddocs/spec/monitor.md’s Actors sections and the vocabularydashboard/index.html’sACTORmap already uses, and it fails open on an unknown token — prints it raw — so an Actor added later degrades gracefully rather than vanishing from a comment.agent-cycle.shandreview-cycle.shcall it directly; a model cannot source shell, soprompts/implementer.md,prompts/reviewer.md,prompts/enabler.mdandprompts/refiner.mdeach spell the header’s literal form out and instruct their stage to open every comment with it, using the node name each receives at invocation verbatim (## Nodefor the Implementer and Reviewer; the runtime input’snodefor the Enabler and the Refiner, each of which already received it). Regression-tested bytest/comment-identity.test.sh. 9e. Salvage before discard. Before requirement 9’s failure path fires on an unparseable final message — the Co-Ordinator, Implementer and Reviewer stages here, and requirement 37’s Enabler engagement — the Script makes one bounded resume attempt, provided the failed run actually left a session behind to resume:run_model_stageagain,--resumed onto thesession_idthe failed run’s own envelope carried, prompted with nothing but “return the verdict JSON object, nothing else.” A run that timed out or exited non-zero has no living session behind it and is never salvaged — only a process that exited 0 and still leftextract_json_resultnothing to parse gets the attempt (stage_salvage_result,lib/stage-attempt.sh). The resume is capped at a fixed, conservativestage_salvage_backstop_sec/stage_salvage_inactivity_sec(5 minutes / 90 seconds) rather than requirement 4f’s adaptive per-(actor, repository, model) budget — a continuation with no tool calls needs none of that estimation, and a bound that could grow to a whole stage’s own backstop is not a bound worth having. The resume also forcesrun_model_stage’s own LANE (requirement 4d, issue #2436) onto the original run’s own lane rather than letting the retry draw again under the"<stage>-salvage"name — it is the same launch continuing, not a new one, so it is billed and recorded on the one lane throughout — which means the resume inherits forcing’s own failure mode: a node whose credential for that lane has gone away between the original run and the resume fails the salvage outright as “no open lane” (requirement 4d), where the undifferentiated draw this replaced could instead have landed on the node’s other open lane.When the resume’s own final message parses, its object is used exactly as if the original run had produced it — no failure is recorded here, no
attempt-failed, no discard — and asalvageevent withoutcome: "recovered"is logged (requirement 33). When it does not (including when there was no session to resume at all), requirement 9’s ordinary failure path runs unchanged,salvageevents recordoutcome: "attempted"andoutcome: "failed"for the attempt, and the resume’s own use ofrun_model_stagenever leaks into the original run’s kill-reason, gap or rate-limit bookkeeping —stage_salvage_resultsaves and restores them around its own call, becausedetect_and_log_limit_hitstill reads them against the original.outfile afterwards and must see what that run actually reported, not what the resume did.The fenced-block parse this backs up is itself widened alongside it: a verdict fenced without a
jsoninfo string, or with a different one, parses on the straight fallback and never needs a salvage at all — only the fence’s presence, not its tag, was ever what told a verdict apart from prose (issue #237).This exists because a model slipping the final-message contract is not evidence the work itself was wrong. On 2026-08-07, poetic-2’s completed conflict resolution of PR #205 was correct, fenced without a
jsontag, and discarded anyway — erasing the pipeline’s memory that the conflict was fixed and triggering a three-node duplicate-work cascade on the same PR. A background task left running past the final message (“I’ll check back shortly”) is the same shape from the runner’s side: real work, wrapped wrong. A discard should cost a retry only when a stage genuinely produced nothing usable, not when the parser of the day could not yet see what it produced. 9f.needs-refinementis the Implementer’s own escape hatch, and a third state alongsideblockedandvoid(extending requirement 9b). A stage that ran to completion and reported{"status": "needs-refinement", …}(requirement 27) found real work whose specification — not the world around it — is what stopped it: no acceptance criterion it could find, a scope too vague for two implementations of it to agree. Recorded throughrecord_needs_refinement_block(lib/candidate-select.sh), the same recorder a Co-Ordinator’s ownneeds_refinementreport uses (requirement 34e) and, independently, the Refiner’s own decline (requirement 39d) — one definition (requirement 34a), three reporters, attributed bystage("coordinator","implementer"or"refiner") so a reader can tell which one found the gap.Distinct from
blockedon purpose, on the same reasoning requirement 9b already givesblockedagainstvoid:blockedsays something in the world is in the way and resolves when that changes;needs-refinementsays the brief itself is short of what “done” would mean, and resolves only once someone — a human, or the Refiner working the item again — adds to it. Collapsing the two would age an honest “the spec doesn’t say enough” on the same clock as “the build is red”, when the two need entirely different attention and, per the reasoning below, different consequences for arefinedmark the item might be carrying.If the item carried a
refinedmark (requirement 39c (The Refiner)) when the Implementer selected it, that mark no longer describes the item accurately — the specification it named was tried and found wanting — so recording the block also removesrefined_labelfrom the issue, if the item has one and carries it, mirroringrelease_refinement_label’s removal ofneeds_refinement_labelwhen a block clears, but here on block creation rather than clearance, and for the positive label rather than the negative one. Requirement 3h’srefinements_mapindependently stops naming the item from the moment a fresherneeds-refinementblock exists for it (comparingtstoblocked_ts), which is what stops a Co-Ordinator pasting a specification the Implementer has already found wanting into a future work order, whether or not the label removal itself succeeded. 9g. A stage killed abruptly states, in its own comment, whether it pushed. Requirement 9’s stage-failure comment, for every detail branch where the stage actually launched and so could have posted something before it stopped — the inactivity watchdog (rc124,stage_kill_reasoninactivity), the rate-limit stop, a plain wall-clock timeout (rc124 with no kill reason), and a generic non-zero exit such as a SIGKILL/OOM death — names the pull request’s head SHA at the start of the round and at kill time, so a reader does not have to re-verify the stage’s own comments against the head blob by hand to tell announced-but-unpushed work from work that landed. The two SHAs equal is the signal that matters most: it says plainly that the round pushed nothing, so every comment that round posted describes intent, not landed work. The two SHAs differing still names both, inviting the reader to diff the round’s actual contribution against what its comments claimed, since some of it may have landed. Only the two branches where no stage ever ran — an API refusal before launch, and the “not launched” cases — carry no such sentence, since there is no stage activity to reconcile against a head SHA.The round-start SHA is read by whichever of
lib/coordinator-phase.sh’s two call sites ofhandle_stage_failurecan name a pull request before its stage launches — the Implementer’s, for the five finishing sources whose work order already carries apr_url(preflight_existing_branch_source), and the Reviewer’s, whose subject is always the pull request the Implementer has just raised or confirmed — onegh pr view --json headRefOidcall immediately ahead of that stage’s ownrun_model_stage, held instage_pr_head_sha_at_startand read insidehandle_stage_failureas a global rather than threaded through as an argument, the same patternstage_kill_reasonitself already uses. An ordinary fresh claim has no pull request yet at round start — the Implementer raises it during the round — so that case leaves the variable empty and carries no such sentence. The kill-time SHA is read the same way, insidehandle_stage_failureitself, once the stage has stopped. Either read missing or failing (no pull request yet, a closed pull request, a transient API fault) drops the sentence rather than the comment: the ordinary wedged-stage notice (requirement 9) still posts regardless.This exists because a stage that comments before it pushes can leave a pull request thread asserting fixes it never pushed, with nothing to reconcile the claim against the head SHA — observed live on PR #2218 (agent-ops#2236), where a Reviewer’s inactivity kill followed two long comments claiming fixes “in this round” that were absent from the diff, and the Script’s own follow-up note (“produced no output at all … and was stopped as wedged”) read as “the stage said nothing” rather than “the stage said a great deal and then failed to act on it”. The same gap is not specific to the inactivity kill: PR #2437 (agent-ops#2510) showed it again through a SIGKILL, where a Reviewer named two findings it was “fixing on the branch”, was killed at exit 137, and the stage-failure comment that followed named only the exit code — leaving the thread’s most recent substantive comment describing work that did not exist. Any stage that can comment on a pull request before it pushes, stopped abruptly by any means, can produce the same gap.
-
Usage-limit detection. Two sources, and the structured one is preferred wherever it exists. When a stage was stopped because its stream reported the account
rejected(requirement 4e), thelimit-hitis derived from thatrate_limit_infobylimit_decide_structured: it statesresetsAtas an epoch, so the stand-down is a fact rather than an estimate, and it is the only source available on that path at all, since a stage stopped at the refusal writes no final message for a phrase matcher to read. Otherwise — and whenever any stage’s transcript matches the phrase tablelimit_phrase_regex_forselects for its own provider (stage_provider, issue #2135) inlib/limit-detect.sh—LIMIT_PHRASE_REGEX(the generichit your .* limitstem plus the legacyusage limit/rate limit/usage cap/quota exceededterms) foranthropicand any provider with no table of its own, orXAI_LIMIT_PHRASE_REGEX’s own disjoint weekly/spend-cap wording for xAI’s Grok Build substrate (issue #2134), so its transient 429 text is never mistaken for a stand-down — sourced by the Script,review-cycle.sh,monitor-cycle.shandscripts/publish-dashboard.shso none can drift apart — it is parsed out of the prose. Either way the event is alimit-hitcarrying the same three fields, because no reader downstream should have to know which source produced it:resume_at,class, andreset_known:resume_atis parsed from an ISO-8601 timestamp in the message if present, else from a human-readable weekly reset clause (e.g. “resets Jul 17, 4am (Pacific/Auckland)” — the named zone is applied viaTZ, not left in the string fordate -d, and never combined withdate -uin the same call, which would silently override the named zone), else a fallback: now +limit_cooldown_defaultfor an ordinary/transient match, or now + a much longer cooldown (LIMIT_LONG_COOLDOWN_HOURS, ~1 day) when the phrasing says “weekly” or “monthly” and no reset time could be parsed at all — that fallback is too short for something that recurs on a multi-day cadence.classisweekly,monthly, orother.reset_knownis true only when a reset time was actually stated in the message. False meansresume_atis the fallback above — this system’s own retry interval, carrying no information about the real reset — and everything reported to a human must say so rather than presenting it as a deadline.
reset_knownreplaced aneeds_humanflag that claimed the spend-cap case “clears only when a human raises the cap”. Every limit has two exits: the plan’s rollover, which needs no one, and a cap increase, which needs a human and only if sooner is wanted. Calling the first exit nonexistent turned an unknown reset time into an apparent dead end. Readers accept the superseded field during a rollout, inverting its sense (lib/limit-detect.sh’slimit_reset_known), so a peer on the previous release is not misread as authoritative.There is no supported API for querying a subscription plan’s remaining quota, so this fail-safe detection is the quota check, and back-pressure (2.2) is the primary spend control.
resume_atis an upper bound to stand down until, never a promise the block lasts that long — but nothing inside a cycle can shorten it, because 2.1 stands the cycle down before any stage runs. Lifting it early is--clear-limit’s job and only--clear-limit’s. -
Cleanup. Always: delete the cycle’s workspace, engage the Enabler if this cycle should (requirement 35), log the schedule slots this cycle’s own run overlapped, if any (requirement 11a), write a
cycle-endevent, release the lock. Tee each stage’s stdout/stderr tostate_dir/cycles/<cycle-id>/for debugging. 11a. Overrun-slot skips (agent-ops#1287). supercronic will not start a job while the previous run of that job is still running: it logs the drop (“not starting: job is still running since … (…elapsed)”) to the container log and nothing else records it, so a cycle that runs long loses its fleet a whole slot — or, on a fifteen-minute node, several — with no event of any kind inlog.jsonl, readingRUNNINGin--statusand the dashboard the whole time while delivering nothing.Only the cycle holding the lock can ever know this happened: the process supercronic would have started for one of these firings never starts at all, so nothing else ever gets the chance to log it. At cleanup (requirement 11), before the lock releases and only for a cycle that actually acquired the lock and is the cron-fired original — its chain depth is 1 (requirement 67) and none of
--once,--dry-runor--wake-pollwas given — the Script computes which of its own schedule’s slots fell strictly inside its own run — from its own start (cycle_started_at) and its own end, its own already-defaultedscheduleblock (cycle_hours,cycle_interval_minutes,excluded_minutes— the same blockdeploy/docker/render-crontab.shrenders into the crontab, requirement 1d), and the node’s own true base minute (below) — and writes onecycle-skipped {reason: "overlap", slot_ts, held_by: <cycle id>, elapsed_s}event per slot, oldest first.slot_tsis the dropped firing’s own instant;elapsed_sis how long this cycle had already been running at that instant — the same quantity supercronic’s own log line reports, computed independently here since this process never reads that log.The node’s own base minute is read straight out of the rendered crontab (
schedule_crontab_base_minute,lib/schedule-slots.sh): the agent-cycle.sh line’s own minute field is an ascending, comma-separated list —cycle_minute, cycle_minute+cycle_interval_minutes, …— so its lowest entry iscycle_minuteitself, the node’s real base regardless of which of that list’s minutes this particular cycle happened to fire on. It is never re-derived by re-hashingNODE_NAMEthe way that script’s ownhash_minute()does, since re-hashing could drift from whatever the rendered schedule actually contains; reading the file it wrote cannot. That file is the one supercronic itself runs (compose.yaml’sschedulernames it), so the read is exact whether or not the render succeeded: the baked crontab a failed render leaves standing is a valid, working schedule carrying its own real minute list, and it is that schedule supercronic then fires on. Reading it can still fail — the file absent, or itsagent-cycle.shline’s minute field not a plain comma-separated integer list (a crontab shaped by a template this parser does not recognise) — in which caseschedule_overrun_slotsfalls back tocycle_started_at’s own minute-of-hour, correct only when this cycle happens to have fired on the lowest minute its own crontab line keeps (agent-ops#1324).Holding the lock alone would not make either base minute trustworthy: only the cron-fired original is supercronic’s running job. A chained continuation (requirement 67) is spawned detached and disowned and its cron-fired parent then exits, ending supercronic’s job, so the slots inside a chained cycle’s run are not dropped at all — they fire, contend for the lock, and are already recorded by the contending tick as requirement 1’s own
reason-lesscycle-skipped. Logging them here as well would double-count them, and — whenever the crontab read above failed — at a fabricatedslot_tsbesides, since a chained cycle starts whenever its predecessor happened to finish, an arbitrary minute-of-hour the fallback derivation would then take as the node’s base.--onceand--dry-runruns have the same shape: supercronic’s job is untouched by them, so their firings land and contend as normal. So does a wake-poll-triggered run (requirement 54):scripts/wake-poll.shinvokes this script with--wake-poll, on whatever instant the poll detected a change at rather than the cron-fired job’s own clock, so it is excluded here the same way. Nothing is lost by the narrowing, because every slot it declines to name is one the contending tick recorded. A human running the script with none of the three flags is the one case left ungated, a known bound rather than an oversight: distinguishing it from the cron firing needs machinery this does not carry.What it names is the slot series running forward from the node’s own base minute, repeating at
cycle_interval_minuteswithin each allowed hour. Read from the crontab, that series is the node’s whole set, exact rather than a bound. Fallen back to the cycle’s own firing minute instead, it is the node’s whole series only when that firing minute was the lowest kept minute of its hour; a cycle that fired on a later one contributes no slot at any earlier minute-of-hour of any subsequent hour, because one firing minute does not identify which of the hour’s kept minutes is the base (:55at a fifteen-minute interval is equally consistent with a base of 10, 25, 40 or 55). That fallback error is one-sided: every event written still names a firing that really was dropped, and the count is a lower bound on the firings lost, never an overstatement (agent-ops#1324) (lib/schedule-slots.sh’sschedule_overrun_slotsandschedule_crontab_base_minute,test/schedule-slots.test.sh).These are ordinary
cycle-skippedevents, sharing their name with requirement 1’s own lock-contention case, but unlike that case they never callsuppress_node_state_transitions(docs/reference/flow-schema.md): the seconds they describe already belong to this cycle’s own node-state timeline, finalized immediately before them at cleanup, not seconds of their own to account for separately.Two readers surface the count without this repository changing either:
scripts/publish-dashboard.sh’snoop_ticksgains anoverlapfield — a flat count of the window’s ownreason: "overlap"events, never folded intototal, since (unlike the stand-down/lock-held pairnoop_ticksalready counted) the cycle that logs one kept its own row incycles[]by running real stages, and this is additional information about that row rather than a tick held out of the list (docs/spec/dashboard/README.md).--statusgains anoverrun: N firing(s) overrun in the last 24hline, this node’s own count (overlap_status_report,lib/manage.sh) —check-nodes.sh(external to this repository; not committed here) already prints--statusper node and so inherits it for free, on the same terms requirement 2.8’sstages:section already does. The count reads the log through the tolerant event stream requirement 2.1’s reduction reads (union_events) and skips a line that does not parse; a log not yet written counts zero, and a read that fails outright printsoverrun: unreadable — this node's log could not be readand reports aguard-degradedwarning on stderr rather than a zero nobody counted. -
Flags.
--dry-run(run through step 5 then stop: prints the work order, launches no Implementer),--once(one verbose cycle in the foreground),--repo <slug>(restrict selection, for testing),-h/--help(print the usage text and exit), plus the switch’s--disable [<reason>] [--for <duration>] [--until <timestamp>],--enableand--status(requirement 2.3), which manage the switch and run no cycle.The usage text describes every flag the Script accepts,
--helpincluded: a flag the parser honours but the usage omits is one an operator can only find by reading the source.--clear-limit [<provider>] [<reason>]lifts a usage-limit stand-down (2.1) and runs no cycle either. With no provider, every provider’s own stand-down lifts, as before issue #2135; naming one (matched againstPROVIDER_SUBSTRATE’s configured keys, plus the always-validanthropic) lifts only that provider’s, leaving a different provider’s own freeze untouched. Which of up to two bare tokens is the provider and which the reason is resolved against that same set, afterproviders_load: one token is the provider only if it names one and the reason otherwise, exactly as before the issue; two tokens are provider then reason, and a first token naming no configured provider is rejected (exit 64) rather than scoped to a provider that does not exist — there is no second reading of two bare tokens, and a silent mis-scope would log alimit-clearednothing reads. It is deliberately not--enable: the switch and the stand-down are separate states with separate causes, and one command for both would let an operator clearing a spend cap silently re-enable a pipeline another agent had disabled to edit these files. It clears both carriers for the named scope, reports what it lifted and what it could not, and warns loudly on a failed flag delete — a flag left set keeps every node down after the operator believes they have resumed; naming a provider deletes the flag only when the flag’s own current record already names that provider, leaving a different or wildcard record untouched. A scoped clear then re-reads both carriers for that provider rather than inferring success from what it wrote, and warns that the stand-down is not lifted when one still holds it down, naming the bare--clear-limitthat can clear it. That is not a defensive extra: a wildcard record — carrying noprovider, as every record before issue #2133 does — governs every provider by requirement 2.1’s “a record without one applies to every provider” rule, and neither carrier can express “every provider but this one”, so a scoped clear genuinely cannot lift one. The union’slimit-clearedresets only the named provider’s own bucket and leaves the wildcard bucket standing; the flag is left in place by the rule just above. Reporting that as lifted is the failure this command exists to end. The reason is optional, unlike--disable’s: a stand-down being lifted is self-explanatory in a way one being imposed is not.--kill-merge-autonomy [<reason>]and--restore-merge-autonomy(requirement 2.3b) manage the D18 kill switch and run no cycle either. Like--clear-limitthis is deliberately not--disable/--enable: killing merge autonomy stops nothing else — cycles keep running normally, only approval and landing are forced back tohuman— so folding it into the switch would make an operator editing these files also, incidentally, force every repo’s landing decisions onto a human, or vice versa. The reason is required on--kill-merge-autonomy, the same terms as--disable’s: the next person to wonder why every repo is stuck athumanis entitled to one. Neither takes--this-node: the kill switch has no node-scoped form, since a node-scoped merge-autonomy override would contradict the fleet-wide identity a single Approver App holds. -
The Script must pass
shellcheckand must set its ownPATHexplicitly (cron’s environment is minimal), coveringclaude,gh,git,jq. When provisioning a host, prove that a cron-style invocation can resolveclaudeby running it from a minimal environment (for example with a sanitizedPATHandHOME) before relying on scheduled runs. -
Finish-then-continue (issue #248): a cycle that wins a claim and launches the Implementer may, once it has fully ended, launch another cycle immediately rather than leave the next one to the next cron firing —
lib/chain.sh. Two conditions, both cheap, both judged from what the cycle already gathered ahead of the Co-Ordinator (ordered_repos_json, ready before requirement 3b’s fingerprint is even taken):- Sources remain. At least one configured repository’s
.sources— already narrowed by back-pressure (2.2a) if it was tripped — is non-empty. This counts enabled source categories, not items, and is near-unconditional in practice: back-pressure narrows.sourcesto the four finish-work sources rather than to empty, so a repo configuring any ofreview-feedback/merge-conflicts/dequeued/abandoned-draftskeeps the count non-zero however back-pressured the fleet is. It is not a prediction that work remains — the chained cycle’s own Co-Ordinator and gather decide that, and at full price, since the cycle just finished changed the no-op fingerprint (3b) with its own PR. In effect the cap below is the only gate that fires after a productive cycle, and its cost is a deliberate trade — see the finish-then-continue design decision. - The lineage has room. This cycle’s own place in an unbroken chain
of immediate continuations, 1 for the cron-fired original, is still
under
max_chained_cycles(default 3). A chained cycle inherits its place plus one viaAGENT_CYCLE_CHAIN_COUNT;max_chained_cycles: 1disables chaining outright.
Never chains on
--once(a human or a test asked for exactly one cycle) or past any stand-down before the claim section, the switch, or a cycle that selected nothing — all of those end before a claim is ever attempted, sochain_eligibleis never true for them. One stand-down inside the claim section does chain, under the same two conditions above: theracedstand-down (17a), where every attempted claim was lost to a peer. That cycle’s Co-Ordinator engagement bought the knowledge that the fleet is busy, not that it is done — and the winners’ claims, invisible when this cycle gathered, are exactly what the chained cycle’s fresh gather and requirement 3q’s filters see, so the continuation is routed to the next-best item instead of the same fight. The other three causes never chain: anunreachableorpre-claimedstand-down against a fresh cycle buys a second engagement into the same outage, or the same selection defect, and the same empty-handed ending; anuntraceablestand-down (17f, 17h) is the Script’s own construction-time check refusing to hand a candidate on, which no peer’s claim or absence had any part in, so a fresh cycle would spend the same chain budget re-composing the same broken work order rather than routing around anyone. Nor does it chain over an untrapped crash or a signal: the gate ischain_eligibleand this cycle’s ownexit_code == 0, checked incleanup(11) after everything else there has already run — the lock released, the Enabler engaged,cycle-endlogged, state pushed. Every ordinary ending after a won claim (complete, blocked, void, a handled stage failure) exits 0 like a stand-down does, and does still chain: a failed or blocked item must not stall the fleet from picking up a different one sooner. The chained cycle is a genuinely new process — its own cycle id, its own lock acquisition, its own full cleanup — launched with the original argv (ORIGINAL_ARGV, captured before flag parsing consumes it), detached (backgrounded,disowned, stdin from/dev/null, stdout/stderr appended to the samecron.loga cron firing already writes to) so the parent never waits on it and its life does not depend on the parent’s — and launched with the default dispositions forTERM,INTandHUPrestored, becausecleanupignores all three before it spawns (9c) and an ignored signal is inherited across both fork and exec into a shell that can never take it back. Without that reset a chained cycle would run deaf to every signal 9c’s handler exists to catch, and requirement 1’s stale-lock takeover would reach it only through theKILLthat follows its ignoredTERM— noattempt-failed, nocycle-end, no claim released. - Sources remain. At least one configured repository’s
-
A pending image roll overrides the chain, and widens the gap at every clean cycle-end, not only a chaining one (agent-ops#1096, widened by agent-ops#1103). This covers two separable jobs, not one: cancelling a chain this cycle would otherwise take, and widening the gap a poll needs from whatever instant this cycle’s own lock release happens to leave to one the five-minute poll is guaranteed to land in. A node running long or chained cycles never leaves
deploy/docker/watchtower-pre-update.shsuch a gap — every individual deferral stays correctly bounded by that pipeline’slock_stale_after, and the node still never rolls, because the next chained cycle’s own claim reacquires the lock before the lock-free instant a poll would need — but the identical starvation reaches a node that is merely busy and never chains at all: chaining disabled (max_chained_cycles: 1), a chain that has exhaustedmax_chained_cycles, or any other clean cycle-end, since none of those leave more than the natural, possibly sub-second gap between this cycle’s lock release and the next cron firing either. So immediately before the chain decision, inside the samecleanup(11), every cycle that ended cleanly (exit_code == 0) and was neither a--oncenor a--dry-runrun (a human or a test asking for exactly one cycle, real or dry, must not arm an override on the node it ran on) asks: is the image it is running behind the registry’s newest (lib/image-drift.sh’simage_drift_status, read back through the identical cache the requirement-2.5 heartbeat push just above it already refreshed — no second registry round trip, no second signal)? If so,chain_write_roll_pendingwrites$state_dir/roll-pending.json({"until": <ISO8601>},schedule.cycle_interval_minutesfrom now, requirement 2.5’s own exclusion list) regardless ofchain_eligible— and, separately,chain_image_behind(lib/chain.sh) flipschain_eligibleback to false wherever it was true — overriding, never granting, and a no-op on a cycle that was never going to chain anyway.deploy/docker/watchtower-pre-update.shreads that marker back and honours it as an unconditional allow againstlock.jsonalone — overriding only that pipeline’s own ordinary in-flight-cycle deferral, neverreview-lock.json’s (agent-ops#1102:review-cycle.shnever wrote the marker and never decided to yield anything, so a project review beginning just after a yielding implementation cycle must keep deferring on its own ordinary judgement regardless) — untiluntil: wide enough that the next poll is guaranteed to land inside it, which the true gap a declined chain (or a cycle with no chain to decline) leaves (the instant between this cycle’s lock release and the next cron-fired cycle’s own claim) is not.Because
untilis a fixed clock offset from this cycle’s own end, not “the next cycle’s own start”, a cycle that reacquireslock.jsonbeforeuntilpasses would otherwise run its own stages underneath a marker that still authorises overriding that very lock (agent-ops#1102). So the other half of this mechanism runs at the top of every cycle, immediately afteracquire_lock: if$state_dir/roll-pending.jsonexists, the sameimage_drift_statusround trip (the identical TTL-backed cache, so this is a network call only when that cache was already due to refresh) is read again, andchain_clear_landed_roll_pending(lib/chain.sh) removes the marker unless the verdict still reads “behind”. Re-acquiring the lock is itself the proof the gap the marker described has ended; once the verdict is no longer “behind” the marker has either already done its job (the roll landed in the gap) or was never earned by this node’s own current image, and leaving it live either way would let a marker written for one roll authorise watchtower to destroy this cycle’s own container for whatever publishes next. A verdict still reading “behind” leaves the marker untouched, and the cycle that just reacquiredlock.jsonasks one further question before running its own stages under it (agent-ops#1102’s own option 2): is watchtower actually invoking the pre-update hook and being turned away right now?chain_updater_should_standdown(lib/chain.sh) answers this offlib/updater-health.sh’s ownupdater_statusverdict, read against the sameupdater-ledgerdirectory the state-sync heartbeat already reads (no second signal) — “deferring”, or “stuck” withreason:"defer", both say watchtower is there and being refused; “rolled”, a bare “stuck”/reason:"allow"(the roll is failing for reasons of its own, #1099’sConflictobservation), andnull(no live ledger evidence at all) all say idling fixes nothing, so the cycle runs normally. When it does say so, the cycle idles instead of running: it logs astand-downnamingcause: "roll-pending"and the marker’s ownuntil, settles intoexternally-blocked/roll-pending(set_node_state_terminal,docs/reference/flow-schema.md’s closed cause vocabulary), and exits 0 without ever reaching the Co-Ordinator —chain_ eligibleplays no part, since it is never raised this early in the cycle. This is capped at one stand-down per pending marker (chain_roll_ standdown_available/chain_roll_standdown_record,$state_dir/roll- standdown.json): even a verdict that stays wrong every cycle cannot idle a node indefinitely, so a second cycle under the same still-live, still-“behind” marker logs aroll-standdown-cappedevent naming the marker and the spent count instead, and runs normally. The counter is cleared alongside the marker itself, by the samechain_clear_landed_ roll_pendingcall above, once the verdict stops reading “behind” — so a later, genuinely new pending roll earns its own fresh stand-down allowance.The result is the bound the hook’s own header now states: one cycle’s length for a node that is merely busy, and
lock_stale_afteronly for one that is actually wedged and so never reaches this check at all. 17d. Race-loss observability: how many candidates a cycle lost to a peer genuinely holding the item (17a’scause: "held", as opposed to"unreachable") before it won its own claim, or — on the cycle that exhausts every candidate — before it stood down. Carried asrace_losseson theselectionevent (only when it is greater than zero — 17a) and on that stand-down’s event. Candidates skipped as pre-claimed (17a’sclaim-skipped) are deliberately not race losses and never inflate this count: a loss knowable from the cycle’s own gather is a selection defect wearing contention’s clothes, and folding it in would make the fleet look busier against itself than it is — the miscounting that let a day of one Co-Ordinator re-proposing four already-claimed issues read as healthy racing. A cycle recovering a race (winning after one or more losses) is healthy contention, not a fault:scripts/publish-dashboard.shanddashboard/index.htmlsurface it as an informational “recovered race ×N” badge, on the cycle history, the live-cycle panel and the fleet cards, wherever that cycle’stitle/sourcealready render (never a warning colour). A cycle that lost every candidate recovered nothing and never carries that badge; it is marked instead beside its outcome, where the plain “Stood down” verdict cannot say by itself whether the fleet’s own contention or a GitHub outage produced it — the same informational colour, and DASHBOARD-SPEC’sraced/standdown_causeis the shape both readings come from. Faster cadence and finish-then-continue (39) both raise how often nodes contend for the same item, which is why this became worth watching rather than left to aclaim-lostgrep.