Public: anyone can read this; the crew can change it.

forked from trevato/cs · proposes · 4 behind

The determinism harness becomes engine: one folded digest behind the door, and both games' pins hold to the byte #139

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The determinism harness is now one module behind the engine's door. `src/engine/digest.ts` holds the generic half both games had written out twice — the quantiser (`QUANTUM`, `quantise`), `CHECKPOINT_CHARS`, the `fold` that hashes every tick and keeps a short digest every *n* ticks, the `Pin`, and the `compare` that names the span two runs parted at and prints the constants to paste. It knows a ti…

shipped production is serving it deploy ae07c2d

opened this

The determinism harness is now one module behind the engine's door. src/engine/digest.ts holds the generic half both games had written out twice — the quantiser (QUANTUM, quantise), CHECKPOINT_CHARS, the fold that hashes every tick and keeps a short digest every n ticks, the Pin, and the compare that names the span two runs parted at and prints the constants to paste. It knows a tick count, a stepper, a line of bytes and how many ticks a checkpoint covers; the rate, the state, the field names, what a span is called and the file the digest is committed in all arrive from the caller as a Complaint.

The proof is that nothing moved: every digest and every per-second checkpoint in src/client/replay.test.ts and src/range/pin.test.ts is unchanged to the byte, and the only edit to either test file is which module CHECKPOINT_CHARS and QUANTUM are imported from — worth reading the diff of those two files first. The game modules keep their scripts, field tables, snapshots and doctrine and lose the arithmetic: replay.ts 263 → 227 lines, pin.ts 303 → 265. The failure message is the better of the two old ones, unified: the second that first differs, the ticks it covers, how many differ, the fields that were hashed and the two constants to paste.

src/engine/digest.test.ts pins the tool on a state that is not a game — a counter, a stepper the test writes and a checkpoint of four ticks — with a divergence injected at tick 9 and found at the span holding it, the quantiser's rounding and its !NaN/!Infinity spelling, a fold of zero ticks, and the complaint read back in full. Like fakePage, it ships in no bundle, and that is asserted rather than hoped: every committed bundle is read for this module's sentence, for the complaint it writes and for CryptoHasher. All three bundles were rebuilt and not one moved a raw byte (app 72,128, range 28,978, example 8,754); only the minifier's short names shuffled, so neither ceiling in src/games.ts moved. The door, the pinned surface list, GUIDE.md's new digest section (how a third game pins itself) and the README's module tour grew with it. bun test is 617 passing.

🤖 Generated with Claude Code

Closes #110

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs