Codeficum 42

Measured notes from the workshop and the rack.

What a green suite cannot see

Corrected 2026-10-08. The count of passing tests at the review changed from 439 to 367. Mutations in one test class changed from 24 to 25 of 29. The mutation matrix runtime changed from seconds to about 4 minutes. See Corrections for the full list.

A nine-module benchmark harness reached 367 passing tests. An adversarial review of the same code then found 17 defects, three of which would have corrupted results rather than crashed. Sixteen were in code whose module already had passing tests (32 for one, 43 for the other). The seventeenth was a schema document that had fallen behind the code. Closing the 17 added 72 regression tests, for 439.

That is the whole finding, and it is not a story about writing more tests. The suite was not thin. It was descriptive: it recorded what the code did, which is a different claim from the code being right. This post is what we changed to tell those two apart, and the numbers that came out.

What was measured, and on what

The subject is chunk-bench, a CPU-side harness for a document chunking and retrieval experiment: nine Python modules that build a canonical text layer, cut it into chunks by competing rules, index and score them, and render the published figures. Apart from pdfplumber for page text, they use only the standard library. The harness runs before any GPU time is spent, which is the point — it decides whether the expensive part is worth starting.

Unless a paragraph gives another date, the numbers below were measured on 2026-08-16 against that tree at 461 tests, on one workstation, CPU only. The suite is deterministic under PYTHONHASHSEED 0, 1 and 12345. No corpus, model or vendor document is involved in any measurement quoted here; the fixtures are synthetic and generated by the repository itself.

The detector that carried the bug it existed to prevent

One module strips running headers and footers from a page before anything downstream sees it. It exists because an experiment factor was supposed to measure added section context, and a document that prints its chapter name at the top of every page hands that context to the control arm for free. Without the strip, the comparison is context against context twice, and the factor measures nothing.

Detection is positional: a line is boilerplate when its text recurs across a chapter's pages at a stable vertical position. The stability test took the minimum and maximum observed position across all pages and asked whether the spread fit inside a tolerance.

On a synthetic 20-page fixture where one page carries a jittered running head — a chapter opening whose title line is missing, so the head sits a few points higher — that test inverts. The result is worth stating precisely, because it is not "detection got worse":

Header stripping on two synthetic 20-page fixtures: one page jittered (first two rows), and one line split 10 and 10 between two positions (last row). Measured 2026-08-16.
Repeated linePages seenPages agreeing on positionOld ruleNew rule
Generic manual title1919strippedstripped
Chapter name2019survivedstripped
Genuinely bimodal line2010rejectedrejected

The generic title left the payload. The chapter name — the single line the module exists to remove — survived on all 20 pages, because one page out of twenty widened its min-max spread past the tolerance. The module was not failing to fire; it was firing on the wrong line and reporting success. The contamination it was written to prevent was living inside it.

The fix is a sliding window over the largest cluster of observed positions rather than the total spread. 19 of 20 now accepts; a genuinely bimodal line at 10 and 10 still rejects, which is the part that had to be held, since a fix that accepts everything is not a fix.

Two halves, both green, nothing joining them

The analysis chain has two modules. The first scores each question and publishes per-variant means. The second takes those per-question values and runs the paired statistic that decides whether a result qualifies.

The second module took the per-question file as a required argument. No module wrote it. The first computed exactly those values internally and discarded them behind the means — a mean cannot be un-averaged, so the chain was severed at its join.

Both halves passed their tests. Each was tested against a hand-written fixture of the other's output, so each was green against a file the other never produced. Nothing in a unit suite is positioned to notice that; the fixtures are what stand in for the missing integration, and a fixture agrees with whatever you wrote it to agree with.

The fix makes the first module write the per-question file from the same loop that computes its means. The end-to-end run below now feeds that file to the second module.

Mutation: making the suite prove it can fail

The rule we adopted is that a fix without a test proven to fail against the old behaviour is not a fix. Proving that requires running the tests against the old behaviour, which by then no longer exists.

So a driver reverts each fix site individually in a throwaway copy of the tree and runs the suite. There are 29 sites. Twenty come from the review: they cover 16 of the 17 defects plus one minor range check. The seventeenth defect was a schema document, with no code to revert. The other 9 come from fixes made later the same day, including the severed analysis chain above.

Acceptance has two criteria, and the second is what makes it worth running:

The driver enforces the first criterion: it fails the run if any reverted site leaves the suite green. It does not check the second. We judged narrowness from the failing-test list the driver writes to its results file.

All 29 were caught. The second criterion is the interesting measurement, because "narrowly" is testable: how much of the suite does one reverted fix actually take down?

Blast radius per reverted fix site. 29 mutations, full 461-test suite run for each. Measured 2026-08-16.
Tests turned red by one reverted fixMutations
110
211
33
43
81
111
Median 2, max 1129 of 29 caught

25 of the 29 failed inside exactly one test class, and none touched more than four. The widest was the one that dropped a coordinate map from a merged text layer — 11 tests across two classes, which is proportionate, since offsets in the wrong coordinate system invalidate every downstream span that reads them.

That distribution is the point. If reverting any single fix had reddened fifty tests, the suite would be telling us the code is load-bearing and nothing more. A median of two says the tests written after each defect are aimed at that defect.

The matrix earned its cost on the way in. It reported one of our own new guards as uncaught — a guard against deleting a body line that happens to be identical to a running header. The test written for it had been defeated by whole-line matching and never reached the guard at all. The test looked correct, passed, and proved nothing.

Arithmetic executed, not asserted

The build is a content-addressed graph: a variant is a path through shared stages rather than a private pipeline, so a stage feeding many variants is built once. That claim justifies starting an expensive run, so it is measured rather than quoted. The grid is declared as a graph, planned against an empty cache, built, then planned again.

Stage runs for a declared 36-variant grid, cold plan then warm plan. Measured 2026-08-16.
StageNaive, per variantSharedSaved
Extraction54549
Boundary361224
Embedding36360
Total1265373

Embedding saves nothing by construction — every variant exists precisely because its chunk text differs, so no two can share an index. Stating that as a measured zero rather than omitting the row is deliberate: an absent row and a zero row read identically in a summary, and only one of them is a claim.

Cold, the plan reported 53 nodes to build and 0 cache hits. After one build, the same plan reported 53 hits and 0 to build. The stages write placeholder files, so this checks the keys and the sharing of the declared graph. It does not check extraction or embedding output, or their running time.

A second driver runs the chain end to end on a two-page synthetic fixture. It drives these modules through their command lines: canon, boundary, structure, retrieve, aggregate, aggregate_ext, figures and stages. A real run invokes the command line; the unit suite exercises the library. For the fusion module, the driver calls only its strip-parity gate, as a library, and builds no fused layer.

35 checks, no GPU. It asserts properties rather than exit codes: that a reversal reproduces the pre-strip layer exactly, that every chunk's recorded span quotes its own source text, that one table row lands in one chunk, that the figures regenerate byte-identically with no external reference.

The table check was weaker than it looked. It asserted only that one row landed in exactly one chunk. The fixture's rows were also as wide as prose, which is the assumption the paragraph rule makes. The next day showed that real table rows are short. Given the same four rows printed short, the rule from 16 August splits the table across three chunks, and the old check still passes. We measured this split on 2026-10-07.

The fixture now prints short rows, and the rule merges runs of three or more one-line paragraphs. The check now asserts that all four rows and their header land in one chunk. After that change, on 17 August, the harness stood at 481 tests, 36 of 36 mutations caught and 42 of 42 dry-run checks.

What went wrong

A ruling I made and then reversed. Two documents disagreed about which spans reach an arbitration step. I ruled for the normative text and implemented it. It broke 27 tests. Inspecting one showed why: the change hard-coded a winner for the common case, which left one of the two configurable arbitration policies unable to express itself at all — every disagreement would resolve the same way regardless of configuration. That is not a scope parameter, it is a second arbiter. Reverted, and the disagreement re-read as being about which spans cost a model call, which the reports already separate. The wrong first ruling is recorded next to the right one; a decision log that contains only the decisions that survived is not a log.

The mutation driver copied itself into itself. First run after moving it into the repository, its scratch tree defaulted to a directory inside the source tree it was copying. Python's recursion limit found it before we did. The scratch tree now lives outside the source, but the first failed run had already left a nested copy on disk, so the second run failed identically for a different reason and briefly looked like the same bug unfixed.

A test that could not reach its own guard. Covered above, and worth repeating as a category: a passing test is evidence about the test, not about the code, until something has made it fail.

An extraction arm that could not be built at all. One extraction level merges two text layers and refuses to run unless both have had their boilerplate stripped, which is correct — merging a stripped layer with a raw one puts the headers back, in that arm only, where no summary metric would show it. But the stripper is positional and needs per-line coordinates that the second layer does not have, so the arm could never satisfy its own precondition. It was blocked by design, and had been since it was written. The fix replays the first layer's audit of what it removed onto the second, which needs no coordinates.

What this does and does not show

It shows that on this codebase, at this size, a green suite of 367 tests concealed 17 real defects. A mutation matrix of 29 reverted fixes caught all 29: 25 failed within one test class and 4 spread to two to four. This does not show that mutation testing finds defects — it does not look for them. It confirms that the tests written after a defect actually bite, which is a smaller and more useful claim.

Nor does it show that the harness is now correct. On 17 August, recounting tokens with the real tokenizer showed that the fixed-window cutter had never used one. That defect had passed this suite and this dry run. The chunking benchmark report gives the numbers.

The generalisation — that descriptive suites systematically miss correctness bugs in data pipelines — is a hypothesis from one codebase, not a measurement.

What transfers without argument is the cost. Both drivers are CPU-only and need only pytest and pdfplumber beyond the standard library. Timed on 2026-10-07 on one idle workstation, the dry run takes about 5 to 7 seconds. The mutation matrix reruns the full suite once per fix site, about 4 minutes for 29 sites. That is still cheap enough to run on every change rather than before a milestone.


Measured on 2026-08-16 on one workstation, CPU only, against one revision of the tree at 461 tests, deterministic under three hash seeds. A re-run from that revision on 2026-10-07 gave identical results for the suite, the mutation histogram, the dry-run checks and the stage counts. The driver timings and the three-chunk table split were measured on that date. The 367-test count is from a full-suite run of the reviewed code, before the fix pass. The 481, 36 and 42 counts are from 2026-08-17.

Fixtures are synthetic and generated by the repository; no corpus, model or third-party document contributes to any number above. Defect counts are from one adversarial review of one codebase and should not be read as a rate.

Corrections

Changes since the version that went live on 2026-10-07, old to new: