docs/spec/implementation/requirements/the-script-01.md
Requirements
Section titled “Requirements”The Script (agent-cycle.sh)
Section titled “The Script (agent-cycle.sh)”-
Lock. Before the fleet-log union below is built, a cheap pre-check reads any lock file already in
state_dir: a recorded pid that is alive, whosehostmatches (or carries none), and whose age is under the larger of the pre-derivation default/floorlock_stale_afterand the last threshold requirement 4f’s own derivation produced on this node (agent-ops#2321) already holds, and is treated as held and fresh — logcycle-skipped, remove the record directory this tick made (which holds nothing at this point: the fleet-log union has not been built) and exit 0. That derived threshold is not available this early, so it is read back fromstate_dir/.lock-stale-after-sec-cache: a bare integer the script writes immediately after deriving it, best-effort in both directions and node-local (a cache of what this node derived, read by nobody else, so it is excluded from replication like.image-drift-cache.json). Missing, empty or non-numeric — no cycle has reached the derivation on this node yet, or the write failed — the pre-check compares against the pre-derivation default alone. Taking the larger of the two never widens a takeover window, because this pre-check only ever skips: too large a threshold delays the slow path reclaiming a hung holder, exactly as too small a derived threshold already does, and takes nothing over early. Every other case — no lock file, a dead pid, a foreign host, or an age that already clears even that threshold — falls through unchanged: the union is built (requirement 2.5) and the preciselock_stale_afterderived from it (requirement 4f), and only then does the script acquire the lock file instate_dir, recording PID, start time, and the writer’s hostname (host— on a containerised node the container, which is the PID namespace the recorded PID is meaningful in; the watchtower pre-update hook reads it, see the node stack section). A pid is only meaningful in the PID namespace that minted it, so a lock whose recordedhostdiffers from this run’s own is judged by host, not pid: it was written by a container that is gone by construction, taken over immediately — no liveness check, no process-group kill — logging the samewarning. Only a lock whosehostmatches (or carries none, from before this stamp existed) is judged by liveness: if held by a live process younger than the now-derivedlock_stale_after, logcycle-skipped, remove the record directory this tick made (its only content at this second check is the fleet-log snapshot built above, and a directory that ran no stage would otherwise take one ofstate_local_streams_retained’s slots from a cycle that did — requirement 2.5) and exit 0; if the holder is dead or older thanlock_stale_after, end its whole process group if still alive — TERM first, then a polled grace of up to 20 seconds for the process to exit, then KILL — log awarning(a stale cycle indicates a fault — it should not occur in normal operation), take the lock, and continue. The grace exists for requirement 9c: TERM is what invites the doomed cycle’s own signal handler to write itsattempt-failed, release its claim and log itscycle-end, and it is sized to that handler’s worst case (one process-group kill, one log append, one 8-second-bounded claim release). Polled rather than slept, so a cycle that records and exits in one second costs one second. 1a. Model id resolution, against a configured set of providers (D12, issue #2131).providersstates which providers beyond the implicitanthropica model key may qualify with — keyed by provider name, each entry naming asubstrate(the adapter that launches it;claude-codeandgrok-buildare the two this image has, issue #2134.claude-codeaccepts theanthropicprovider only — D29, issue #2198: Claude Code pointed at another vendor’s own endpoint is not a thing this codebase does, so any other provider namingclaude-codeis a config error, named below.grok-buildis open to any provider name, since Grok Build itself is the vendor’s own CLI pointed at its own account) and, optionally, acredential_env(defaulting by substrate —ANTHROPIC_API_KEYforclaude-code,XAI_API_KEYforgrok-build; anANTHROPIC_API_KEYnot scoped at creation to a single workspace also needsANTHROPIC_WORKSPACE_IDset, issue #2309).lib/model-id.sh’sproviders_loadloads it intoPROVIDER_SUBSTRATE(andPROVIDER_CREDENTIAL_ENV) once, at startup, before any model key is resolved — synthesizinganthropicwith substrateclaude-codewhether or notprovidersnames it explicitly, so no existingconfig.jsonneeds to change. Every model key read from config —coordinator_model,implementer_model_default,implementer_model_trivial,reviewer_model_default,reviewer_model_complex,enabler_model,enabler_model_critical,refiner_model,approver_model_default,approver_model_complex,approver_model_critical— is resolved immediately after being read, before the lock and before any stage may launch: a bare id (claude-sonnet-5) meansanthropic/claude-sonnet-5; a qualified id has the qualifier stripped to the same bare id once the named provider is accepted; a qualifier naming a provider absent fromprovidersis a fail-fast config error naming the offending key, not a value ever passed toclaude --model, and so is one naming a provider whose configuredsubstratehas no adapter in this codebase — named alongside the key, so agrok-4.3qualifier can never reachclaude --modelbecause the schema admitted it. An empty value (the “disable this stage” conventionreviewer_model_complexandenabler_modelboth use) passes through unresolved.review-cycle.shapplies the same resolution to every repository’s own resolvedrepository_review.defaults.model(or its own override inrepository_review.repos, issue #342) (docs/spec/review/README.md). Both scripts share one implementation,lib/model-id.sh’sresolve_model_id_into(and its siblingsresolve_model_id, the same resolution as a value on stdout, andresolve_model_provider, which names the provider a key resolves to rather than the bare idclaude --modelwants), so the two pipelines can never drift on what counts as a supported provider. Resolution also records which provider each bare id came from, inMODEL_PROVIDER, and that is why every stage model is resolved through the assigningresolve_model_id_into VAR KEY VALUErather than the printingresolve_model_id(issue #2133): the recording is a side effect in the caller’s own shell, and a caller writingVAR="$(resolve_model_id KEY VALUE)"runs the whole resolution in a subshell, so the bare id returns and the recording is discarded with it. Requirement 4d’s substrate dispatch and requirement 33a’sproviderfield are the two readers of that map, and both fall back toanthropic/claude-coderather than failing when it holds nothing — so the printing form at a stage-model site costs no error, only a stage silently launching on the wrong provider’s adapter. The printing form is for a caller that genuinely wants the string alone:scripts/doctor.sh’s configuration report,scripts/publish-dashboard.sh’s tier lookups, andresolve_model_qualified, which builds the<provider>/<bare-id>id requirement 1c’s tier ladder is keyed by.providers’s own entries are each named by the installation, which is outside what the declarative schema (requirement 1b) can shape-validate on its own — an eighth guard alongside requirement 1b’s other seven,lib/config-schema.sh’sconfig_provider_errors, rejects an unknown key inside an entry, a missing or unsupportedsubstrate, asubstrateofclaude-codenamed by any provider butanthropic, or an explicit emptycredential_env, shared the same way betweenagent-cycle.sh,review-cycle.shandscripts/doctor.sh. Which substrate a resolved model’s provider launches on, and how that substrate’s own adapter is implemented, is requirement 4d’s own scope, not this one’s — this requirement stops at naming the provider a model key resolves to.Every model key above may instead name a weighted set of models (issue #2247), splitting that actor’s work across providers the way
lanesbelow already splits one provider’s own work across its two credentials:{"models": [{"id": "anthropic/claude-sonnet-5", "weight": 2}, {"id": "xai/grok-4.7", "weight": 1}]}, each member’s ownidin the same bare-or-qualifiedmodelIdshape as an ordinary key’s single value,weightan integer >= 0 defaulting to 1.lib/model-id.sh’smodel_key_load_intois the set-aware form ofresolve_model_id_intoevery one of the keys above now resolves through: a bare or qualified string resolves exactly as it always did, delegating outright, so nothing changes for a key no installation has turned into a set; an object resolves every member through that same resolution — an unresolvable member is the identical fail-fast config error an ordinary key’s bad value already is, naming the key and the offending member, and so is a set whose members strip to the same bare id under different providers (e.g.anthropic/claude-sonnet-5andopenrouter/claude-sonnet-5, bothclaude-sonnet-5with the qualifier stripped), naming the key and the colliding bare id instead of the offending member — refused rather than loaded and left to have the second such member’sMODEL_PROVIDERwrite silently overwrite the first’s, which would have every launch land on whichever provider resolved last regardless of which member the draw actually picked, defeating the configured split without any error ever surfacing (agent-ops#2677) — and normalizes the set intoMODEL_SET_JSON, keyed by the config key’s own name, which becomes the “handle” value the key’s own variable holds in place of a single bare id. A member is drawn from the set once per launch, by weight, before the lane requirement 4d’s own draw chooses (lib/stage-run.sh’sstage_model_resolve_into/stage_model_draw_into): the same seededcksum-mod-total-weight-then-bucket rule D30’s lane weights already use, reused rather than duplicated with a rule of its own, so “drawn by the same weighted rule” is the set’s own contract, not a second one to learn. A member whose provider has no credential lane open right now is skipped in favour of a sibling’s draw — screened by the identicalstage_lane_any_present-then-stage_lane_drawcheck the eventual launch repeats for whichever model the set settles on — so a model is never handed to the launcher only to fail there for a lane reason the draw could have avoided; if every member’s provider is shut, the draw gives up skipping and the launcher’s own “no open lane” refusal (requirement 4d) is the correct outcome, not a special case here. Which set key was drawn from, and which member it settled on, are named on thestage-startevent (requirement 33) a launch that drew from a set carries, alongside the drawn member’s own bare id wherever the stage’s model is otherwise named (stage_budget_apply’s own per-(actor, repository, model) cache cell among them, so a set’s distinct members warm-start their own cells rather than sharing one for the handle). Requirement 1c’s floor check reads every member a set can draw — never just whichever one a single draw happened to pick — throughlib/model-id.sh’smodel_key_qualified_ids, which expands a set’s handle to every member’s qualified id (or wraps a single ordinary id in a one-element array), reading each member’s provider back out ofMODEL_PROVIDERrather than re-deriving it from the already-qualifier- stripped bare id, which would wrongly assumeanthropicfor any member whose provider was not the implicit one.Requirement 3b’s no-op fingerprint reads a set’s members for the mirror- image reason, through
lib/model-id.sh’smodel_key_fingerprint_json(issue #2660): a fingerprint that embedded the key’s own variable directly would see only the handle — the config key’s own name, a constant — so editing which models a set draws from, or their weights, would leave the fingerprint byte-identical and the fleet-wide forced recheck a model change is meant to trigger would never fire. The function embedsMODEL_SET_JSON[handle]’s normalized member array for a set-configured key and the value itself as a JSON string otherwise, so an ordinary key’s contribution is byte-identical to a bare--argand a key no installation has turned into a set fingerprints exactly as it did before sets existed. Every model keylib/gather-phase.shbuilds into a fingerprint-input config object routes through it —coordinator_model,implementer_model_defaultandimplementer_model_trivialinselection_config,enabler_modelinenabler_configandrefiner_modelinrefiner_config— which of those objects the canon itself then carries being requirement 3b’s own scope rather than this one’s. The keys that are in no such object at all — the Reviewer’s and Approver’s tiers,monitor_model, andrepository_review.defaults.modeland its per-repository override — have nothing to fold into, since they are read per selected item or belong to pipelines with no no-op short-circuit of their own.A provider’s entry may also carry
lanes(the credit mix, D30, issue #2240): an object naming at most the two credential pathsapiandsubscription, each carryingweight(an integer >= 0; a lane’s share of its provider’s launches relative to its sibling, and so of its spend in expectation — #2241 is the launcher that reads it; this requirement only configures and validates it),enabled(a boolean, or unset meaning “open only when it is the one the CLI would use unaided” — the key when present, else the login, which is every node’s behaviour before this configuration key existed), and the thresholdsscripts/doctor.sh’s “Claude” section reads and #2243’s closing lever will act on:spend_cap_usd(0 means none) withspend_window_hours, andbalance_usd,balance_as_ofandbalance_floor_usd. Absent, or present withoutlanes, a provider’s two lanes resolve toapiweight 1,subscriptionweight 0, neither enabled and no thresholds — D4’s precedence exactly as every node already runs it, reproduced rather than newly configured.config_provider_errorsvalidateslanesthe same way it validates the rest of a provider’s entry, and for the same reason (each provider’s own key, and now each lane nested inside it, is a name the installation chooses, outside the declarative schema’s reach): an unknown lane name, a lane value that is not an object, an unknown key inside a lane, aweightthat is not an integer >= 0, anenabledthat is not a boolean, aspend_cap_usd/balance_usd/balance_floor_usdthat is not a number or aspend_window_hoursthat is not a positive integer, abalance_as_ofthat is not a string or is not an ISO 8601 date (or date-time), abalance_floor_usdset without bothbalance_usdandbalance_as_of, aspend_cap_usdorbalance_floor_usdset on a lanelib/model-id.sh’sPROVIDER_LANE_NO_MEASUREnames as having no cost measure at all (no substrate-reported cost and no statement, #2248 — today:xai/subscriptionalone, #2246), and both lanes resolving to weight 0, which would leave the provider with no open lane.providers_loadpopulatesPROVIDER_LANES(keyed by provider name, valued by a JSON object carrying both lanes fully defaulted) alongsidePROVIDER_SUBSTRATEandPROVIDER_CREDENTIAL_ENV, synthesizing the same all-default object for the implicitanthropicwheneverprovidersdoes not name it explicitly.scripts/doctor.sh’s “Claude” section reads it to report both ofanthropic’s own lanes independently — theapilane byANTHROPIC_API_KEY‘s presence and shape, thesubscriptionlane byclaude auth status --jsonrun with that key stripped from its own environment (so the answer is about the login, not the key), naming whether the login is a genuine subscription or a Console account (which bills the API and so is not an open subscription lane, #2241) — each line naming present or absent, the lane’s own configured weight, and whether it is enabled (explicitly, or by default given this node’s own live credential presence). Both lanes absent is still afail, exactly as a single missing credential was before this paragraph’s own configuration key existed. Its “xAI” section reads the same map the same way for whichever provider entry names substrategrok-build— by that entry’s own key, never the literal namexai, whichgrok-buildis not reserved to — reporting theapilane byXAI_API_KEYand thesubscriptionlane by the existence of$GROK_HOME/auth.jsonalone, since completing the device-code login that writes it is an interactive operator step no check may perform — D4’s own exception to the non-interactive bring-up, the same one the Claude subscription login carries. Both present warns that Grok Build’s own precedence prefers the stored session over the key; neither is the samefail. 1b. The configuration has a machine-readable schema, and it is the startup gate both pipelines run on.config.schema.jsonstates the shape ofconfig.json— every key an installation may set, its type, its constraints, and the value the code falls back to when it is absent. It covers both pipelines’ keys, including therepository_reviewobject ofdocs/spec/review/README.md, because there is one configuration file and a schema that described half of it would licence the other half to drift. Every object in it is closed (additionalProperties: false), which is the point: an unread key is a default nobody chose, so a misspelling is otherwise indistinguishable from a deliberate omission for as many cycles as it takes a human to notice.lib/config-schema.shvalidates a config against it, implementing the subset of JSON Schema the file uses and no more; the schema may use only keywords that library implements, whichtest/config-schema.test.shasserts by reading the keywords back out of the schema — a validator that silently ignores a keyword is worse than no validator, because it reports the configuration sound. Bothagent-cycle.shandreview-cycle.shcall it at startup, immediately afterCONFIG_FILEis known and before any individual key is read from it — the same fail-fast position requirement 1a’s model-id resolution occupies, and well before the lock. A validation failure is fatal and names every offending path at once, the way the retiredniceguard already named every offending slug at once: one error per run turns a five-key typo into one cycle to fix, not five.scripts/doctor.sh(component 14) is what an operator runs ahead of time, against the same library function, so its verdict and the Script’s own refusal can never disagree. The schema is also the single source for the three prose configuration tables — this document’s,docs/spec/review/README.md‘s and the README’s — each leaf key’sx-docsfields carrying the prose,scripts/render-config-table.sh(component 16) rendering it into the documents’ marked regions and gating it in CI, so a key can no longer be added to the schema and forgotten in a prose copy the wayunvoid_labelandstate_local_cycles_retainedboth once were. A leaf’sx-docs.valueequal to its own schemadefaultdocuments the product’s shipped behaviour and nothing checks a live installation against it; one that differs documents Poetic’s own choice for that key, andscripts/doctor.sh(component 14) warns when a liveconfig.jsonresolves it to something else —refiner_modeldocumented as installed while the key had never once been set, silently running the stage off, is exactly the drift this catches (issue #567).A
$refresolves to a fixpoint, not one hop: a$defthat itself carries a$ref—pr_label‘sminLength: 1folded into arequiredLabelthat$refslabel, say — has every level’s keywords enforced, not only the outermost, and each hop’s sibling keywords keep winning over the target’s own. Resolution is bounded to a handful of iterations so a cyclic$refcannot hang jq. A$refnaming a$defspath that does not exist, or a chain still unresolved past the bound, is a fault in the schema itself —config_schema_errorsreports it as an offending path, the same as any other invalid config, rather than treating the missing target as no constraints at all (getpathon an absent path returnsnull, and jq’snull + {...}would otherwise silently keep only the sibling keywords, turning a typo’d$refinto a hole underadditionalProperties: false). Reported that way alone, at the config path the$refwas reached from, the check’s reach would be only as deep as the config: both cycles gate on the raw config, and a walk that descends only into keys the config actually sets would never resolve a$refon a property the operator has omitted, leaving that property’s own typo exactly as silent as before.config_schema_errorstherefore also sweeps the schema on its own terms — descending only through the keywords the validator itself understands (properties,items,propertyNames, an object-valuedadditionalProperties,$defs), never over everypaths, which cannot tell a schema node from adefault,constorenumvalue that happens to carry a$refkey of its own, and a false positive there would fail both pipelines’ startup gate for every installation. This sweep resolves every$refit finds regardless of whether any config key reaches it, including a$defsentry nothing currently references and anitemsschema behind an array the config leaves empty; its fault is reported in schema space (schema.$defs.label,schema.properties.pr_label) rather than borrowing a config path it no longer has, so the two kinds of fault read distinctly.config_defaultsresolves the same fixpoint so an inner$def’sdefaultreaches through a chain too, but performs no validation of its own: there, an unresolved$refjust means nodefaultto find at that hop, the same as an ordinary$defcarrying none — including a$refcombined with a siblingdefaulton a key the config omits, which the schema-wide sweep above catches as a fault even thoughconfig_defaultsstill degrades it to nothing there.The schema is likewise the single statement of the values a reader falls back to, and not merely a description of them.
lib/config-schema.sh‘sconfig_defaultsmerges a config with everydefaultthe schema declares — recursively, treating an explicitnullexactly as absent (the two cases jq’s own//treats alike), filling each item of an array such asreposon its own, and synthesising an absent object whole from its leaves’ own defaults soschedulemay be omitted entirely — and every reader ofconfig.jsonreads that merge rather than a// literalof its own:agent-cycle.sh,review-cycle.sh,scripts/doctor.sh,lib/claim.sh,lib/labels.sh,scripts/state-sync.sh,scripts/rotate-logs.sh,scripts/sweep-orphan-branches.sh,scripts/publish-dashboard.shanddeploy/docker/render-crontab.sh. A default therefore exists in one place, and each of those scripts requiresconfig.schema.jsonbesideconfig.jsonat runtime. The merge performs no validation of its own — a config that fails the gate above still merges, defaults and all — which is what letsdoctor.shgo on diagnosing a config the Script would refuse. Three kinds of fallback are deliberately not schema defaults and stay in code: one that holds between two keys, of whichrefinement_after_coordinator_cyclesinheritingenabler_after_coordinator_cycles(requirement 34e) is the case in point; readers that must depend on nothing but bash,jqandconfig.jsonby design, so that what they read cannot drift from what is actually deployed —deploy/docker/watchtower-pre-update.sh, reading three keys (state_dir,lock_stale_after,repository_review.lock_stale_after) that carry no schemadefaultto take, andscripts/check-node-image.sh’s in-container grace read, which runs inside whatever image the node is currently running and so must stay correct against an image that predatesconfig_defaultsentirely — itsimage_behind_grace_hourskey does carry a schemadefault, but the read stays a literal// 3on principle rather than on necessity; and the shipped priors of the two self-tuning stage caps (requirement 4f), which live inlib/stage-budget.sh‘sSTAGE_BUDGET_PRIORS. The last is the one case where adefaulthere would be actively wrong rather than merely redundant: thetimeout_*,inactivity_*andrepository_review.defaults.timeout_review/repository_review.defaults.inactivity_review(and their per-repo overrides) keys are overrides, and a reader distinguishes “configured” from “absent” only by the key’s absence. Adefaulton$defs/inactivityMinutesor$defs/timeoutMinuteswould be merged in byconfig_defaults, read as an explicit override, and win permanently — pinning the cap at the injected value and leaving the derivation unreachable. Both$defstherefore carry none, and the keys’ documented value stays (unset).The schema being a gate retires the two startup guards it wholly subsumes:
nice‘s range (requirement 3) andprompt_overrides’ shape (requirement 4a) are both fully expressible astype/minimum/maximum/additionalPropertieson a single object, so neither has a hand-written check left inagent-cycle.shorlib/prompt-overrides.sh. Five guards stay in code rather than moving into the schema, because each holds between two keys, whichadditionalProperties/required/etc. on one object cannot state: the Enabler’s assignee (requirement 35), the implementation-plan path (requirement 3k), and the three guards of requirement 1c below — the model-tier floor, a"required"refinement source withrefiner_modelempty, and one left unrefinable byrefiner_max_per_engagement: 0. All five are shared, not duplicated, betweenagent-cycle.shandscripts/doctor.sh—lib/config-schema.sh’sconfig_enabler_assignee_ok,config_missing_plan_path_repos,config_model_tier_floor_violations,config_required_refinement_sources_without_refinerandconfig_refinement_sources_paused_by_capare the one implementation each script calls, so the Script’s refusal (or, for the last of them, itswarning) anddoctor.sh’sfail/warncan never drift on what counts as a fault. Requirement 1c’s sixth guard,config_required_failed_runs_source, is the one exception to the division above: it holds within a single key —refinement_policy["failed-runs"]being"required"— and the schema could state it by giving that one property its own enum in place of the shared$defs/refinementPolicyValue$ref. It stays in code because agent-ops#924 requires the doctor’s own message to be the contract for it, and a schema violation reports the schema’s path rather than whyfailed-runscan never be refined; sharing one implementation withagent-cycle.shis what keeps that message from drifting. A seventh guard,config_duplicate_repos_slugs, stays in code for the same reason one step out: it holds between two entries ofrepos[]rather than between two keys of one object, which no array keyword the schema has can state either —uniqueItemsrejects only byte-identical whole entries, andreposcarries none in any case — so two entries sharing aslugwhile differing elsewhere leave the per-repo resolvers with no way to say which one’s overrides apply.agent-cycle.shrefuses to start on it, naming the duplicated slug(s), andscripts/doctor.shreports the same condition as afailthrough that one implementation, so those two cannot drift either (component 14 below;config_duplicate_repository_review_slugsis the same rule forrepository_review.repos, shared withreview-cycle.shinstead —docs/spec/review/requirements.mdrequirement R1b).An eighth guard,
config_provider_errors(issue #2131), stays in code for a reason none of the first seven share: it holds within one key,providers, but that key’s own entries are each named by the installation rather than drawn from a fixed set the schema’spropertiescould enumerate in advance — the same gapadditionalProperties: falseexists to close everywhere else, with nothing here for it to close against.config_provider_errorsrejects an unknown key inside one entry (onlysubstrate,credential_envandlanesare read), a missing or unsupportedsubstrate—lib/model-id.sh’sPROVIDER_SUBSTRATE_INSTALLEDnames the full enum,claude-codeandgrok-build— asubstrateofclaude-codenamed by any provider key butanthropic(D29, issue #2198: that substrate is Claude Code pointed at the provider’s own endpoint, which onlyanthropic— a Bedrock/Vertex credential route of it included, D4 — is entitled to do), and an explicit emptycredential_env. The same escape valve covers each lane nested inside alanesblock, for the gap one step further in — a lane’s own shape sits under a provider key the schema cannot enumerate, sopropertiescannot reach it either — and requirement 1a above states that block’s own faults in full.agent-cycle.shandreview-cycle.shboth refuse to start on it, andscripts/doctor.shreports the same condition as afailthrough that one implementation, so the three can never drift.
1c. The model-tier floor (agent-ops#822). Nothing before this requirement
stopped the cheapest model in the fleet from authoring a work order
specification (context/acceptance) that a more capable model then
implemented — #815 (fixed by #819) and #821 both trace to exactly this
gap. lib/model-id.sh’s MODEL_TIER_RANK is the ordering that makes
“cheaper” and “more capable” checkable rather than conventional: one
scale of capability bands spanning every provider (D31, issue #2445),
never a scale per provider — the fleet’s four currently configured
Claude model ids — claude-haiku-4-5-20251001 below claude-sonnet-5
below claude-opus-5 below claude-fable-5 — and, since issue #2134,
xAI’s own three Grok models placed on that same scale —
grok-build-0.1 below grok-4.3 below grok-4.7 — each keyed by its
fully-qualified id (anthropic/claude-sonnet-5, xai/grok-build-0.1,
resolve_model_qualified‘s own return shape, issue #2131) rather than
the bare one resolve_model_id returns. The ranks are spaced ten apart
so a later model can be placed between two existing bands without
renumbering any of them, and are the owner’s own judgement from public
evidence (D31) — Anthropic’s relative pricing happens to corroborate the
order of today’s four Claude ids, but pricing is not the ordering
principle and would not corroborate a second generation; xAI’s own
prices are not consulted at all. Two models placed in the same band tie,
and neither ranks below the other. A placement is revised only by a
dated decision-log entry on the scorecards’ evidence (D22), never by a
stage, and a model an installation judges differently is moved in its
own config.json’s model_tiers key (D29’s customer-control rule, issue
#2465) rather than by editing this table.
**The override (issue #2465).** `model_tiers` is a top-level`config.json` object, keyed by model id in the `modelId` shape (a bareid meaning `anthropic/`, as every other model key's shape does), valuedby an integer tier band >= 0 — the shape is declarative, stated by theschema's `propertyNames` (the `modelId` pattern) and `additionalProperties`(an integer schema, rather than the `false` a closed object of namedproperties carries) rather than the escape-valve code `providers`needs, since a model id's shape is fixed in advance the way aprovider's own chosen name is not. `lib/model-id.sh`'s `model_tiers_load`merges it over `MODEL_TIER_RANK` — an entry for a model already placedmoves it to the stated band, an entry for one the table does not knowplaces it, and nothing shipped is removed by omission — called at thesame five sites `providers_load` is (requirement 1a), immediately afterit, since each key's own provider must already be configured. Thatcheck is `resolve_model_qualified`'s own fail-fast check at cycle start,naming `model_tiers` as the key, exactly as an ordinary model key ischecked: a `model_tiers` key naming a provider `providers` does notconfigure, or one configured with a substrate this node has no adapterfor, is the identical error, aborting `agent-cycle.sh`/`review-cycle.sh`under `set -e`. The band is canonicalised on the way in: requirement 1b'sschema reads `integer` as "a number with nothing after the point", so`25.0` and `1e2` are valid bands JSON renders in a form bash arithmeticcannot evaluate, and `model_tiers_load` merges the plain decimal integereach denotes. A band it cannot render that way is refused by name — thesame kind of fault as a rejected qualifier — leaving the shipped bandstanding rather than merging a value `model_tier_below` can only swallowas a shell error while reporting the floor below clear on a comparison itnever made. `model_tiers_load` always resets `MODEL_TIER_RANK` to theshipped table first, so calling it more than once in one process nevercompounds a previous call's overrides, and a caller that never calls itreads the shipped table unchanged — the same convention `providers_load`already established for `anthropic`. `scripts/doctor.sh`'s "Models"section lists every override beside the band it shipped at (or "not onthe shipped ladder", for a model the table has never heard of), so aplacement that clears or trips the floor below is visible rather thansilent, and a model an override has placed is exempt from theunranked-model warning above; a band `model_tiers_load` refused is a`fail` there rather than a listing, since that command names aconfiguration's faults and carries on where both cycle scripts refuse tostart on them, and so is the one reader that reaches the report with aband the schema has already rejected. A placement's own band is still not carried bythe `--mix` lever (D30): `--mix` carries no threshold and never relaxes aguard, and a tier placement is configuration, rolled with the image likeany other.
`model_tier_rank`, `model_tier_known` and `model_tier_below` all take aqualified id and read the table by it; a model the table has never heardof (a future release, a typo the `modelId` pattern still accepts, or asecond provider's own model before its own tier is ever added here) ranksunknown rather than lowest or highest, and every check below treats"unknown" as "cannot verify" — never as "fails" or "passes" — so a modelnewer than this table cannot itself be rejected by it. `model_tier_below`compares two ranked ids' ranks directly, whether or not they name thesame provider — nothing in it reads either id's provider segment.`scripts/doctor.sh` warns separately (in its "Models" section) whenone of `coordinator_model`, `refiner_model`, `enabler_model`,`implementer_model_default`, `implementer_model_trivial` or`reviewer_model_default` is unranked, so an unranked model is neversilently invisible to the checks that use this table.
Two authors can write a work order's `context`/`acceptance` directlyrather than relay text a human, the Script, or a gatherer already wrote:the Refiner, writing `refined_spec` or an issue comment (requirement 39(The Refiner)),and the Enabler, writing the same when it settles a `needs-refinement`block (requirement 36b). **The floor**: `config_model_tier_floor_violations`(`lib/config-schema.sh`) rejects a configuration where `refiner_model` or`enabler_model` ranks strictly below `implementer_model_default` or`implementer_model_trivial` — either pairing means that author could writea specification for an Implementer more capable than itself, whether ornot the two name the same provider. Both `agent-cycle.sh` (a startupguard, fatal) and `scripts/doctor.sh` (`fail`) call the one function, soneither can drift from the other. An empty value on either side of apair is skipped (that stage, or that implementer tier, is simply not inplay), and so is a pair naming a model the table cannot rank — reportedinstead as `scripts/doctor.sh`'s unranked-model warning above, neversilently treated as clearing the floor. Each of the four arguments isnow a compact JSON array of qualified ids (`lib/model-id.sh`'s`model_key_qualified_ids`, issue #2247) rather than one each — a single-element array for a key no installation has turned into a weighted set,every member's own qualified id for one that has — so the check runsover every pair a set's members can produce with every pair on theother side, not just whichever member a single draw happened to pick:this runs once, at config-load time, well before any launch draws fromeither side. `coordinator_model` isdeliberately outside this comparison: requirement 39a (The Refiner)'s"Per-source refinement policy" is what keeps it from authoring aspecification for a source it must not — see the next paragraph —rather than a tier comparison the Co-Ordinator's whole reason forexisting (cheap triage) would otherwise make impossible to satisfy.
Today's shipped configuration holds `refiner_model` and`implementer_model_default` at the **same** tier (`claude-sonnet-5` forboth) — the floor permits this deliberately, and the reasoning isrecorded here rather than left implicit: writing a specification demandsno more capability than implementing it does, so equal tier issufficient, and only a rank strictly *below* either implementer tier isever rejected. `enabler_model` sits a further tier above(`claude-opus-5`), for the harder judgement calls requirement 36b'srefinement duty can involve.
**Closing the gap on the sources that can still reach an Implementerunrefined.** `refinement_policy` (requirement 39a (The Refiner)) is what actually keepsa cheap model's own composition out of a work order for a given source:`"required"` never selects an unrefined item from that source, so its`context`/`acceptance` can only ever have come from the Refiner or theEnabler — both held to the floor above — never from `coordinator_model`composing one itself. `project-review` and `implementation-plan` are thetwo remaining sources whose items can carry a specification`coordinator_model` composed from ambiguous material rather than onealready fully written elsewhere — every other source `refinement_policy`can name is `exempt` by default for exactly that reason, and stays so.An installation that runs no Refiner cannot safely set either to`"required"` — see the next paragraph — and is left, by the shipped`"preferred"` default, exactly as exposed to `coordinator_model`authorship as before this requirement for those two sources alone; everyother source remains `exempt` and therefore Script- or gatherer-composed,never model-authored, with nothing here to validate because there isnothing here that can go wrong.
`issues` and `tech-debt` used to belong in the list above — a`coordinator_model` composing `context`/`acceptance` for either from anissue thread's current state or a tech-debt row's own body was exactlythe ambiguous-material gap this requirement exists to close, and theschema's own shipped default still names both `"preferred"`(`config.schema.json`'s `refinement_policy.default`), with thisinstallation's `config.json` setting both to `"required"` outright.Requirement 17h (agent-ops#769) has since closed that gap structurallyrather than through `refinement_policy` alone: the Script composes`context`/`acceptance` for every `issues`/`tech-debt` candidate itself,from a live read, regardless of the item's refinement state — so`coordinator_model` cannot author either field for these two sources atall any more, whatever `refinement_policy` says about them.`refinement_policy`'s `"required"`/`"preferred"` distinction still governswhether an *unrefined* `issues`/`tech-debt` item may be selected in thefirst place (requirement 39a (The Refiner)) — that judgement is unchanged — but nolonger decides who authors its work order text once selected.
**Resolving `refiner_model`'s optionality.** A `"required"` policy with noRefiner to ever refine anything is a configuration nobody can act on:`prompts/coordinator.md`'s "Per-source refinement policy" never selectsan unrefined item from a `"required"` source, and requirement 39 (TheRefiner)'s own gate on `refiner_model` being set means nothing ever refines one either —the source's items would simply wait forever. Three spellings reach thatstate, and the fleet's own decision on the first tech-debt item thisinvariant's own gap was filed against (TD-PPagop-26082704, agent-ops#1003)splits them into two consequences:
- An empty `refiner_model` with any source resolved to `"required"` — `config_required_refinement_sources_without_refiner` (`lib/config-schema.sh`) rejects this outright, checked by the same two callers as the floor above.- `failed-runs` resolved to `"required"`, whatever `refiner_model` or `refiner_max_per_engagement` are — it is the one source with no candidate array at all for the Refiner's own candidate gathering to ever reach (`prompts/coordinator.md`'s "Per-source refinement policy"), so a `"required"` policy on it is unsatisfiable by construction. `config_required_failed_runs_source` rejects this outright too, the same refuse class as the case above.- `refiner_max_per_engagement: 0` with `refiner_model` set and a source resolved to `"required"` — `refiner_engagement_set` (`lib/refinement.sh`) slices every engagement's candidates to none, so nothing is ever refined even though the Refiner itself is configured. Unlike the two cases above, this is not a configuration nobody could ever satisfy: `0` is documented behaviour, a deliberate and temporary pause of a stage that still exists, and working down an already-refined backlog before specifying more is coherent. `agent-cycle.sh` and `scripts/doctor.sh` therefore *warn* rather than refuse — every cycle the condition holds, never only once, so it cannot age out of the dashboard's window the way a once-only warning would — `config_refinement_sources_paused_by_cap` computes the set warned about. The condition is read with the rest of the configuration, ahead of the log existing at all, and the `warning` event is emitted once logging is initialised; a management command (requirement 2.3's `--status` and its siblings) runs no cycle and emits none, so no operator poll can mint a cycle id carrying an event but no `cycle-start`. Auto-degrading the source's own policy to `"preferred"` was considered and rejected: what runs must be what the config says.
`refiner_model` therefore stays optional in the schema (a fresh installwith every default in force sets neither key, and clears every checkabove trivially — `refinement_policy` defaults to `"preferred"` on thetwo sources that carry one at all), but an installation that opts asource into `"required"` — as this one has for `issues` and `tech-debt`— is rejected outright unless it also runs a Refiner, and unless thatsource is not `failed-runs`; setting `refiner_max_per_engagement: 0`afterwards does not then need every `"required"` policy flipped back too— it only warns.
**Escalating a wrong-but-implementable specification does not need afresh mechanism.** A Refiner-authored (or Enabler-authored) specificationthat is technically actionable but wrong already has a route to ahigher-tier read without waiting on a multi-cycle block-and-age cycle:the Implementer that receives it can itself report `"needs-refinement"`(its own "Ending" contract), which is exactly the block that makes theitem Enabler-eligible (requirement 35a) — and `refinement_after_coordinator_cycles`(config, minimum `0`) already controls how many further Co-Ordinatorcycles that eligibility waits on, independently of`enabler_after_coordinator_cycles`. An installation that wants awrong-but-implementable specification reaching `enabler_model` (a highertier than either the Refiner or the Co-Ordinator, per the floor above) asfast as this system allows sets `refinement_after_coordinator_cycles: 0`rather than needing a second escalation channel built beside the one`needs-refinement` already is — a block is still required (one signalthat something is wrong), but no *wait* is, which is the reading of"without requiring the item to have visibly blocked first" thisrequirement satisfies.
`test/config-schema.test.sh` asserts both `agent-cycle.sh` and`scripts/doctor.sh` refuse a configuration violating the floor, including`refiner_model` ranked below `implementer_model_default`, and refuse a`"required"` source with `refiner_model` empty.1d. Every timing sized against a once-an-hour cycle derives from the
configured cadence instead, or states plainly that it does not. Before
this requirement, schedule.cycle_interval_minutes (issue #248,
“faster heartbeat”) let an installation run its implementation cycle far
more often than once an hour, but a handful of timings whose intent was
always “a few cycles” stayed literal numbers of hours chosen when a cycle
and an hour were the same thing: raised at 15-minute cadence, “far beyond a
whole cycle” became 24 cycles rather than 6, and “beyond a whole cycle, so
a draft merely being worked never qualifies” stopped bounding what it was
supposed to. A stale-but-live claim, held four times longer than the
installation’s own cadence would suggest, and a no-op safety valve that
waits four times as many skipped cycles as intended are both silent —
neither refuses to start, neither logs a warning — so nothing short of
this audit would have surfaced either.
config_defaults (requirement 1b) is where the fix lives, as a
post-fill derivation over the same merged object every one of its
callers already reads — no reader needed to change. It resolves two
gaps between cycles, both in minutes, from the already-defaulted
schedule block, and the three shapes of key below take one each — the
first the worst-case gap, the second and third the mean.
The worst-case gap — the longest an installation can go between two
firings, which is what a threshold that must outlast a quiet stretch is
sized against: cycle_hours (a cron hour field — *, */N, a-b,
a-b/N and plain numbers, comma-combined) contributes the longest run of
consecutive disallowed hours, circularly, times 60; cycle_interval_minutes
and excluded_minutes contribute the widest gap between two kept firings
within an allowed hour, measured from the earliest minute
excluded_minutes leaves standing (a representative case, not a worst
case over every minute a node’s own cadence hash could land on — worst-
casing that collapses the derivation to a fixed ~60 minutes regardless of
cycle_interval_minutes, since a base minute chosen late in the hour can
genuinely produce only one firing that hour under
deploy/docker/render-crontab.sh’s own restart-at-the-base-minute-each-hour
loop). The two sum:
an installation whose cycle_hours restricts operation to business hours
has a worst gap measured in hours regardless of how tight its
cycle_interval_minutes is within them — the implementation note this
requirement was built from names the failure a derivation blind to
cycle_hours would risk: a claim_ttl_hours sized to the bare interval
expiring a live node’s claim overnight.
The mean gap — a day divided by the number of firings in it, which is
what a count of firings elapsed is sized against, whether the key spells
that count as a number of retained cycle directories or as an hour figure
that is really “N firings” in disguise: every
allowed hour repeats the identical kept-minute pattern, so the firings are
the allowed hours times the kept minutes within one, and the mean gap is
1440 / firings_per_day. It equals the worst-case gap for any
installation that has restricted neither cycle_hours nor
excluded_minutes, and only where they part company does the distinction
bite — see the second and third shapes of key below for why the worst-case
gap is the wrong denominator there.
The derivation validates none of the three schedule leaves it reads,
because config_defaults validates nothing (requirement 1b): a
wrong-typed or unparseable one degrades to the historical hourly
assumption, under which both gaps are 60 minutes — so neither gap moves
any of the seven derived keys from the flat figure each already carried
before this requirement, whichever of the two it takes — rather than
raising an error that would abandon the
merge and hand every caller an empty configuration. scripts/doctor.sh is
why that distinction matters: the tool whose job is to report exactly such
a violation reads a defaulted config to do it, so the derivation must
survive the configurations it is run to diagnose.
Three shapes of key are re-expressed against these gaps, each keeping the
key’s name, type and unit unchanged — this is a derivation, not the
breaking rename a claim_ttl_cycles would be. Which shape a key takes
follows what it is actually sized against, not its unit: an hour-valued
key can take either gap, and two of the four do.
-
A stretch that must be outlasted, expressed in hours, against the worst-case gap:
claim_ttl_hours(6 cycles) andabandoned_draft_after_hours(4 cycles) each bound a live claim or a draft still being worked, and outlasting the longest possible gap is the whole of their intent — the worst-case gap is what a threshold with that job is sized against (see above). Both also carry the second, runtime floor described below. -
A count of firings elapsed, expressed in hours, against the mean gap:
disable_default_ttl(4 cycles) andnone_selected_recheck_hours(24 cycles) each carried an hour figure that was really “N cycles” measured back when a cycle was an hour — but the cycles they count are firings elapsed (a few cycles of--disable, a day’s worth of skippednone-selectedruns), the same quantity a count-valued key below counts in cycle directories, so each is sized against the mean gap for the identical reason: a quantity that accrues at the installation’s throughput follows how often it fires, not how long its longest quiet stretch is. Sizing either against the worst-case gap would starve its own documented bound the same way the count-valued keys below would be starved by it — see their own bullet for the “9-17” example, which applies here unchanged: 36 firings a day derives 3 and 16 respectively, where the worst-case gap’s 915 minutes would derive 61 and 366 — adisable_default_ttloutlasting the weekend, and anone_selected_recheck_hoursthat can stall the pipeline for a fortnight rather than the day requirement 3b documents.All four keys across both bullets above are bash integer arithmetic on the read side (
lib/claim.sh’s$(( claim_ttl_hours * 3600 )),scripts/sweep-orphan-branches.sh’s^[0-9]+$guard), never a float, and widening that contract is outside this requirement’s scope. Absent, each isN * gap_minutes / 60against its own gap, rounded up to a whole hour.none_selected_recheck_hoursalone carries a “0 disables the valve” convention (minimum: 0, notexclusiveMinimum); an explicit 0 stays exactly 0, never raised by the derivation, or a deliberate “don’t” would silently turn back on under a fast enough cadence. -
A span of wall-clock history, expressed in cycle directories, against the mean gap:
cycles_retained(200),state_local_cycles_retained(1000) andstate_local_streams_retained(50) each bounded roughly how many days of history a fleet running hourly kept, not literally that many cycle directories. Absent, each is nowceil(N * 60 / mean_gap_minutes), preserving the same wall-clock span (~8.3 days, ~41.7 days and ~2.1 days respectively) as the gap between cycles moves, rather than letting a faster cadence quietly shrink the retained window fourfold the way a flat count already had. Against the mean gap, not the worst-case oneclaim_ttl_hoursandabandoned_draft_after_hourstake: a cycle directory is written per firing, so how many of them a span holds follows how often this installation fires, not how long its longest quiet stretch is. The two coincide unlesscycle_hoursdisallows an hour orexcluded_minutesdrops a reachable occurrence, and where they part company only the mean preserves the window: a9-17installation firing every 15 minutes fires 36 times a day (a mean gap of 40 minutes) and so keeps 300 cycle directories, where the worst-case gap of 915 minutes would keep 14 — about three hours of history in place of eight days, and fewer than the flat 200 this derivation replaced.state_local_streams_retainedalone takes a configured value as configured — a cap as well as a floor (agent-ops#1826; the design decision “A configuredstate_local_streams_retainedis a cap as well as a floor” records why). It is the one key of the three that bounds files of a different order of size from the records holding them, and a host whose disk cannot hold the derived count has to be able to say so. The value passed on is a whole number of at least 1 — an integral float the schema admits (20.0) is floored, and 0 or below falls through to the derivation — soscripts/state-sync.sh‘s integer arithmetic never meets a literal it cannot read. The other two keep the floor-only shape, because a value below their derivation could only shorten the record.config.jsonis built into the image every node runs, so a value configured here applies to the whole fleet;STATE_SYNC_STREAMS_RETAINED, whichdeploy/docker/compose.yamlforwards to the scheduler from a node’s.env, sets the count for that node ahead of the key, so an installation whose nodes’ disks differ sizes each on its own (requirement 2.5 has the variable’s own rules).crash_loop_afteris the fourth key issue #591’s audit considered under this same “counted in cycles already” heading and decided against deriving: its four carries the count of consecutive failures before a crash-loop escalation fires, which is the whole of its intent — time-to-escalation falling as the cadence speeds up is the point of a faster cadence, not a defect in the count, so it keeps its plain schema default and moves on the operator’s own terms.
claim_ttl_hours and abandoned_draft_after_hours carry a second
floor beyond the cadence one. Both bound a cycle’s own worst-case
runtime, not only the gap between cycle starts — lib/claim.sh’s
do_gc sweeps a claim-registry entry (and, with it, the claim branch,
while it is still untouched and PR-less) once claim_ttl_hours has
passed, and scripts/gather-abandoned-drafts.sh’s own candidacy race
presumes the claim it races against has not already been swept, which
needs claim_ttl_hours at least as wide as abandoned_draft_after_hours
too. At a fast enough cadence the cadence term alone can undershoot that:
6 cadence firings at 15 minutes is 90 minutes, well under the shipped
Implementer backstop alone (150 minutes, lib/stage-budget.sh‘s
STAGE_BUDGET_PRIORS), and a cycle whose Implementer has not pushed by
then would have its claim branch swept by another node’s do_gc while it
is still being worked. So each of these two keys’ hour_key result is
additionally floored at requirement 4f’s own lock_stale_after quantity
(stage_budget_lock_seconds) — the same shape as the cadence floor
above, raised, never lowered. Computed from STAGE_BUDGET_PRIORS and
this configuration’s own actor overrides (stage_budget_all_overrides)
alone, with an empty budget table rather than the fleet’s own learned
per-(actor, repository, model) history: config_defaults remains a
function of config_file and schema_file alone (no reader needing an
event log to compute its own defaults), and this is the same
conservative, no-history baseline a fresh installation’s
scripts/doctor.sh and scripts/publish-dashboard.sh already fall back
on before any cycle has run, applied here unconditionally rather than
only until the first one has. disable_default_ttl and
none_selected_recheck_hours bound no in-flight claim or draft, so
neither carries this second floor.
The three count-valued keys’ resulting volumes, at the shipped
15-minute cadence (cycles_retained 200 → 800,
state_local_cycles_retained 1000 → 4000, state_local_streams_retained
50 → 200, all fourfold since gap_minutes falls from the historical 60
to 15; TD-PPagop-26082830): state_local_streams_retained is the one
worth quantifying rather than only ratioed, since it alone bounds files
large enough to matter. A cycle directory without its derived files is
kilobytes and a stage stream megabytes, so 200 retained cycles’ streams
are low hundreds of megabytes on a busy repository, against
cycles_retained’s and state_local_cycles_retained’s tens of megabytes
each — inside min_free_workspace_bytes‘s 2 GiB pre-clone floor (2.0c),
the one check any of these three keys’ derivation could trip. The
fleet-log snapshot is the file of a different order: measured on both
poetic nodes on 2026-09-18 (agent-ops#1678), 200 retained snapshots ran
45 MB apiece and 7.3–7.4 GB per node, regrowing at about 4.3 GB per node
per day, and each is larger the longer the fleet’s log.jsonl runs.
That is why a snapshot does not stay to be counted at all: the cycle or
review that wrote it removes it when it ends (requirement 2.5), and this
count meets a snapshot only where a run died before its own cleanup.
Both shapes share lock_stale_after’s own contract (requirement 4f),
with the one exception the count-valued bullet above names: a
configured value is a floor under the derivation, never a ceiling. An
operator’s explicit hours or cycle count can still be raised by the
derivation — the overnight-expiry failure above, guarded against even for
a value someone set by hand — but the derivation can never lower what was
explicitly configured; state_local_streams_retained alone is taken as
configured in both directions. Absent entirely, the derivation is the whole
answer, which is why each of these seven keys now carries no schema
default of its own (x-docs.value renders *(unset)*, the same
convention lock_stale_after already uses) — a literal default here would
be merged in by the generic fill above, read back as an explicit override,
and win permanently, leaving the derivation unreachable, exactly the
reasoning 1b’s own closing paragraph already gives for why the two
self-tuning $defs carry none.
Already independent, confirmed rather than changed. lock_stale_after
and repository_review.lock_stale_after are each already a floor under a
value derived from the stage backstops in force (requirement 4f) — a
cycle’s own worst-case runtime, not the scheduling interval between cycle
starts, is what a stuck lock has to outlast, and the two quantities are
independent by construction. The usage-limit stand-down probe (2.1b)
already runs once per cycle however often that is, so it follows
cycle_interval_minutes mechanically and needed no change. The roadmap’s
“lock staleness” candidate (docs/ROADMAP.md Phase 1, D7) is this
paragraph’s answer: already correct, not a fourth case for the table
above.
Independent by design, and each says so on its own schema entry.
enabler_recheck_hours, human_nudge_idle_hours,
merge_queue_dequeue_notice_max_age_hours and void_retire_after_days
measure human-world time — how long before a person is expected to have
looked at something — which does not shrink because the pipeline itself
runs more often. limit_escalate_after_hours and lib/limit-detect.sh’s
LIMIT_LONG_COOLDOWN_HOURS are bounded by the account provider’s own reset
clock, not this installation’s cadence. image_behind_grace_hours bounds
how long a node may run behind a published image mid-roll, a property of
the deploy pipeline, not the cycle cadence. stage_budget.window_days and
window_runs are a statistical window over runs, which a faster cadence
fills with more data without changing what the window means.
schedule.heartbeat_minutes, state_sync_push_minutes,
state_sync_fetch_minutes, log_rotation_minute, doctor_offset_minutes
and review_offset_minutes each have their own crontab line in
deploy/docker/crontab.tmpl and run hourly or sub-hourly on their own
terms, independent of the implementation cycle’s. log_retained_bytes
triggers rotation on size, which self-corrects regardless of how often
the log is written to.
52. The table of contents is generated from headings, not hand-maintained,
and regenerating it is gated in CI. Each guide under docs/guides/
carries a <!-- toc:start --> … <!-- toc:end --> region, placed
immediately after the document’s title (and any lead-in paragraph,
before its first ## heading), holding a nested bullet list of every
##/### heading in the document — the same “generated, never
hand-edited” contract AGENTS.md’s “Generated regions” note states for the
configuration tables (requirement 1b, component 16), for a second kind of
region. docs/spec/implementation/README.md and
docs/spec/dashboard/README.md carry the same marker pair, but hold a
directory-wide list instead — one entry per sibling file under their own
directory, linking each sibling’s own first heading, rather than headings
within the README itself. scripts/render-toc.sh (component 24) renders
both kinds, from lib/markdown-scan.sh’s TOC_FILES (the own-heading
kind) and TOC_DIR_FILES (the directory-wide kind): for the own-heading
kind, extracting headings in document order while
skipping fenced code blocks (lib/markdown-scan.sh, the one fence-aware
reading it shares with requirement 52a), slugging each to GitHub’s own heading-anchor
algorithm — lower-cased, stripped to [a-z0-9_-] and space, spaces to
-, with no further collapsing of consecutive hyphens, since GitHub’s
own algorithm does not collapse them either — and de-duplicating repeated
slugs across the whole document the way GitHub’s own renderer does (the
first occurrence keeps the bare slug, each later one is suffixed -1,
-2, …), so every generated link resolves to a real in-document anchor.
Before rendering, each target file is checked for exactly one
<!-- toc:start --> / <!-- toc:end --> marker pair with the start
marker on an earlier line than the end marker; a file with neither
marker, only one of the pair, more than one of either, or the pair in
reversed order, is refused — in both the plain and --check
invocations — naming the file, rather than copied through unchanged
(or, for the reversed case, silently corrupted), which would otherwise
leave a missing or unpaired region undetected. .github/workflows/toc.yml runs
scripts/render-toc.sh --check on every pull request, failing it the
moment a heading is added, removed or reworded without a matching
regeneration, or a target file’s marker pair is missing or malformed.
52a. The documentation is measured against a fixed benchmark of real
questions, not asserted to be good, and the benchmark is never run by the
pipeline. test/docs-benchmark/questions.jsonl holds at least 48
questions, at least eight for each of six readers (target-user,
operator, evaluator, contributor, cycle-agent and
output-reader), each with a gold answer, the sources that state it and
the facts a correct answer must contain. Every source names a file and a
heading of it, a label inside its ## Requirements section, or a label
inside its ## Acceptance checks section, outside fenced code, and every
backticked token of a required fact appears in its gold answer. The
sources are checked on every pull request, because the change that moves
one is usually documentation-only. scripts/docs-benchmark.sh (component
24a) asks each question of claude -p in a plain directory holding a
ref’s files, with no .git and no path named *docs-benchmark*, with a
fixed model at a fixed effort, only the Read, Grep and Glob tools, project
settings only and the environment variables that change the model’s
behaviour cleared, and has a separate call grade each answer fact by
fact. It records the answer, the grade with the grader’s reasoning, the
tool calls, the tokens and the wall time, and writes a dated report under
docs/reviews/. The definitions that decide what a run’s figures mean
are named as the protocol in lib/docs-benchmark.sh and hashed; every
report records that hash, a hash of what a run reads of the questions,
and the Claude Code version, and two reports are comparable when all
three match. No stage, workflow or crontab entry runs the benchmark
itself: a stage that launched claude would be an agent launching an
agent (see “Actors”), and every run spends tokens.
52b. The documentation’s links, map, size budget, section citations and
as-built phrasing are checked offline on every pull request.
scripts/check-docs.sh (component 24b) makes five checks over every
tracked Markdown file bar the fixtures test/check-docs.test.sh builds to
break them and the frozen tech-debt/ archive, printing one line per
violation and exiting non-zero if any check failed. Every relative
Markdown link, and every x-docs link in config.schema.json, resolves
to a path that exists, and a #fragment on one matches either a heading
of the target — slugged by lib/markdown-scan.sh’s gh_slug, the one
GitHub anchor-slug formula shared with requirement 52’s table of contents,
so the fragment this accepts and the anchor that generates cannot
disagree — or an explicit <a id="…">/<a name="…"> anchor in it, which
GitHub resolves a fragment against just as readily and which a
heading-only reading would call broken. Every in-scope document is named
in docs/README.md’s “All documents” map, one row per file except a dated
docs/reviews/project-review-*/ directory, which takes one entry for the
whole directory, and every path that map names exists. No in-scope
document’s hand-written content — its bytes outside the generated regions
lib/markdown-scan.sh lists, the configuration tables of requirement 1b,
the tables of contents of requirement 52, the labels table and scripts
index of requirement 52d and the regions the organisation’s sync stamps,
which a schema change, a new heading, a catalogue or header-comment
change, or a re-stamp regenerates
— exceeds the 100,000-byte budget docs/README.md’s “Size budget” section
fixed, unless the document is exempt there (CHANGELOG.md,
docs/ROADMAP.md, docs/reviews/**, and every as-built specification,
docs/*-SPEC.md with its * inside one path segment, which AGENTS.md’s
“As-built specifications” section requires to grow) or carries an entry in
scripts/docs-size-ratchet.tsv naming the byte count it may not grow past
and the issue that will bring it under budget. A marker pair in a file, or
with an id or fragment, that the library does not list holds hand-written
bytes, as does a region that never reaches its own end marker, so only what
a renderer rewrites leaves the measure. An entry for a document that is
missing, exempt or within the budget fails, as does an exemption that
matches no document, so neither list outlives what it describes. A quoted
section citation,
in any of the three forms docs/README.md’s “How sections are cited”
section and this repository’s prose use, names a heading of the file it
cites or text that still exists in it — checked in documents, prompts,
scripts and workflows alike, but never inside a frozen record, whose
citations were true when it was filed and which is never edited
afterwards. And the count of the five historical-sounding phrases
scripts/docs-phrasing-ratchet.tsv’s own header lists stays at or below
that file’s entry for each as-built document: a ratchet, not a ban, since
the standing decision of 2026-09-04 (#1154) allows a historical aside that
passes the deletion test. Both ratchet files are inventories of what is
over the line today, the exemptions aside, never a place to buy slack by
raising a limit.
The whole check runs offline, reading no network, so an external link is
out of scope by design — as are spelling, grammar and requirement-label
citations, which issue #2095 covers instead.
.github/workflows/docs.yml runs scripts/check-docs.sh --check on every
pull request, on merge_group and on push to main, ungated by paths:
— a renamed heading, a moved file or a new citation anywhere in the tree
can break any of the five.
52c. Every requirement, acceptance-check and component label across
docs/spec/implementation/, docs/spec/review/ and docs/spec/monitor.md
is unique within its own (specification, sequence) pair, and every
citation of one resolves to that same kind. scripts/spec.sh check
(component 24c) scans every anchored <a id="…"> label in those three
specifications and fails on a duplicate within the same pair. It then
scans every tracked file — except CHANGELOG.md, docs/ROADMAP.md,
docs/STANDING-DECISIONS.md, the frozen tech-debt/ archive,
docs/reviews/, test/fixtures/, and scripts/spec.sh,
test/spec.test.sh and scripts/spec-check-ratchet.tsv themselves,
whose own labels are examples of the citation grammar rather than
citations of anything — for a requirement-label citation in either the
English phrasing (requirement 17a, acceptance check 1g,
component 14b) or the qualified form docs/README.md‘s
“Requirement-label citations” section defines (IMPL 17a, IMPL AC 1g,
IMPL C 14b, REV R5, REV AC 5, REV C 5, MON M4, MON AC 4,
MON C 4), and fails on one that dangles or names the wrong one of the
three sequences — a label cited as a requirement that is really an
acceptance check, for instance. A dotted sub-label (requirement 2.5) is skipped
rather than mismatched against its truncated integer part (agent-ops#2521),
and a hyphenated sub-item label is truncated to its parent rather than
checked in full (agent-ops#2544) — both open gaps, not silent passes this
requirement claims to cover. A known violation may be carried in
scripts/spec-check-ratchet.tsv (label, file, line, issue),
matched only at the exact file and line it names, so a ratchet entry
cannot silently widen to mask a new violation of the same label
elsewhere; an entry is removed by hand once its citation is fixed.
scripts/spec.sh show <label> and scripts/spec.sh where <label>
resolve the same grammar for a human or an agent looking a label up
instead of opening and searching the spec file by hand, and
scripts/spec.sh index renders the committed docs/spec/index.json
every lookup and every check run reads from — scripts/spec.sh index --check fails if the committed file is stale against the specs’ own
current anchors. .github/workflows/spec.yml runs scripts/spec.sh check and scripts/spec.sh index --check on every pull request, on
merge_group and on push to main, ungated by paths: — a citation can
be added or broken from any file in the repository. Acceptance check 52c.
52d. The labels reference and the scripts index are generated from the
code they describe, not hand-maintained, and regenerating each is gated
in CI. docs/reference/labels.md carries a <!-- labels-table:start -->
… <!-- labels-table:end --> region holding one row per label the
pipeline creates or reads, and docs/reference/scripts.md a
<!-- scripts-index:start --> … <!-- scripts-index:end --> region
holding one row per script under lib/ and scripts/ — a fourth and a
fifth kind of generated region, under the same “generated, never
hand-edited” contract AGENTS.md’s “Generated regions” note states for
the configuration tables (requirement 1b, component 16) and the tables of
contents (requirement 52, component 24).
scripts/render-labels-table.sh (component 24d) builds its region from
lib/labels.sh’s own labels_catalogue (requirement 6a, component 15),
called once for each of the three roles a repository can hold and unioned
by label name, so a label two roles share appears once; the two
pr_label keys the catalogue cannot resolve on its own — both required,
with no product default — are supplied from their own schema
x-docs.value, the same documented example requirement 1b’s tables
render. The catalogue carries a label’s name, colour and description and
nothing else, so what applies a label and what removing it does come from
that script’s own hand-authored metadata, keyed on the catalogue’s
resolved name; a catalogue label with no metadata entry fails the render
naming the label, rather than rendering a blank cell, so the metadata
cannot silently fall behind the catalogue.
scripts/render-scripts-index.sh (component 24e) builds its region from
each script’s own header comment — the first paragraph after the shebang,
wrapped lines joined with a single space except where the wrap fell inside
a token at its own ASCII hyphen or underscore, which rejoins with nothing
so a row prints the token rather than a word cut in half, a leading
# shellcheck disable= paragraph skipped in favour of the one after it,
and the lead-in naming the script’s own path or basename stripped — grouped by the one
distinction this repository already enforces structurally: lib/, sourced
and never executed, and scripts/, run directly. A script with no such
paragraph fails the render naming the file, so a script cannot be added
without a header comment to index it by. Both renderers read the files
they write and the markers that delimit them from lib/markdown-scan.sh’s
LABELS_TABLE_FILES/SCRIPTS_INDEX_FILES and its
labels_table_start_re/scripts_index_start_re marker-regex pairs — the
same list component 24b reads to leave these two regions out of the size
budget — and both follow component 16’s contract exactly: with no
arguments they regenerate in place, --check renders to a temporary file
instead and exits non-zero naming the stale file, and a target file
without exactly one marker pair is refused naming the file, in both
invocations, rather than copied through unchanged.
.github/workflows/labels-table.yml and
.github/workflows/scripts-index.yml each run their own --check on
every pull request, on merge_group and on push to main, ungated by
paths: — a catalogue edit, a script added, renamed or removed, and a
header comment reworded all drift a region from a file outside any narrow
path filter. Acceptance check 52d.