Soundness corpus: eighteen classes from bugs agents really shipped, after a study of which real fixes the checker reports #131

Merged
sionzee merged 132 commits from field-study into main 2026-11-22 17:33:06 +01:00
Owner

Based on whole-program-reach (#130), and contains it: the diff shown is this piece alone. It changes no rule and no pack data, only the soundness corpus.

The corpus counts the bug classes that pass every gate and fail at run time, and until now every class in it was thought up by the people who wrote the rules. It measured what we imagined: 2 of 74 escaping. Nobody had asked the other question: of the bugs agents really shipped in a SAFE-TS project and later had to fix, how many would today's checker have reported?

The study

One adopter's history was read in full: all 506 commits that are not merges and change TypeScript source, subject and body, plus the defect log of its migration. That gives 124 fixes, one per thing repaired, each judged by what was wrong in the code before it:

Fixes
Visible in the code 51 a reader who does not know the product could say "this cannot be what was meant"
Wrong only against intent 64 (52%) a balance number, a rule of the product, a layout: no checker sees these
Not code the checker reads 9 configuration, assets, build

The code before each fix of the first kind was checked with today's checker and today's std and packs. Of the 46 that could be judged:

  • 12 (26%) are reported at the place of the bug, one more nearby for another reason;
  • 33 (72%) pass in silence.

Of the 15 judged defects from the migration log, 10 are reported today.

Two things make the 26% look better than it is. Several rules (cycle-init-read, no-positional-children, exhaustive-dispatch, pending-without-close, unbounded-poll, ...) were written from this same history, so that share is mostly rules working on the bugs they were made from. And about half of the first kind were written before the project turned SAFE-TS on. The 72% is the more independent figure.

What this adds

scripts/soundness/classes/field.mjs: eighteen classes, each the reduction of fixes the checker is silent on, under names of its own, with a source field saying how many fixes are behind it (corpus.mjs --list prints it). All eighteen pass tsc, safe-ts check --deny-warnings and oxlint, and go wrong at run time, so the tracked number moves from 2 of 74 to 20 of 92: the corpus got harder, the checker did not get weaker. The corpus README gains "Where the classes come from", with the method and its bias.

Class Fixes What would close it
clock-domain-mixup 3 brands in std for instants of different clocks; pack data branding performance.now() and Date.now()
literal-size-instead-of-table 3 a literal loop bound that equals one value of a table keyed by the kind being walked; false positives unknown
void-discards-result 2 void on a Result reported, or counted as an escape hatch
coordinate-frame-mixup 2 brands for points in different frames
init-path-divergence 2 comparing what two ways of making one type derive: expensive
duplicated-formula-drift 2 clone detection: noisy
superseded-task-applies-late 1 unused-task-signal widened to a callback that writes captured state after an await (0.4.0 reported this; it was narrowed since)
encode-into-unchecked 1 one pack entry: the result of encodeInto must be used
listener-after-await 1 on the control-flow layer: a close or abort listener added after an await
exit-path-skips-release 1 unreleased-resource for acquire and release pairs a project declares
state-cleared-before-read 1 the control-flow layer plus what a callee clears
argument-shift-after-insert 1 argument names against parameter names
library-update-not-called 1 pack data of a new kind: "call this after changing that"
out-of-order-responses 1 useTask and latestSignal exist; a rule would be noisy
loop-decision-reads-loop-effects 1 noisy
set-add-counted-twice, float-roundoff-guard, lone-surrogate-lossy 1 each small: an insert in std that says whether it added; a pack hint

Fixes with no class: wrong predicates and checks that disagree (visible, but no rule could close them without knowing what the code is for), an observer only a browser keeps alive, tests that fail only under load.

Review

I read nine of the fixes against their verdicts (three of the first kind, six of the second) and agree with each. I ran today's binary on two of the extracted trees: one fix judged silent has no finding at its line, and one judged reported has the finding exactly where the fix later added the missing handler. I read all eighteen programs and ran the corpus with the binary of the base and of this branch: the same twenty escape. Four names in the programs had come from the fixes they reduce and are replaced.

For the owner to decide

  • Whether the handful no rule is likely to close stay in the count (init-path-divergence, duplicated-formula-drift, loop-decision-reads-loop-effects, out-of-order-responses). They are honest, and they mean the number will not reach zero.
  • void on a Result. The docs call it the explicit discard, and two real fixes are an agent using it to drop a failure it should have shown.
  • Brands for clocks and coordinate frames in std: five fixes between them, and cheaper as types than as rules.

Created with Claude Opus 5.5 (the study and the classes) and Claude Fable 5.2 (review, the merge) in Claude Code.

Based on `whole-program-reach` (#130), and contains it: the diff shown is this piece alone. It changes no rule and no pack data, only the soundness corpus. The corpus counts the bug classes that pass every gate and fail at run time, and until now every class in it was thought up by the people who wrote the rules. It measured what we imagined: 2 of 74 escaping. Nobody had asked the other question: **of the bugs agents really shipped in a SAFE-TS project and later had to fix, how many would today's checker have reported?** ## The study One adopter's history was read in full: all 506 commits that are not merges and change TypeScript source, subject and body, plus the defect log of its migration. That gives 124 fixes, one per thing repaired, each judged by what was wrong in the code before it: | | Fixes | | |---|---|---| | Visible in the code | 51 | a reader who does not know the product could say "this cannot be what was meant" | | Wrong only against intent | 64 (52%) | a balance number, a rule of the product, a layout: no checker sees these | | Not code the checker reads | 9 | configuration, assets, build | The code before each fix of the first kind was checked with today's checker and today's std and packs. Of the 46 that could be judged: - **12 (26%) are reported at the place of the bug**, one more nearby for another reason; - **33 (72%) pass in silence.** Of the 15 judged defects from the migration log, 10 are reported today. Two things make the 26% look better than it is. Several rules (`cycle-init-read`, `no-positional-children`, `exhaustive-dispatch`, `pending-without-close`, `unbounded-poll`, ...) were written from this same history, so that share is mostly rules working on the bugs they were made from. And about half of the first kind were written before the project turned SAFE-TS on. The 72% is the more independent figure. ## What this adds `scripts/soundness/classes/field.mjs`: **eighteen classes**, each the reduction of fixes the checker is silent on, under names of its own, with a `source` field saying how many fixes are behind it (`corpus.mjs --list` prints it). All eighteen pass `tsc`, `safe-ts check --deny-warnings` and oxlint, and go wrong at run time, so the tracked number moves from 2 of 74 to **20 of 92**: the corpus got harder, the checker did not get weaker. The corpus README gains "Where the classes come from", with the method and its bias. | Class | Fixes | What would close it | |---|---|---| | `clock-domain-mixup` | 3 | brands in std for instants of different clocks; pack data branding `performance.now()` and `Date.now()` | | `literal-size-instead-of-table` | 3 | a literal loop bound that equals one value of a table keyed by the kind being walked; false positives unknown | | `void-discards-result` | 2 | `void` on a `Result` reported, or counted as an escape hatch | | `coordinate-frame-mixup` | 2 | brands for points in different frames | | `init-path-divergence` | 2 | comparing what two ways of making one type derive: expensive | | `duplicated-formula-drift` | 2 | clone detection: noisy | | `superseded-task-applies-late` | 1 | `unused-task-signal` widened to a callback that writes captured state after an `await` (0.4.0 reported this; it was narrowed since) | | `encode-into-unchecked` | 1 | one pack entry: the result of `encodeInto` must be used | | `listener-after-await` | 1 | on the control-flow layer: a `close` or `abort` listener added after an `await` | | `exit-path-skips-release` | 1 | `unreleased-resource` for acquire and release pairs a project declares | | `state-cleared-before-read` | 1 | the control-flow layer plus what a callee clears | | `argument-shift-after-insert` | 1 | argument names against parameter names | | `library-update-not-called` | 1 | pack data of a new kind: "call this after changing that" | | `out-of-order-responses` | 1 | `useTask` and `latestSignal` exist; a rule would be noisy | | `loop-decision-reads-loop-effects` | 1 | noisy | | `set-add-counted-twice`, `float-roundoff-guard`, `lone-surrogate-lossy` | 1 each | small: an `insert` in std that says whether it added; a pack hint | Fixes with no class: wrong predicates and checks that disagree (visible, but no rule could close them without knowing what the code is for), an observer only a browser keeps alive, tests that fail only under load. ## Review I read nine of the fixes against their verdicts (three of the first kind, six of the second) and agree with each. I ran today's binary on two of the extracted trees: one fix judged silent has no finding at its line, and one judged reported has the finding exactly where the fix later added the missing handler. I read all eighteen programs and ran the corpus with the binary of the base and of this branch: the same twenty escape. Four names in the programs had come from the fixes they reduce and are replaced. ## For the owner to decide - **Whether the handful no rule is likely to close stay in the count** (`init-path-divergence`, `duplicated-formula-drift`, `loop-decision-reads-loop-effects`, `out-of-order-responses`). They are honest, and they mean the number will not reach zero. - **`void` on a `Result`.** The docs call it the explicit discard, and two real fixes are an agent using it to drop a failure it should have shown. - **Brands for clocks and coordinate frames in std**: five fixes between them, and cheaper as types than as rules. Created with Claude Opus 5.5 (the study and the classes) and Claude Fable 5.2 (review, the merge) in Claude Code.
Soundness corpus: eighteen classes from bugs an adopter's agents shipped
All checks were successful
Benchmarks / bench (pull_request) Successful in 3m2s
Tests / test (pull_request) Successful in 8m38s
e589fc789c
Open: every class of the corpus was thought up by the people who wrote the rules, so it
measured what we imagined. Nothing measured how much of what agents really ship and later
fix the checker reports.

This adds classes/field.mjs: eighteen classes, each the reduction (under names of its own) of
fixes found in an adopter's history that today's checker, with this branch's std and packs, is
silent on. Each carries `source`: how many fixes fall into it and what they were, in words that
don't identify the project; `corpus.mjs --list` and the JSON report print it. All eighteen
escape and are listed in escaping.txt (20 of 92 classes escape now). The corpus README gets
"Where the classes come from": how the fixes were collected and judged, and why the sample is
not independent of the rules written earlier from the same history. No rule or pack data
changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
sionzee changed target branch from whole-program-reach to main 2026-11-22 17:32:24 +01:00
Merge main: the piece below has landed
Some checks failed
Tests / test (pull_request) Has been cancelled
Benchmarks / bench (pull_request) Has been cancelled
f532976ca2
Co-Authored-By: Claude Fable 5.2 <[email protected]>
sionzee deleted branch field-study 2026-11-22 17:33:06 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Evobug/Safe-Ts!131
No description provided.