roadmap BUILT

236. Three derivations are copied between scripts, and nothing notices when they drift

Built. Milestone 234 (the project's own numbers, one row per ISO week) had to copy these derivations to do its job. What was decided, and what the block deliberately left open, is at the bottom.

In brief. Three derivations now exist twice:

They are copied rather than imported because each lives inside a #!/bin/sh script's inline python heredoc, where nothing can import anything.

So if a gate changes its definition, the dashboard keeps the old one silently. The numbers on notes/project-metrics.md would drift away from the numbers the gates enforce, both would look authoritative, and no check would fire. That is rung four of AGENTS.md's ladder holding together the page whose entire purpose is measurement.

Why it is not simply "make it a crate"

The obvious fix is a host crate both callers depend on, and it may well be right, but two things make it a decision rather than a refactor:

What it needs

One definition per question, or a check that fires when two disagree. The second is weaker and much cheaper, and this block does not choose. A test that runs both derivations on the current tree and fails on a mismatch would catch every drift that matters without moving any code, at the cost of keeping two implementations honest rather than removing one.

BUGS

What was built, 2026-09-03

Status: BUILT. Both answers, split by which question each derivation is being asked. The block declined to choose and was right to: measurement showed the choice is not one decision but three.

The premise was false, and checking it is what shrank this from a refactor to an afternoon. The block says the derivations are copied "because each lives inside a #!/bin/sh script's inline python heredoc, where nothing can import anything." A heredoc with a stable working directory imports perfectly well, and script/lint, script/metrics and script/falsifications all cd to the repository root before they run python. So the host crate the block priced was never the only way to get one definition, and the thing that made it a decision (three script/ commands becoming consumers of a built artifact) does not arise. helpers/rust_source.py is a plain module, nothing executes it, and no caller's shape changed.

Two derivations are now one definition. The comment-and-literal stripper, which is what makes a code-line count a code-line count and is the shared half of the code and comment line split, and the whole unsafe census with every exclusion and its reason. script/lint and script/metrics import both. There is no check on them because there is nothing left to compare.

The tolerance the block warned about was never in the count. It is in the file sourcing, and that stayed in each caller: script/lint walks git ls-files and reads the working tree, and script/metrics streams blobs out of git cat-file --batch at eight revisions and checks nothing out. Sharing the count removed the drift without asking either script to describe a tree it is not looking at.

The harness count could not be collapsed, and the reason is a capability difference rather than a preference. script/lint and script/falsifications attribute each harness to a workspace package out of cargo metadata, which is the better derivation and needs a workspace on disk. script/metrics has no workspace on disk at a July revision and its own header records that nothing there is allowed to build. So that one gets the block's weaker answer, said out loud as the weaker answer: script/lint runs all three and fails on a disagreement.

The comparison is not a third copy, which is the trap in that answer. It calls _harness_hits() (this gate's own) and script/falsifications --count (a mode added for exactly this, printing two integers rather than the prose --check already prints, because a gate that greps a sentence breaks when somebody improves the sentence). It also calls rust_source.harness_count (the function script/metrics itself calls). Nothing in the check knows what a harness looks like. It was proved to fire by perturbing the shared regex and its exclusion list: 147, 147, 145, and script/lint exited 1.

The sweep for a fourth copy, which the block asked for. Every constant and regex definition in script/ and helpers/ was compared across files. Two more shapes turned up and neither is this hazard:

No committed data moved. script/metrics --backfill was run before and after: all seven historical rows are byte-identical, and only the current week's row changes, because HEAD moved between the last workflow run and this branch. Two consecutive backfills produce identical bytes, so the idempotence guarantee holds. The generated CSV and SVGs are deliberately not in this branch's diff.

BUGS

Follow-on

Index row

two lifted into helpers/rust_source.py; the harness count cannot be one definition and script/lint compares all three instead