Skip to content

benchmarks(errors): write each case as edits to the clean app - #211

Merged
JuroOravec merged 2 commits into
mainfrom
benchmarks/errors-case-edits
Oct 20, 2026
Merged

JuroOravec merged 2 commits into
mainfrom
benchmarks/errors-case-edits

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Part 2, step 1a of the error-prevention benchmark plan (#158). Stacked on #205; merge that first.

Why

Each case used to keep a full copy of every file it changed, with only the mistake line different. Adding anything to the clean app, which the next part-2 PRs do, would have meant rewriting about 90 copies by hand. A copy nobody updated would quietly keep testing the old app.

What changes

  • A case's port.toml now lists its mistake as [[edits]] (file, old, new). Each old must appear exactly once in the clean app's file, and two edits may not overlap. Full-file files copies still work, for a case that rewrites most of a file.
  • validate names every case whose old text is no longer in the clean app. After a change to the clean app, it lists the cases that need a look.
  • Case paths are checked when the case is loaded. A path that is absolute, contains .., uses a backslash or a drive letter, or leads out through a symbolic link is rejected. Before this, a case could write outside its working folder.
  • All 134 ported cases are converted, and their copies deleted.
  • The plan for parts 2 and 3 moves into the repo as docs/design/error_prevention_benchmark_plan.md, with the decisions from Benchmarks: compare which mistakes each framework catches, and when #158.

Proof

No benchmark run is needed: applying each converted case's edits to the clean app gives byte-for-byte the same file as its old copy (at 67f0876), for all 134 cases (Citry 24, Django 23, FastHTML 21, Jinja 21, Next.js 22, Nuxt 23). Each case's mistake line is unchanged too. The one-off conversion and proof scripts are not committed; git history keeps the old copies if the proof needs re-running.

Runner tests: 72 passed. validate: clean. The Windows path rules (drive letters, backslashes, names ending in a dot or space) are covered by tests but were not run on Windows.

🤖 Generated with Claude Code

Base automatically changed from benchmarks/error-prevention to main October 20, 2026 16:51
JuroOravec and others added 2 commits October 20, 2026 19:10
A case's port.toml can now describe its mistake as `[[edits]]` entries
(`file`, `old`, `new`). Each `old` must appear exactly once in the clean
baseline file, every `old` is looked up in the clean text so edit order
does not matter, and overlapping edits are rejected. `validate` checks
every edit against the current baseline and names each case whose `old`
text is missing or repeated, so a change to the reference page shows
which cases need a look. Full-file `files` copies stay available for a
case that rewrites a file completely; a case cannot both copy and edit
one file. The `mistake.contains` check now runs on the edited text.

All 134 ported cases were converted by a one-off script that diffed each
copy against its baseline file, and the copies were removed. No case kept
a full copy. Proof: for every converted case, applying its edits to the
baseline gives the old copy from 67f0876 byte for byte (citry 24,
django 23, fasthtml 21, jinja 21, next 22, nuxt 23). The conversion and
proof scripts are not committed: they only make sense while the old
copies exist, and git history keeps those for a re-check.

Also adds the approved plan for parts 2 and 3 as
docs/design/error_prevention_benchmark_plan.md, and documents the edit
format and its error modes in the README and the design doc.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…line

Loading a port.toml now rejects an edit `file`, a `files` path or the
copy it names when the text could point elsewhere: an absolute path, a
`.` or `..` name, a backslash, a drive letter, a control character, an
empty name, or a name ending in a dot or space (which Windows drops). It
also rejects a copy that is a symbolic link leading out of the case
folder, and one file named twice with different letter case or Unicode
form, which macOS and Windows treat as one file. Each error names the
port file and the path.

`validate` additionally resolves every baseline path and names the case
when a symbolic link leads out of the baseline, or when the path lies in
a folder the working copy leaves out, such as node_modules, which would
otherwise pass validate and fail partway through a run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec force-pushed the benchmarks/errors-case-edits branch from 1ebc2bb to 4ef57e6 Compare October 20, 2026 17:10
@JuroOravec
JuroOravec merged commit 772b89b into main Oct 20, 2026
1 check passed
@JuroOravec
JuroOravec deleted the benchmarks/errors-case-edits branch October 20, 2026 18:05
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