ADR-167 — A shared gateway bounds its alive runs: a gw:<host> subject in the run-admission ledger, admitted before start and held through the runner's redelivery
- Status: Accepted — the operator decided it on 2026-11-13 (run admission completed by a transit guard, over a per-call semaphore and over a place taken at the runner's claim; a subbot child inherits its live ancestor's place; a deferred launch runs the current bot when nothing started; observe first, then a guarded enforce;
max_waitbounds the whole wait; the subject is the host alone in v1) - Date: 2026-11-13
- Deciders: jo (the arbitrations), Claude (three designs, two code maps, the plan, the store slice), codex gpt-6-astra (the adversarial review of the plan, 14 findings)
- Extends: the per-key hard cap's ledger,
store.CredSlotStore(pkg/store/credslot.go,pkg/store/mongo/cred_slots.go, #2643) — nothing of it is reversed; its rows gain a second kind of key. - Relates to: ADR-131 (the team's gateway key, whose host is the subject) · ADR-164 (key pools route spend; they bound no shared host) · ADR-155 (the durable capacity ledger, designed and not built, which left the parking semantics of #2643 to that ticket; this record takes them up for a subject that is not a key)
- Amended by: ADR-176 (Proposed) — a run refused for capacity waits as
waiting_capacityinstead of aGATEWAY_SLOT_WAITpark (§3, T4b/T5), and a launch-side ledger error waits onledger_errorinstead of a refusal (§7); C2's runner-side ledger error is amended only at ADR-176's S5. - Serves: #3254
Context
On 2026-11-13, 13 teams launched 22 Revi reviews within about a minute. Each team held its own PLIAGE key, and every key pointed at one LiteLLM host (claw, deepseek-v4.1-flash): about 12 runs executed at once. The latency of one call went from about 50 s to 4–7 min. Three runs were killed by review-pr's max_duration: "180m", because the budget clock counts wall time inside the run (pkg/runtime/budget.go) and slow calls consume it.
Nothing bounds the runs of one gateway:
- the per-key cap (
max_concurrent_runs) counts by fingerprint, and a gateway key's fingerprint folds in its base URL and its secret (secrets.APIKeyFingerprint), so 13 team keys are 13 rows — a floor of 13 runs, above the ~12 that saturated the host; max_concurrent_runs: 1on every team key still caps at 13.
The goal is at most N alive runs per gateway, all teams together, the runs past N waiting visibly with no pod started and no budget spent. It must hold across server replicas, be configured in the database, have an off lever, and implement an existing seam (philosophy 2).
The per-key cap already ships the seam. store.CredSlotStore keeps one row per key; an admission is one conditional write, so of N concurrent admissions on K free places exactly K win, whatever replica each ran on; an admission adopts the alive runs the row does not name and evicts the holders whose run stopped spending; a refused launch parks CRED_SLOT_WAIT and the retry sweeper asks again for free.
The admission alone does not hold the bound — the review's main finding, verified in the code. The publisher is not the only road to execution:
- a NATS delivery of a
failed_resumablerun is executed as a resume (pkg/queue/admission.go), and the runner calls the engine without going back through any admission; - the runner produces that status on each of its nak paths — interruption or drain, sandbox timeout and sandbox capacity, attachments, orphan adoption — and the server's orphan sweeper does too;
- during those windows the holder predicate counts only
queuedandrunning(RunStatus.HoldsCredentialSlot), so the ledger judges the holder stale, evicts it and gives its place away, and when the redelivery lands the run resumes anyway.
With N = 1, two runs execute. The hole exists today for the per-key cap.
Decision
A gateway is a capacity subject of the run-admission ledger. Its subject is
gw:<host>(store.GatewayCapacitySubject): the lower-cased host the gateway client dials (compatgw.Config.Host), with no scheme, port or path. Thecred_slotsledger, on both store twins, keys a row by a credential's fingerprint or by a capacity subject; the namespaces cannot collide, since a fingerprint is hex oraccount:-prefixed. Holding, adoption and eviction read one predicate for both (Run.SpendsCredential), and the Mongo filter mirrors it (spendsCredentialFilter, a$orover the two stamps).Every run that seals a gateway key is stamped, bound or not.
Run.CapacitySubjects(capacity_subjects) ridesRunCredStampbesideCredFingerprints: written as one unit at launch, and re-stamped at every resume from the re-sealed bundle — both channels,APIKeysandPinnedAPIKeys— never fromContentBoundary.GatewayHost, which is frozen at launch. It is never folded intoCredFingerprints, which the run snapshot, a usage wait's wall credentials and the credential walk read as the identities of credentials. Stamping without a bound is what lets a bound set during a burst count the runs already on the host (adoption), and it feeds a per-host gauge with no configuration. A resume's re-stamp fails closed as soon as its old or its new stamp carries a subject.Park before start. The publisher reserves
gw:<host>after sealing, before it writes or publishes the run, in the all-or-nothing loop that reserves the key slots — keys first, then the gateway, so a reservation given back on a key's refusal never touches the row every team shares. Refused, the run is parkedfailed_resumablewith its retry armed in the same write: codeGATEWAY_SLOT_WAIT, reasongateway_slot, a free re-ask at the entry'sprobe_interval(2 min by default). The budget clock has not started andRestoreexcludes stopped time, so the wait costs no pod and no budget. The refusal is aCapacityRefusal{Kind, Subject, Label, Held, Max}; for a gateway it answerserrors.Is(ErrGatewayAtCapacity)and unwraps toErrCredentialAtCapacity, so the retry sweeper, the 429 and the missions read it as they read a key's. The parked text names the host and the count across all teams, and no other team's run.The transit guard: the bound holds outside the admission. Three closures, shipped before any
enforce; they close the per-key cap's holes too.C1 — a continuation keeps its place. One predicate,
Run.HoldsCapacity(now):queued,running, orfailed_resumablewithcontinuation_state = redelivery_pendingandupdated_atwithinRedeliveryHoldTTL(10 min by default, leverITERION_REDELIVERY_HOLD_TTL, which covers the longest nak plus the orphan-adoption floor). The holder predicate, the eviction, the adoption and the count read it, on both twins, for keys and subjects alike.C2 — the runner re-asserts before any direct resume. A ledger primitive,
ReassertCredSlot(ctx, subject, runID): a conditional write that moves the run's entry to a new instant if the entry exists — the shape of the ledger's in-place re-admission, with no max and no configuration. Under the run lock, before the engine resumes a delivery that readfailed_resumableor adopted arunningorphan, the runner CASes the continuation toredelivery_pending, then re-asserts each stamped subject:- every one held → the run resumes;
- one missing → no resume: a free retry is armed, the message is acked, and the run goes back through the publisher's admission;
- a ledger error → a deferred nak, never a resume on a guess.
The order is the guarantee: an eviction judged before the CAS misses the moved entry, one that fires between the CAS and the re-assertion makes the re-assertion fail, and one judged after the CAS sees a holder.
C3 — the launch closes after its write. The same primitive runs after
PersistLaunchRunand before publication. An entry gone means the launch stalled pastCredSlotGracebetween its reservation and its write and was evicted: one fresh reservation is tried, and if it is refused the run is CASedqueued → failed_resumable, parked and armed, with nothing published.
A tree is one place. A subbot child runs in its parent's runner, under its parent's message, and carries no stamp of its own. A child resumed after its human gate is granted under the place of its live ancestor that holds
gw:<host>, with no new entry, so N parents holding N places while each waits on its child's human answer never deadlock on a 429. A child whose ancestors have all ended asks for its own place.A deferred launch runs the current bot when nothing started. A parked run with no checkpoint, no
started_atand no runner claim is re-resolved on the current bot when it is admitted, and its inputs are revalidated against the current workflow as a launch's are; the version it runs is recorded on the run. The hash check is not opposed to it, so a bot updated during the wait spends no attempt. A run with a checkpoint keeps the hash check.Configuration: a platform family, observed first, enforced behind a guard.
- The family.
platformcfgfamilygateway_capacity, one entry per canonical host:max_concurrent_runs(0is no bound on every branch — no reservation, refusal, offer, yield or would-park count, the meaning0already has on a key),mode(observeorenforce),probe_interval(strictly positive), a note. Super-admin routes with CAS and audit, a status route (alive runs and bots per host, and the alive runs on the host whose subjects do not name it (nogw:<host>for that host; the host a run is on is the base-URL host of the gateway key its latest stamp sealed — nevercontent_boundary.gateway_host, which is frozen at launch and replayed onto subbot lanes — and a subbot child is attributed to its stamped ancestor)), the CLI and the OpenAPI. - The cascade intersects. The platform row is always reserved, a team key's own cap tightens it, and nothing below the platform raises it — a team would otherwise raise a bound it shares with twelve others.
observe. The publisher reserves nothing; it countsiterion_gateway_would_park_total{host}when the alive runs reach the entry's max, and admits.- The activation. About a week in
observeon the per-host gauge, thenenforceat 8, lowered toward 6 if the latency of one call stays above about twice its nominal value. ThePUTthat setsenforceis refused (409, with the count) while alive runs on the host carry subjects that do not name it (counted as the status route counts them);accept_unstamped: trueis the explicit, audited escape. Before it, every server replica runs the enforce release and every runner the transit-guard release, read from the deployed digests, not from a tag. - The rollback. The lever is
mode: observe, or removing the entry, effective within the resolver's 30 s; parked runs are admitted unbounded at their next re-ask. - Failures. A configuration never read since the replica started, with a gateway key sealed: the run parks, "capacity unknown" — a webhook launch has nobody to click again. A configuration that fails after a first read: the last known value. A ledger error: the launch is refused, because a hard bound that opens on an incident is only advisory.
- The family.
max_waitbounds the whole wait. The horizonscheduled_at + max_waitis checked before an offer, before the cheap pre-check and before the resume, without spending an attempt — the promise the retry sweeper's comment already makes.The host alone in v1. One subject per host. The model joins it (
gw:<host>|<model>) on its own trigger — other models of the host taking its places — once route resolution exposes the model of each call site.
Considered options
- A semaphore per provider call, waited on before each call (
callAndAggregate). It needs a Mongo registry with a TTL, an IPC to the sandbox where neither Mongo nor NATS is reachable, a budget clock suspended while waiting and a node deadline that moves (engine_exec.gofreezes it at node start), and it fails open on a Mongo outage by default. It does not do better on the 2026-11-13 burst: every pod starts and every call queues. It is kept as a later step, built on any one of these triggers: a measured LLM duty cycle ≤ 0.5, where the admission immobilises more than half the capacity; a fan-out bot that saturates the gateway alone; significant server-side traffic on the bounded host (supervisors, the conflict agent, the session board); the need to give the place back during model-idle phases or while a parent waits on its child. Its prerequisites are an ADR on the suspended clock and the moving deadline, and an IPC version marker for the sandbox. - Key pools, or a cap on each team's key. A cap of one on each of 13 keys still allows 13 runs, above the saturation point, and a pool routes spend between keys without bounding the host they share (ADR-164). A team key's cap stays in v1 as the per-team share inside the gateway's bound.
- Taking the place at the runner's claim, the publisher's admission kept as an early filter. One enforcement point that every execution crosses, future ones included — but the runner must then read
gateway_capacityand the key caps, a refusal at claim acks and parks from the runner, and two acquirers have to be reconciled. Rejected for C1–C3, where the publisher stays the only acquirer and the runner only re-asserts a place, with no configuration. It wins if an execution path that bypasses the publisher appears. - Accepting "N plus the runs in transit" and measuring, with no re-assertion in the runner. No runner change — but the bound gives way exactly during a deploy's drain, when redeliveries are the most numerous and the soft-order pass would hand the drained places to parked runs. It wins only if redeliveries prove rare and the margin under the knee comfortable.
- Folding
gw:<host>intoCredFingerprints. One field fewer, and every reader that takes a fingerprint for a credential's identity would lie. - A separate
gateway_slotsledger. A second admission, adoption and eviction to keep in step with the first, for the same conditional write. - A strict FIFO from the first enforced slice — a revision counter on every ledger write, key rows included. It stays on its trigger: overtakes measured despite the soft order.
Consequences
- The ledger becomes the run-admission ledger, for keys and gateways alike, and the transit guard closes the per-key cap's existing redelivery and stalled-launch holes.
- New durable state, each with its cloud twin in its slice:
capacity_subjectson runs (both twins),capacity_stamped_foron runs (both twins, written only throughRunCredStampwith the lists it qualifies: the marker that the latest stamp read its subjects off the sealed bundle, so that an emptycapacity_subjectsmeans no gateway key),gw:rows incred_slots, thegateway_capacityplatform document. The status index serves both arms of the holder filter; its cost under load is measured, not assumed. - Mixed versions. An older publisher reserves keys only and an older runner resumes without re-asserting: hence the version checklist before
enforce. A pre-T1 replica'sSaveRunkeepscapacity_subjects(fields unknown to its schema are preserved) and itsSetRunCredStampleaves them in place: a run whose re-resolution it stamps keeps its old subjects, so when the key moved off that gateway — to another one, or to a key on no gateway — the run is over-counted on its old host until a re-stamp by a T1-or-later replica rewrites its subjects, or it ends; and when it moved to another gateway it is under-counted there. A T1 replica'sSetRunCredStampwrites the subjects of a stamp that carries none — it clears them — so a T2-stamped run it resumes during a T1→T2 rolling deploy loses itsgw:<host>while it keeps running there: under-counted until its next re-stamp. Neither knowscapacity_stamped_for(T2): both leave it in place. It is a digest of the fingerprints and subjects its stamp wrote, so once a T1 or pre-T1 re-stamp has rewritten either list it no longer matches them and reads as unset, and the status route reads that run as stamped without its subjects — on the host its key row names, or unresolved once no row answers and its content boundary records a sealed key — never as a run that left the gateway. The one older re-stamp it survives leaves both lists as they were, which then still describe the same keys. Every under-count is a run alive on a host whose subjects do not name it, which is what the status route counts and what the activation guard refusesenforceon (§7); over-counts and under-counts alike bias theobservegauge. - A long run with few calls holds its place for its whole life: N is sized in runs, not in calls, until the per-call step's trigger fires.
- The wait is visible: the existing
run_retry_scheduledevent gainswaits_on,held,maxandposition; the studio reads "waiting for gateway capacity · 4th" with a chip that is not red; the pull request gets a pause notice of its own, with no time and no "quota", once per episode. - The node deadline frozen at node start kills a slow run whatever the cause. That defect is a ticket of its own: the bound removes the 2026-11-13 cause, not it.
Slices
Each slice owes task check (CI adds race, vendor-check and mongo-conformance), every test seen red under its named mutation, its Mongo protocol tests run on a real replica set (a local skip is not a pass), a review loop with its trailers, its documentation in the same change, and a sub-issue of #3254.
- T0 — measure, no code: that the 22 runs sealed an
openai_compatiblekey and carrycontent_boundary.gateway_host; the host's latency against concurrency on 2026-11-13; review-pr's LLM duty cycle and concurrent calls per run; the other bots and models on the host; the subbot bots with a human gate; the naks and redeliveries per day and per deploy. - T1 — the ledger accepts subjects that are not keys. Store only, no behaviour change:
Run.CapacitySubjectsandRunCredStamp.CapacitySubjects, bothSetRunCredStamps, the predicate's second arm and its Mongo$or,GatewayCapacitySubject, the ledger's documentation; the conformance rowsCapacitySubjectHolder,CapacitySubjectIsNotAFingerprintandCapacitySubjectStampRoundTrip, on both twins. - T2 — the stamp and the gauge. The subjects stamped at launch and at resume, with the marker that the stamp read them (
capacity_stamped_for), the fail-closed re-stamp, the per-subject count,iterion_gateway_alive_runs{host}, the status route with its count of the runs alive on a host whose subjects do not name it (the host read from the run's latest sealed gateway key, subbot children attributed to their stamped ancestor). - T3 — the
gateway_capacityfamily, inobserve. Validation and warnings, the Mongo and memory twins,Resolver.Ready(), the routes, the CLI and the OpenAPI,would_park, the operator documentation. - T4a — the transit guard. C1, C2, C3 and the park armed in one write, proven on two Mongo clients, with the frozen-program re-admission of a started run's capacity and usage-window parks (#3820). Built with the departures from §4 and §6 that the amendment of 2026-11-26 below records.
- T4b —
enforce. The gateway's reservation after the keys',CapacityRefusalandErrGatewayAtCapacity,GATEWAY_SLOT_WAIT, the 429gateway_at_capacity, "never read" parks, the tree and the deferred-launch defaults, the activation guard. - T5 — the wake and a soft order. The parked run's wait identity on its retry state, an offer that respects a live claim, a capacity pass that resumes what it offers outside the due batch, a cheap pre-check, the yield to older parked runs when
max > 0, the release of parked runs when an entry goes tomax: 0, the whole-waitmax_wait. - T6 — the wait made visible, up to the pull request's notice.
- Later, each on its trigger: a platform per-team share of a gateway, the
gw:<host>|<model>subject, a gateway funded by a pool's environment, the strict FIFO, the per-call semaphore.
Amendment (2026-11-26) — the transit guard as built (T4a, #3820)
T4a builds C1, C2 and C3 and the park armed in one write, proven on two Mongo clients of one replica set. §4 and §6 keep their wording; where the code departs from them, this amendment is the record. The operator approved each departure, and the behaviour changes below, on 2026-11-26.
How the transit guard departs from §4.
The hold expires at an instant its writer stamps,
continuation_until, notupdated_at. A run in transit isfailed_resumablewithcontinuation_state = redelivery_pendingand acontinuation_untilstill ahead. Every transit writer is a runner, soITERION_REDELIVERY_HOLD_TTL(10 min by default, unset or empty alike) is read by runners only, at boot: a value that does not parse stops the boot, one under 7 min is honoured with a warning. The hold outlasts the re-offers a delivery hands back once it executed (3 min at most, a sandbox that was not placed), each stamped again by the post-engine promote at its nak, plus the 4 min floor under which a running document is not adopted — not every nak, as §4 put it: the nak of a delivery whose lease another pod still holds (natsq.HeldLockRetryDelay, past 10 min from the fifth delivery on, up to about an hour with the defaults) and a schema or epoch refusal come before the guard and refresh no hold. A redelivery that arrives after its hold still re-asserts by its token, and parks onCRED_SLOT_WAITwhen an admission took its place meanwhile. Every reader compares the stamped instant with its own clock, andcontinuation_untilfollows every continuation writer. The holder predicate, the eviction, the adoption, the count and the alive-run listing read it on both twins; the Mongo filter is a rooted$orwhose transit branch the partial indexcapacity_transitserves.A re-assertion names its admission. A ledger entry carries
admitted_at, the instant the reservation that wrote it returned (CredSlotAdmission.At), on a push and on an in-place re-admission; an adoption writes none.ReassertCredSlot(ctx, subject, runID, token)moves only the entry whoseadmitted_atistoken. Neither an adopted entry nor one a later admission wrote is held by an older admission's re-assertion. This closes three holes without recording the reservation on the run document: C3 accepting an adopted entry (two launches on a cap of one), a cap set while runs are in transit — on the subjects their message holds, and until their hold ends (the residual below) — and an operator rollback taking an entry the runner just proved. Ledger decisions read the primary; the transit write and the re-assertion use majority write concern.The message carries what its admission reserved, not "each stamped subject":
RunMessage.capacity.holds(subject and token), filled by the launch and by the resume from their own admission. An admission that reserved nothing iscapacity: {}. A message from a pre-T4a publisher has none: it is resumed unguarded and countedlegacyoniterion_capacity_reassert_total, which must read 0 before T4b's checklist (the chart's alert pack records it asiterion:capacity_reassert_legacy:increase24h). No schema bump. A subbot child's copy of the message clears it.The residual: a subject the message does not hold. A run's stamp names every key it sealed and every gateway subject, capped or not; its message holds only what its admission reserved. A subject in the stamp and not in the holds — a key or gateway capped after the admission, or never capped — is covered by the transit's adoption alone. A delivery that resumes the run while it holds nothing (
Run.HoldsCapacity: neither alive nor in its transit) — the hold lapsed, a post-engine promote that failed left none, a DLQ replay, an operator-paused run redelivered on an admission that held nothing — re-asserts nothing on it and can run beside a run admitted in between, on a cap set after the admission. It proceeds, and is counted per such subject,outcome="unheld_out_of_transit"at stagedelivery, from the run as the delivery's precondition read it. T4a does not close it: that needs to know whether a subject has a ledger row, a read neither twin has.C2 runs in three stages.
- Under the run lock,
store.EnterCapacityTransitwrites the transit, then re-asserts each hold, keyed on the status the write finds — launch and resume messages alike. - Just before the engine loads the run, the transit is refreshed when the clone took more than a quarter of the hold.
- A claim guard (
runtime.WithResumeClaimGuard, run incasResumeClaimbefore any claim write) re-asserts on the document the claim reads and writes nothing to it; the claim fences on its version. A guard makes the pause path claim first.
Each stage counts on
iterion_capacity_reassert_total, by stage, outcome and kind.- Under the run lock,
The hold starts at the engine's park.
runtime.WithOnResumableParkfires on each of the engine's park writes with the error the engine returns for the park (every writer offailed_resumableis inventoried from the store's source and held to it,TestEveryEngineParkFiresTheHook, #3925), and the runner's hook reads it with the delivery's own classifier (classifyExecResult). A park the runner re-offers holds its places through the post-engine steps: an interruption, a node's failure or timeout. A park the runner acks on the spot starts none: a deterministic failure, a spent budget, afailnode whatever code it declares (trunk, branch or a sub-bot's child), a trust refusal, and a provider usage window that the usage-window road will take — the hook asks the road's own predicate under the run's policy (usageWindowRoadTakes); a usage window the road hands back (the policy is off, there is no retry surface) is re-offered and held like any other park (#3922). A held park whose delivery is finally acked has its transit ended with it. The post-engine promote and the orphan adoption stampcontinuation_untiltoo.A delivery ends the transit it started. A delivery that resumes nothing and is not naked for a redelivery puts back the continuation it found and gives back the places it re-asserted, only when that end matched: a run claimed in between keeps them (
iterion_capacity_transit_end_total). On a last delivery whose transit write itself fails, the continuation is markedfinalrather than leftredelivery_pendingwith no redelivery to honour it.The park is one write, on Mongo only (
store.CapacityParker, asRunRetryStoreis, since the retry sweeper it feeds is Mongo-only).SaveParkedLaunchRunparks a launch in its create, code included;ParkRunOnCapacityparks a runner's run from its own transit. Both arm the retry with the builderScheduleRunRetryuses. A runner's lost place parks onCRED_SLOT_WAIT: free for an infrastructure source (INTERRUPTED,PROCESS_ORPHANED,SANDBOX_SETUP_TIMEOUT,SANDBOX_CAPACITY,ATTACHMENTS_UNFETCHABLE), charged against the retry budget otherwise. The pool lease of a delivery that never ran is closed. A store error on the park's road (the run's read, the park write, the re-read of a charged park refused) re-offers the delivery after a delay with its transit kept; on the last delivery it ends the transitfinal, its cause on the run's timeline — unless that end finds the run moved (a write that landed despite its error, an operator's resume): the run is left to whoever moved it, nothing on its timeline. The park's store budget starts once the freeze returned.C3 runs as §4 states it and counts on
iterion_capacity_launch_reassert_total(held,reserved_again,parked,error).
Behaviour changes.
- A redelivery no longer resumes an operator-paused run whose message carries reserved holds (drop
operator_paused_holds_capacity), nor a run whose retry is armed (dropretry_armed). The runner and the DLQ replay both word these drops, and the runner acks a drop it has no wording for instead of proceeding. - A C2 park drops the message's one-shot intents: a codemode quota restatement, an unspent scratch-loss consent.
- A C2 park is charged for an execution-failure source, as above.
- A forced resume that loses its place is not forced again by automation: an operator resumes it.
Frozen-program re-admission. A C2 park of a run that started keeps the program its delivery carried, so the retry sweeper's re-admission resumes what a redelivery would have, not whatever the bot became during the wait.
- The freeze. The parking runner writes the delivered IR and bundle reference into a content-addressed envelope (
ir/<run>-bundle-program-<digest>.json, in the run's-bundle-key space: tenant-checked on read, deleted with the run). The park's single write records it on the run root (frozen_program), bound to the document'squeued_atand the run's workflow hash. Nothing else writes it but the usage-window park below, and the FS twin has no writer. A freeze that fails parks the run without a record;iterion_capacity_frozen_program_totalcounts each park aswritten,not_started,freeze_failedorhash_mismatch— the first two once the park lands, a failed freeze when it fails. - The re-admission. The sweeper reads the record before anything is metered. A record whose attempt or hash moved is stale: it is ignored and the run takes the current-bot path. A bound record republishes the envelope verbatim through the run service and the publisher (
ResumeSpec.Frozen), never withForce, the binding checked again on every document they act on. Credentials, their stamp and the capacity admission are resolved again, as on every resume. A stored bot deleted during the wait still ends the automation. One deleted and re-created under the same slug since the parked attempt — its row born after the attempt'squeued_at— is another bot: on either park's road the record is ignored as stale, never re-admitted, and the run takes the current-bot path. An inline-source run parked on capacity now resumes, where the sweeper abandoned it. - §6 for a started run. "Nothing started" reads as no checkpoint and no recorded attempt (
run_started,run_resumed):started_athas no writer and a runner claim leaves no durable witness. §6 is unchanged for a run that did not start: its C2 park freezes nothing (not_started) and it takes the current bot, so a bot changed during that wait is still refused for its hash until T4b's deferred-launch defaults close it. - Consent refusals end automation. On every sweeper retry, frozen or not, a resume refused for an undecided effect, a scratch or a lineage that does not travel, an artifact contract the program no longer meets, or a required secret that resolves to nothing (
secrets.ErrRequiredSecretUnresolved) is abandoned at its first due, its reason named ("resuming needs an operator"), instead of being re-armed until the budget is spent. A refusal whose every missing secret had a stored candidate that failed to read or to unseal is not one: it is re-armed. - Usage-window parks keep the program too, resumed only when the bot changed. Before a usage-window park of a started run arms its retry, the runner freezes the delivered program and records it on the run root (
store.FrozenProgramWriter.SetRunFrozenProgram, Mongo only: one write fenced tofailed_resumableand the exactqueued_atof the attempt it parks), sourceusage_window, counted oniterion_capacity_frozen_program_total{source="usage_window"}; a record that does not land is said and counted, and the retry is armed all the same. The sweeper resumes the bot's current program first, so a wait whose bot did not change takes its current skills, devbox and subbot snapshot; a refusal for a changed source (runtime.ErrWorkflowSourceChanged), or for a current program that no longer compiles (runview.ErrCurrentProgramUnloadable), makes the same pass resume the frozen program instead, on the same admission, unforced. A pull-forward probe's re-admission that meets the window again is parked again on its own attempt and records the program there, so the record follows the run from wait to wait.
