Skip to content

Latest commit

 

History

History
138 lines (103 loc) · 6.46 KB

backstop.md

File metadata and controls

138 lines (103 loc) · 6.46 KB

backstop.sh

Revision: 1 Last modified: 2026-12-04T19:00:00Z

Overview

backstop.sh is the fastcycle slow-but-always-complete lane, plus two smaller jobs that belong to the same "hold the line" role.

The fast lane is fast because it selects: it runs only the gates that a change appears to affect, and reuses cached verdicts. Selection and caching are both places where a gate can be missed. The backstop exists to find exactly those misses. Its definition, from plan.md T-C10:

runs the full gate set and full mutation corpus with --no-cache and no selection: before every release tag, nightly when the fast lane ran that day, and on any change to the gate engine, I/O map or key definition; any verdict the full lane produces and the fast lane missed is a drift: release blocker, the offending gate marked force-full until re-traced.

Three subcommands:

Subcommand What it does
run Executes every gate uncached and with no narrowing — the ground truth.
compare Diffs the fast verdicts against the full verdicts and classifies drift.
freshness-queue Drains the §11.4.226 guard-freshness queue: registered guards that have never run against the current artifact.

Run compare after run on every release candidate. A drift is a release blocker, not a warning.

Prerequisites

  • sh, python3 (all three subcommands require it; absent → exit 2).
  • lib/backstop_run.py, lib/backstop_compare.py and lib/backstop_freshness.py beside it.
  • gate_runner.sh for the actual execution.
  • A gate manifest JSON enumerating the gates for run.
  • No environment variables are read directly.

Usage examples

# 1. full uncached lane — every gate, no selection, no cache
sh scripts/fastcycle/gates/backstop.sh run \
  --config gate_config.json --manifest gates.json --no-cache \
  --out full_verdicts.json --jobs 4

# 2. drift comparison against the fast lane's verdicts
sh scripts/fastcycle/gates/backstop.sh compare \
  --fast fast_verdicts.json --full full_verdicts.json --out drift.json

# 2b. mark every drifting gate force_full until it is re-traced
sh scripts/fastcycle/gates/backstop.sh compare \
  --fast fast_verdicts.json --full full_verdicts.json --out drift.json \
  --apply --map gate_map.json

# 3. which registered guards have never run on this artifact?
sh scripts/fastcycle/gates/backstop.sh freshness-queue \
  --registry registry.json --fingerprint "$(cat artifact.fp)" --out queue.json

compare prints NO_DRIFT on success, or one DRIFT gate=<id> fast=<verdict|ABSENT> full=FAIL line per drifting gate plus a final DRIFT_COUNT=<n>.

Exit codes

The C-001 table (contracts/common-conventions.md):

Code Meaning
0 Clean / no drift; or a successful ordering emission (freshness-queue).
1 A finding: drift found, or a run / --determinism-check FAIL.
2 Usage or config error.
4 BLIND — a required input could not be read, or the registry/manifest is empty, so no honest verdict is possible.

The empty-registry 4 is deliberate and matters: you cannot compute pressure over nothing, so an empty queue is reported as BLIND rather than as a clean "nothing stale".

Drift definition

A drift is a gate whose full verdict is FAIL and whose fast verdict is anything other than FAIL. That single rule covers three distinct fast-lane failures:

  • the gate was absent from the fast run — a selection hole;
  • the fast run said PASS — a stale cache entry or a wrong input set;
  • the fast run said SKIP or BLIND — the gate ran but was not judged.

--apply --map marks each drifting gate's map entry force_full: true so it is never selected away again until it has been re-traced. That is the mechanism that stops the same hole reopening.

Edge cases

  • Empty manifest or registry. Exit 4 (BLIND), never 0.
  • A gate present in full but absent from fast. Reported as fast=ABSENT, not as an error and not as a pass.
  • compare with mismatched gate universes. Gates only in fast are not drifts (the rule is one-directional: full said FAIL, fast did not).
  • --apply without --map. A usage error — the flag needs a document to write.
  • Scheduling is not wired here. The release-tag / nightly / gate-engine-change triggers are documented as obligations, not implemented as a scheduler. fixtures/backstop/README.md explicitly scopes automated scheduling out of the RED test, and inventing an unverified scheduler would itself be a §11.4.6 guess. Wiring run into the real trigger points is a separate task.
  • freshness-queue ordering. reopens_count descending primary (§11.4.189 most-reopened-first), staleness descending secondary. A guard whose stored fingerprint matches the current fingerprint is FRESH and excluded regardless of its reopen count; last_verdict_fingerprint absent counts as stale.

Internal behaviour

  1. Dispatches on the subcommand (run, compare, freshness-queue) — anything else is exit 2 with usage on stderr.
  2. Verifies python3 is on PATH, else exit 2.
  3. run → lib/backstop_run.py: enumerates every gate from the manifest and executes each with the cache disabled, clamped by host_guard.sh.
  4. compare → lib/backstop_compare.py: joins the two verdict documents by gate_id, applies the drift rule, optionally rewrites map entries to force_full.
  5. freshness-queue → lib/backstop_freshness.py: joins the guard registry against the current artifact fingerprint and orders the stale entries.
  6. Writes --out and exits per the table above.

Related scripts

Calls scripts/fastcycle/gates/lib/backstop_run.py, scripts/fastcycle/gates/lib/backstop_compare.py, scripts/fastcycle/gates/lib/backstop_freshness.py, scripts/fastcycle/gates/gate_runner.sh.

Guarded by scripts/fastcycle/tests/test_backstop_red.sh (T060) with fixtures under scripts/fastcycle/tests/fixtures/backstop/.

Referenced from scripts/fastcycle/gates/mutation_reuse.py (which reads the same drift/verdict documents).

See also docs/scripts/gate_runner.sh.md, docs/scripts/verdict_cache.py.md (the key definition whose change is itself a listed trigger) and docs/scripts/io_trace.sh.md (the I/O map, another trigger).

Last verified

2026-12-04 — bash -n scripts/fastcycle/gates/backstop.sh → exit 0. sh scripts/fastcycle/gates/backstop.sh with no subcommand prints the three-subcommand usage block on stderr and exits 2.