Run Lifecycle
How runs.status and runs.gate_status move through creation, dispatch, finalization, cancellation, and terminal outcomes.
Notes
run createpublishes a verified immutable plan while the run iscreating. Admission seeds compact execution metadata and checks exact local membership. One control transaction publishes routes/cursors and changes a fully admitted run topending.--prepare-onlyholds a ready plan without execution intent. Repeating the command without that flag requests admission. Coordinators recover requested ready plans after lease release or expiry. See Run Preparation.- Coordinator dispatch claims an open
run_id + run_shardcursor, marks a newpendingrun asrunning, selects a bounded shard-local chunk window, and inserts onerun.chunk.readyoutbox event record per selected chunk. - Before dispatch and finalization, the coordinator recovers expired worker chunk leases or marks exhausted chunks failed.
- Finalization requires drained dispatch cursors and the exact routed set of sealed shard summaries. Evaluation failure leaves a shard
runningwhile any planned chunk remains unsettled, including retry waits. - Finalization verifies run, shard, policy, and planned membership identities; merges the sealed scorecards; and commits the report, gate, and completion event under the current coordinator lease. Missing or invalid candidates are deferred while other candidates continue.
- Cancellation applies to
creating,pending,running, andfinalizing. It records durable revocation before placement delivery and waits for quiescence before terminal cleanup. - Execution permission (
enabled,paused,revoked) is separate from lifecycle status. Revision-fenced delivery and existing worker heartbeats enforce changes; pause does not discard completed results. Partial creation installs closed local admission tombstones, fencing delayed seed writes. Shared immutable files and committed result evidence remain.
Settlement and partial results
Evaluation outcome, work settlement, and result completeness are separate facts.
A failed evaluation does not cancel healthy work. Each terminal chunk transaction
locks that chunk, retires unfinished attempt authority, and commits an immutable
run_chunk_settlements receipt. Successful committed results remain scored;
unfinished or superseded attempt artifacts remain available as evidence.
Coordinators publish progress from available receipts, including receipts after a
slow earlier chunk. planned_chunk_count and settled_chunk_count describe work;
missing_execution_count counts planned cases without execution rows in settled
chunks; unresolved_execution_count counts existing executions without an
authoritative terminal aggregate. These missing counts exclude still-open chunks.
missing_aggregate_count retains its execution-status meaning. Progress can lag
worker commits and is provisional until every shard is sealed.
A page contains at most 256 receipts without configured scorecard gates, or 64 with gates. Both folds limit each page to 4 MiB of receipt JSON; each receipt is limited to 1 MiB. A nonblocking transaction-scoped PostgreSQL advisory claim owns one page. Counters and receipt-consumption identities commit together, so a crash rolls back both and releases the claim. Workers do not acquire this claim or wait for aggregation. Independent coordinator progress work runs before finalization, with separate page, scheduling-time, and concurrency budgets.
The coordinator selects shards with pending receipts or a canonical fold ready to advance. Open shards without pending receipts wait for durable work without opening aggregation transactions. Successful checkpoints rotate productive shards; busy or invalid candidates also rotate so other ready shards can proceed. Shards with remaining pending receipts or canonical work can advance further pages in the same cycle through fair rounds, while independent shards and databases use bounded concurrency. The progress query reads one extra pending identity to detect remaining work without another query: at most 257 identities without gates or 65 with gates. Receipt JSON still obeys the 256/64-row and 4 MiB page limits. When other planned chunks remain open, a page that consumes all available receipts waits for another discovery; later receipt commits remain durable pending work. Once every planned receipt is accounted for, canonical verification can continue within the same pass. Each page obtains its own claim and revalidates local ownership. This scheduling includes runs with open dispatch and cancelled runs. Finalization reads the published shard summaries in one batch per execution database.
Once all receipts are accounted for, another resumable fold reads them in planned ordinal/ID order. This makes final floating-point scores independent of arrival order and page boundaries. The fold validates exact chunk membership against the frozen hash and count before sealing an immutable summary. Scorecard denominators come from retained planned case/profile membership, including missing eligible cases in dimension, binding, group, and tag gates. Missing work contributes no invented numeric score, evaluator error, or abstention.
A run with 900 valid results out of 1,000 planned cases can complete after all
chunks settle, preserving the 900 results and reporting 100 missing executions.
Its coverage_complete is false and its release gate fails. Completion does not
require fabricated execution rows.
Every run freezes its settlement plan during creation. Aggregation and finalization reject missing or changed plans; terminal status alone never proves settlement.
Settlement preserves committed evidence. It cannot recover outcomes that existed only in a crashed worker's memory, verify a permanently unavailable placement, or guarantee that every retry is eventually awakened. Retry wakeups, heartbeat cleanup, draining recovery, and resumable cancellation remain separate recovery concerns; unavailable shards keep finalization pending.