Skip to content

M3 G4 prep: register the laws layer; optional layer inputs - #70

Open
VirtualMachinist wants to merge 9 commits into
mainfrom
m3/g4-runner
Open

VirtualMachinist wants to merge 9 commits into
mainfrom
m3/g4-runner

Conversation

@VirtualMachinist

Copy link
Copy Markdown
Member

This is the third of four PRs for M3's laws readers step. It registers the laws layer with the gate, and the gate's runner learns optional inputs. The report fields and the protocol text come in the step PR.

What it does

  • Optional inputs: a layer input marked optional is passed when its producer wrote it. When the producer didn't, the input doesn't count as missing.
  • Registration: the registry holds the real laws layer in place of its stub. The kit's own config still has the layer off until self-hosting (G11).
  • Handoffs: a required input must still be declared by its producer, and an optional one need not be.
  • Clearer not-evaluated reason: when a project's ESLint config reaches no TypeScript file, W-01's reason now says so: "no TypeScript file was linted: ESLint's config reaches no TypeScript file (no config block has files for **/*.ts and the TypeScript parser, or an ignore drops them), so no rule can be judged".

The end-to-end test

src/laws/layer/real-e2e.test.ts runs the layer in a child process, through the production process runner and the default readers. It runs over a real git project, with real ESLint, typescript-eslint and tsc:

Project Result
strictTypeChecked config, every W-04 flag set W-01 and W-04 pass
An override for src/** that sets @typescript-eslint/no-explicit-any to off W-01 is refuse, at that override's line in eslint.config.js
The same override set to warn W-01 is refuse, at the same line
A config with no block for **/*.ts W-01 is not-evaluated, with the reason above, and src/a.ts is refused as not linted

Old survivors killed

Registration brought old runner, plan, report and ratchet code into mutation scope. The 39 surviving mutants this exposed are killed by new test files: runner-edges, plan-edges, registry-order, findings-edges, ratchet-mode and launch-label.

Declared exceptions

File Change
src/laws/readers/eslint-judge.ts and its test The not-evaluated reason text only
src/gate/plan.ts requiresOf written with filter/flatMap, removing an equivalent mutant
src/report/findings.ts The anchors and the key in one list, with no index tie-break since the sort is stable. This removes two equivalent mutants. The fingerprint is pinned by a new test
src/gate/runner.ts Exports sourceReader and optionsFor, so tests can count the once-per-file cache and pin the coverage choice. It drops a clause that the problem list already says
src/gate/registry.ts Drops a sort of a list that is already in gate order. A test pins the order
New test files in src/layers/tests, src/report and src/gate Only to kill the old survivors

No behaviour changes outside the optional inputs and the registration.

Gate on this head

  • 4,322 tests in 204 files pass, with 99.53% coverage.
  • layers: 5 in range, 5 ran, 0 failed, 0 not-evaluated. The gate took 10 minutes on a 10-CPU machine.
  • Mutation: 570 killed and 3 timeouts, 0 survived, 453 excluded as compile errors.
  • The highest CRAP score is 4.00.

🤖 Generated with Claude Code

VirtualMachinist and others added 9 commits November 20, 2026 04:35
…laws layer

A layer input marked optional no longer makes the layer not-run when its producer left no file: the runner passes it when it is there and the layer says what a missing one means. The registry now holds the laws layer in place of its stub, read from laws/W-NN.yaml. The hand-off test keeps the rule that a required input is declared by its producer, and the stub tests keep the laws layer off so they judge the build-output stub alone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rints do at their edges

Registering the laws layer and the optional input put the runner, the plan, the registry, the finding fingerprints, the ratchet mode check and the tests layer launch message in the scope of the mutation run, and 39 of their mutants survived. Tests now pin each: what a layer entry holds when nothing ran, a layer that throws, the clock, the producer named in a missing input, an optional input present and absent, the laws layer after a stop, the report crap scope, a switch with no reason, layers that require each other, an id nothing registers, a fingerprint against an independent sha256, the order among repeats, and git as the only command for a diff the tests do not need.

Where a mutant could not be told from the original, the code is simpler: no tie rule in the layer lookup, one anchored list instead of two parallel ones, no sort of a list already in gate order, no second clause that the problem list already says, and a file reader that can be handed in so the once-per-file cache can be counted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…make the diff coverage choice a function

A changed test file brings every function it covers into the mutation scope, so the three cases added to the diff wiring, ratchet and tests-layer test files made the run exceed its budget. They now live in small files of their own that cover only what they pin, and the choice of coverage for a diff is a function with its own test, so the diff engine is not run for it. The diff engine option takes undefined, as its copy token option already does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ver survivors

The coverage choice for a diff is now the options a layer gets, in one tested function, so no line of the diff engine changes. The ratchet mode test only leaves a hard run alone, the line order of repeats has an ascending case, and the tool that is not installed has its own direct test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… that reaches no TypeScript file cannot be judged

A project whose ESLint config has no block for TypeScript files gives the reader no configuration for them, so W-01 was not-evaluated with the reason that no TypeScript file was linted. That is the right verdict, and the reason now says why: the config reaches no TypeScript file, so no rule can be judged. The end to end test runs the layer in a child process over a real project with its own ESLint and TypeScript: W-01 and W-04 pass on the strict type-checked preset with every flag set, W-01 is refused at the config line of an override that sets no-explicit-any to off and of one that sets it to warn, and the config with no TypeScript block is not-evaluated with the new reason and its file refused.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ne without the canonical writer

Repeats on the same line stay in the order the tool listed them because the sort is stable, so the index tie break said nothing the sort did not. The ratchet mode test writes its baseline as plain JSON so it covers no code of the baseline module.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…so it covers no in-process code

The end to end test ran the whole gate in this process: 38 s of real git and real tools that covered 86 percent of the runner, so every mutant in the runner, the plan and the findings also ran it. It now starts bun src/cli/main.ts for check, gate and baseline, with the same assertions on exit codes, output and report, so it is still the check of the entry point and of the ratchet adoption, and the mutants of the code it ran are judged by the tests that stand beside that code.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A changed test file brings the functions of its merge base copy into the mutation scope, and the in-process version of this test covered the whole gate, so editing it put every layer, the baseline code and the report code in scope: 2757 mutants and 248 survivors of old code instead of 570 and none. The test is back as it was.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant