Skip to content

refactor: one file per guarantee under laws/ and proofs/ - #64

Merged
ngngardner merged 3 commits into
mainfrom
refactor/split-laws
Nov 1, 2026
Merged

ngngardner merged 3 commits into
mainfrom
refactor/split-laws

Conversation

@ngngardner

@ngngardner ngngardner commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • One file per guarantee. Each guarantee is laws/<Name>.bend (its prose, then its quantified laws), proved by proofs/<Name>.bend. LAWS.bend and PROOF.bend only import them. That's 270 law files, 2 shared definition files and 7 lemma files, replacing the 5.5k-line LAWS.bend and 6.5k-line PROOF.bend.
    • 61 files are SPEC.md's guarantees.
    • 6 hold a law two guarantees rest on, named for what it says (PhraseTableLookup, InterimStatusIs1xx, LocationResolvedBySort, LocationSplitsAtQuery, SplitAtCharacter, CutAtFirstEquals). The guarantees that rest on them say so with an also rests on: line.
    • 203 are the laws SPEC.md never inventoried (URL parsing, framing, credentials, the cookie jar, caching, CORS). Each has a file of its own, named for what its law states (Base64EncodesF, NoStoreNeverFresh, UrlPathIsAbsolute, ...), with no prose. LAWS.bend's header says they promise nothing beyond their equality.
  • No requirement IDs.
    • SPEC.md's definitions (proved, pending, the gate) now head LAWS.bend, which also names the first file of each family.
    • Each section's intro heads that family's first file (e.g. laws/BadRequestAnswers400.bend for the server).
    • The "left to prove" note for the percent-encoding frame is in laws/QuoteOutputIsFramed.bend.
    • IDs cited in src/, main.bend, bench/ and the README are now law paths.
    • The table itself is kept as docs/SPEC.md.
  • Trust boundary, now # Trusted, not proved: comments on the code:
    • HTTP-TRUST-1 (Base TCP and recv) and HTTP-TRUST-2 (server sequencing) go on the src/server.bend header.
    • HTTP-TRUST-3 (bend-kit wire, dns and bytes) goes on the src/wire.bend header.
    • HTTP-TRUST-4 goes on client.follow, and HTTP-TRUST-5 (client sequencing) on the src/client.bend header.
    • HTTP-TRUST-6 (errno reporting) goes on wire.fail in src/wirespec.bend.
    • HTTP-TRUST-7 (entities table) goes on the src/entities.bend header, which tools/entities.py now writes. It says the table is generated from WHATWG's entities.json. It drops SPEC.md's claim of a differential test against html.unescape, since no such test exists in the tree, CI or history.
    • HTTP-TRUST-8 goes on form.body, and HTTP-TRUST-9 on the src/packed.bend header.
  • Helpers: no proof helper or law def was unreachable, so none were dropped.
  • bolt.bend drops def trace().

Depends on

Emerging-Patterns/bolt#257. The pinned bolt reads law files by name only and still runs trace. This PR stays a draft until that release lands and the pin is bumped here.

Test plan

  • bend PROOF.bend → ALL PROOFS CHECK
  • Lint with bolt from #257: 3 errors, 1007 warnings. The errors are the S005 stale # noqa in bench/main.bend, which main also shows under that bolt (4 errors, 1007 warnings there: main also has a C011 for def trace()).
  • Bump the bolt pin after the release, then nix flake check

🤖 Generated with Claude Code

ngngardner and others added 2 commits October 31, 2026 23:28
SPEC.md, a 5.5k-line LAWS.bend and a 6.5k-line PROOF.bend had to be read
side by side, matched up by ID tags. Each guarantee is now
laws/<Name>.bend, its prose on top and its quantified laws under it, proved
by proofs/<Name>.bend. LAWS.bend and PROOF.bend only import them.

Definitions the laws share are under laws/defs/, lemmas several proofs use
under proofs/lemmas/, each named for what it holds. Requirement IDs are
gone: a file's name is its guarantee's. A law two guarantees rest on sits
in the one that states it, or in a file of its own named for what it says
(PhraseTableLookup, InterimStatusIs1xx, SplitAtCharacter, ...). The laws
SPEC.md never inventoried (URL parsing, framing, credentials, the cookie
jar, caching, CORS) each get a file named after the law, and LAWS.bend's
header says they promise nothing beyond their equality. Each section's
intro heads the first file of that family; the table itself is kept as
docs/SPEC.md.

The trust boundary moves onto the code: the server's effects and
sequencing on src/server.bend, the client's sequencing on src/client.bend
and client.follow, bend-kit's wire, dns and bytes on src/wire.bend, the
errno reporting on wire.fail, the form body on form.body, the packed
reader on src/packed.bend, and the entities table on src/entities.bend
(written by tools/entities.py).

This needs a bolt that reads law and proof files by what LAWS.bend and
PROOF.bend import, and no longer runs `trace`; bolt.bend drops `trace`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 203 one-law files the converter named after their law (B64F,
AskClenExact, FreshNoStoreAny, ...) now say what the law states: 160 are
renamed (Base64EncodesF, RequestBodyOfContentLengthKept,
NoStoreNeverFresh, ...) with their proofs; the 43 whose names already
read as behaviors stay. Imports and cites follow.

The entities table's trust comment no longer claims a differential test
against html.unescape, which does not exist: it says tools/entities.py
generates the table from WHATWG's entities.json and checks each entry's
code points, and that no test compares html_unescape with Python's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bolt v1.22.0 reads law and proof files by what LAWS.bend and PROOF.bend
import, which this layout needs. Rules changed since the old pin, so some
noqa comments no longer silence anything (S005); they are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ngngardner
ngngardner marked this pull request as ready for review November 1, 2026 03:39
@ngngardner
ngngardner enabled auto-merge (squash) November 1, 2026 03:39
@ngngardner
ngngardner merged commit 9895137 into main Nov 1, 2026
4 checks passed
@ngngardner
ngngardner deleted the refactor/split-laws branch November 1, 2026 03:47
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