Plan: One baselines directory, one bless verb

Status

Done (2026-11-24) — every recorded baseline is a typed TOML ledger under xtask/baselines/, read with no defaults; cargo xtask baselines bless rewrites the measured and run-fed ones; the contested registry holds no prose.

Closes: #2300, on the last step.
Tree: written against main at f143567d8.
Rulings (maintainer, 2026-11-23): plan #2300 next; the contested-surfaces review (criterion 4) is in scope; every ledger becomes typed TOML read through one loader ("do it right, even if it takes longer").

Context

The gates in xtask compare the tree with recorded numbers and lists. Today those records live in three kinds of place:

  • Rust constants. For example DTO_LENGTH_BASELINE (about 370 rows), DTO_UNTYPED_BOUNDS, DTO_OPAQUE_BOUNDS and DTO_OUT_OF_MODEL_CEILINGS in xtask/src/cmd/lints/dto_length.rs; UNTYPED_ENVELOPE_ALLOWLIST in lints/untyped_envelope.rs; STRUCT_METHOD_ALLOWLIST in lints.rs; UNGATED_BASELINE in devstack_gating.rs; CORS_EXEMPT in cmd/security.rs; and the empty tables in lints/problem_type_status.rs and lints/undocumented_403.rs. Changing one handler means editing a constant in a lint’s source.

  • Hand-typed universe floors. About sixteen *_FLOOR constants and WORKSPACE_MEMBER_SEED_COUNT (cmd/lint_scan.rs). Each exists to notice a walk that stopped seeing the tree; each is a number someone typed. One lint may hold several (FILES_FLOOR, CONSTANTS_FLOOR and JUDGED_FLOOR in problem_type_status.rs).

  • Files, each with its own format and parser. Under xtask/: quality-budgets.lock, fn-name-and-opt-out.txt, store-model-responses.toml, coverage-signatures-baseline.txt, evil-corpus-uncovered.txt, contention-uncovered.txt, audit-write-census.txt, authz-engine-wired.txt, authz-nil-id-exceptions.txt, authz-helpers.toml, mutants-baseline.toml. Elsewhere: crates/craig-api/authz-exempt-routes.txt, .coverage-baseline.json, contested-surfaces.toml. Different flags rewrite some of them (--bless, --write-pins, --write-lock, --baseline); several have no writer.

The 2026-10-23 tooling audit (note on #2300) found quality-budgets.lock fails open three ways: a locked count of 0 reads as "unset" and falls back to a looser threshold; a missing or renamed key reads as 0 (read_lock(..).unwrap_or_default()); and the check only fails when the count rises, so a lock above the real count is silent headroom.

contested-surfaces.toml is 3,301 lines for 136 surfaces. 92 carry an oracle string and there are 193 comment lines of prose. That prose describes the consumer’s behaviour and sits two directories away from the consumer.

Scope

In: the records listed above; one loader; one verb to rewrite the measured ones; derived floors; the contested-surfaces shrink.

Out:

  • What any gate checks. No lint’s rule changes.

  • xtask/lint-policy.toml (policy, not a recorded measurement), deny.toml, .gitleaksignore, config-sources.lock.

  • Vocabulary constants that are part of a rule (FN_NAME_AND_ALLOWLIST, JURISDICTION_LITERAL_EXEMPT_TREES, SCREENING_ALLOWLISTS): they define the rule and stay in source.

  • The STRUCTURAL-VALUE / SILENT-OK markers as a class (carried from #2315): no census is removed by this plan, so none is removed for that reason. One SILENT-OK goes with the code it marks: the lock-file fallback D4 deletes.

  • scenarios audit --bless: it records coverage moves in compliance/, not a baseline of an xtask gate.

Design

Erratum (2026-11-23, step 2): --allow-growth is accepted only with exactly one --only, so one reason cannot excuse growth in a ledger its author did not name. Found by the commit review.

Erratum (2026-11-23, steps 3 and 4): there is no Direction type. Each ledger registers its own check and bless functions, and the three behaviours live in the helpers they call. A fixture workspace that reaches a floored walk writes its own floors file rather than passing a literal, because the floor is now read where the walk runs. The partner-adapter seed count (PARSE_PROP_SEED_ADAPTERS) is not a *_FLOOR constant and stays in source.

D1. xtask/baselines/, all TOML

One directory holds every record, and every record is TOML deserialized into a typed struct by the one loader (D2). The line formats in use today (a::b | reason, service METHOD path kind, service METHOD path — reason) each have a hand-written parser; those parsers are deleted with their files. A row with a reason becomes a table with a required reason key, so "a reason is present" is the type’s rule and not each parser’s.

Records are of three kinds, and the kind decides what bless may do (D3):

Kind Meaning Records

measured

The gate can recompute it from the tree alone.

the DTO tables, untyped envelope, struct-method, problem-type, undocumented-403, ungated devstack tests, CORS exemptions, quality budgets, fn-name opt-out, store-model baseline, the three authz pins, evil-corpus and contention ratchets, audit-write census, scan floors

run-fed

Recomputing needs the output of a run the verb does not start.

coverage (cargo llvm-cov), coverage signatures (the battery’s test-results/http/run.json)

declared

Written by a person; a gate reads it as input. There is nothing to recompute.

authz-helpers, contested-surfaces, mutants-baseline (a catalogue no gate reads; it moves so the directory is complete)

Two files have a reader outside xtask and are settled here:

  • The authz exemption table. crates/craig-api/src/authz_witness.rs embeds crates/craig-api/authz-exempt-routes.txt with include_str! and parses it at run time. The ledger becomes xtask/baselines/authz-exempt-routes.toml; the witness embeds that file and deserializes it with toml, replacing its line parser. craig-api gains toml as an optional dependency of the authz-witness feature and as a dev-dependency (the module also compiles for the crate’s own tests); production images build neither. One file, two typed readers, no generated copy. The Dockerfile copies the whole context, so the file is in the image build.

  • The coverage baseline. .coverage-baseline.json is cargo llvm-cov’s own export, of which the floor reads one number. The ledger becomes `xtask/baselines/coverage.toml holding lines_percent; the tool’s JSON is no longer committed.

D2. One loader: xtask/src/baseline.rs

A small module, expected about 300 lines of production code, with no scanning of its own:

  • load::<T>(name) reads xtask/baselines/<name>.toml and refuses a missing file, an unparsable file, an unknown key and a missing key. There is no default.

  • Direction says how a record may move without a reason:

    • ShrinkOnly: a count or row set. The gate fails when the measurement is above the record (new debt) and when it is below (a stale record, to be blessed down in the same MR), which is what reconcile_site_allowlist already demands of the per-file tables.

    • Exact: a generated listing that must equal the scan.

    • Floor { slack }: the gate fails when the measurement falls below the record less its slack; a rise is fine and needs no action. Coverage uses a slack of 0.5 points (today’s FLOOR_TOLERANCE_PERCENT); scan floors use one fifth (D5).

  • write(name, value, header) renders deterministically (sorted, stable formatting), keeping a file’s hand-written header lines as the fn-name opt-out does today.

Each record registers one Ledger value: its name, kind, direction, and for a measured record how to measure it.

D3. One verb: cargo xtask baselines

  • baselines check runs every measured ledger’s comparison and prints one line each; it loads the run-fed and declared ledgers to prove they parse. Each gate keeps calling its own comparison in validate and the car; check reaches the same code by name.

  • baselines bless [--only <name>…] rewrites measured ledgers from the tree. For a run-fed ledger it reads the run’s output and refuses, naming the command to run, when that output is absent. It never touches a declared ledger.

  • A change against a record’s direction needs a reason: --allow-growth <reason> to raise a ShrinkOnly record, --allow-lower <reason> to lower a Floor. The reason must be non-empty and is written into the file’s header (last_exception = "<date>: <reason>"), so the diff a reviewer reads carries it.

Removed, each in the step that converts its record, with no alias: lints fn-name-and --bless, lints store-model-baseline --bless, validate-authz-coverage --write-pins, quality-budgets --write-lock, coverage-matrix --bless, coverage --baseline. contested-census --bless stays: it seeds stub rows for a person to complete, which is authoring a declared ledger, not rewriting a measurement. Expected size of the verb: about 200 lines.

D4. Quality budgets

quality-budgets.lock becomes xtask/baselines/quality-budgets.toml, read through D2 as ShrinkOnly. That closes the three audit findings: every budget key is required; a locked 0 is a ceiling of 0; and a count below its lock fails as stale. The threshold fallback (ceiling = if locked > 0 { locked } else { threshold }) and the unwrap_or_default read are deleted, since every budget is locked.

D5. Floors recorded, not typed

xtask/baselines/scan-floors.toml holds one entry per floor, keyed <lint>.<what> (so problem-type-status.files, .constants and .judged are three entries, and workspace.members replaces WORKSPACE_MEMBER_SEED_COUNT). Each is a Floor with a slack of one fifth, the proportion the hand-typed floors were set at. bless raises an entry to the measured count freely and lowers one only with --allow-lower, so a walk that has already broken cannot quietly record its broken count.

require_files_floor(lint, scanned, floor) keeps its three parameters. Production callers pass the loaded entry; the tests that scan a TempDir keep passing their own literal, so no fixture needs the real tree’s counts. The *_FLOOR constants are deleted.

D6. Contested surfaces

The registry keeps, per surface: id, class, crate, status, ordering, the anchor, the tests rows, and for a skip its reason, owner and review date. The prose comments leave the file, and two fields are removed from the Surface struct and from the stub text contested-census --bless writes: oracle (documented in contested.rs as "not validated") and levers (no row uses it).

Where the prose goes, per surface, decided by reading the consumer the anchor names:

  • The consumer’s doc comment already says what the prose says: the prose is dropped.

  • It does not: the behaviour is written into that doc comment, as a description of the code (what it converges to, under what delivery order, and why), with no plan or unit label.

  • The prose describes the test rather than the consumer: it goes on the test’s doc comment.

No check changes: covered still requires tests, as today.

Steps

Each step is one MR on the merge train. Steps 2 to 6 stack; 7 to 10 stack on 6.

  1. This page.

  2. baseline.rs, the baselines verb, and quality budgets (D2, D3, D4). The verb starts with one ledger.

  3. In-source tables become TOML ledgers: the four DTO tables, untyped envelope, struct-method, problem-type, undocumented-403, ungated devstack tests, CORS exemptions.

  4. Recorded floors (D5).

  5. Existing record files, first half: the three authz pins (with the witness’s reader), the fn-name opt-out, the store-model baseline, the coverage signatures. Each becomes typed TOML; its parser and old write flag go.

  6. Existing record files, second half: evil-corpus and contention ratchets, the audit-write census, authz helpers, the mutants catalogue, the coverage baseline, and contested-surfaces.toml (moved, not yet shrunk). CODEOWNERS, CONTRIBUTING.adoc and every doc that names an old path follow.

  7. Contested surfaces: mq-consumer, outbox-worker and partner-crate (32 surfaces).

  8. Contested surfaces: worker (58).

  9. Contested surfaces: s2s-client, auth-plane, pool, browser-flow (46); then oracle and levers are removed from the struct.

  10. Close: the docs below, the plan archived, #2300 closed.

Tests

Category What

Regression (the audit’s three findings)

A budgets file without a budget’s key is refused. A locked 0 with a measured 1 fails. A measured count below its lock fails as stale. Each is a test that fails on today’s quality_budgets.rs.

Unit

load refuses a missing file, an unknown key and a missing key. Each Direction judges above, at and below its record, including the two slack boundaries (0.5 points; one fifth). bless refuses to raise a ShrinkOnly record without --allow-growth, refuses to lower a Floor without --allow-lower, refuses an empty reason, writes the reason into the header, refuses a run-fed ledger whose run output is absent, and leaves a declared ledger byte-identical.

Property

For an arbitrary ledger value, write then load returns the value, and write of the loaded value is byte-identical (the canonical form a reviewer diffs).

Contract (no gate weakened)

For each record converted in steps 3, 5 and 6 that a gate reads, the gate’s existing tests pass unchanged, and one test per ledger plants a violation in a temporary tree and sees the gate fail. In each of those steps a conversion check loads the old record with its old parser and the new file with the loader and compares the two row sets for equality, before the old parser is deleted in the same MR. The authz witness’s existing tests pass on the TOML table. The mutants catalogue has no gate; its conversion check is the row-set equality alone.

Contested surfaces

The registry’s existing structural tests pass at each of steps 7 to 9. After step 9, a covered surface without tests still fails, and a registry row carrying oracle is refused as an unknown key.

Risks

Risk Mode Mitigation

A row is lost when a table moves from source to a file, so a gate admits what it refused.

fail-open

The conversion check in the contract tests; for a ShrinkOnly record a lost row also shows as new debt at the next check, since the measurement then exceeds the record.

A format conversion drops or alters a row.

fail-open

The conversion check (old parser against the loader, row sets equal) runs in the MR that converts.

A record file is missing or misnamed in a checkout or in the CI image.

fail-closed

load refuses; the car fails at the gate with the file’s name. Each step moves a file and its readers in one MR.

The authz witness reads a table its build does not contain.

fail-closed

include_str! fails the build; the devstack image build in the car is the proof.

--allow-growth or --allow-lower becomes the habit.

silent

The reason lands in the file header in the same diff, so a reviewer sees every use. No further mechanism is added.

A floor is refreshed after a walk has already broken, recording the broken count.

fail-open

bless lowers a Floor only with --allow-lower (D5), pinned by the unit test named above.

Oracle prose is lost rather than moved.

silent

Steps 7 to 9 list in each MR, per surface, whether its prose was moved, already present, or dropped and why. The commit review reads each new comment against the code.

A doc comment written from the registry’s prose claims more than the code does.

silent

The comment describes what the code does and names the test that shows it; the review checks claims against the tree.

The stale-record rule makes an unrelated MR fail when a count happens to fall.

fail-closed

That is the intent (the record must follow the truth); the failure message gives the bless command.

Erratum (2026-11-24, steps 5 to 9): steps 5 and 6 each landed as more than one commit, step 5 as two MRs. The conversion check was done once per file by a script before the old file was deleted, not kept as a test. The audit-write census is not registered with the verb: its module is test-only and its tests are its check. For steps 7 and 8 each surface’s prose was read against the code; for step 9 the check was mechanical (identifiers named in the prose found in the anchor and test files), and the untested paths the prose recorded were filed as #3154. Release notes are one fragment per MR, not one for the plan.

Delivery

  • Doc page: docs/modules/ROOT/pages/quality-gates.adoc gains § Baselines (the directory, the three kinds, the three directions, the verb, exception reasons, recorded floors) and loses each per-gate description of its own write flag. operations/contested-environment.adoc describes the smaller registry.

  • CHANGELOG entry: one changelog.d/2300.changed.adoc fragment (this repository’s release notes are fragments, folded into CHANGELOG.adoc at a release); Ops: none (developer tooling).

  • Close: #2300 with the last merge; the plan archived with its review log.

Review log

Round Vendor Resolved model Verdict

1

Anthropic (Vertex)

vertex-anthropic/claude-fable-5-2

FLAGS: step numbering, oracle described as validated, levers, a SILENT-OK contradiction, the floor bless rule, and the run-fed and declared kinds. Each fixed in the plan.

2

Google (Vertex)

vertex-gemini/gemini-4-carbon

Read the edited plan with round one beside it; the maintainer then approved it for implementation.

Edit this page · latest