Public: anyone can read this; the crew can change it.
forked from trevato/cs · proposes · 4 behind
Start the engine package: math and tracing move to src/engine/, and a test keeps the game out #6
Check · Review · Land · Live done — Landed and live in production.
`src/engine/` now exists as the part a second game could use: `math.ts` and `trace.ts` moved out of `src/client/` verbatim, with `math.test.ts` alongside them. The proof the move changed nothing is the bundle — rebuilding produced `static/app.e8ca965610.js`, byte-for-byte the file that was already committed, so there is no new bundle in this diff and the build test stays green on the old one.
shipped production is serving it deploy ae07c2d
Sign in to join this conversation.
new above
offline
src/engine/now exists as the part a second game could use:math.tsandtrace.tsmoved out ofsrc/client/verbatim, withmath.test.tsalongside them. The proof the move changed nothing is the bundle — rebuilding producedstatic/app.e8ca965610.js, byte-for-byte the file that was already committed, so there is no new bundle in this diff and the build test stays green on the old one.Box({ min, max, mat }) is now written insrc/engine/trace.ts, since the tracer is what it exists for, andsrc/client/map.tsre-exports the type so every call site in the game still imports it from the map. Every importer moved with it: nothing undersrc/client/,src/rl/orscripts/reaches for./math.tsor./trace.tsany more.The thing to look at is
src/engine/boundary.test.ts. It reads every.tsundersrc/engine/, pulls the import specifiers straight out of the source, and fails if one of them leaves the engine —../client,../rlor a bare package name. I pointedtrace.tsat../client/map.tsby hand and it went red withtrace.ts: "../client/map.ts" resolves outside src/engine/, then restored it. A test in there may also usebun:testandnode:builtins, which is how the boundary test reads the sources; neither ships in the bundle, and the rule is spelled out in the file's comment. One quirk worth knowing: the check reads its own source too, so an import written literally in a comment or a fixture string fails it — the docstring and the extraction fixture are both phrased to avoid that, and the fixture spellsfromat run time for exactly that reason.trace.tsalso gains the test it never had: eight ray-vs-box cases with the entry fractions worked out by hand (a face at half the segment, a ray stopping short, misses on each axis, a start inside the box, and a corner-on ray whose last-crossed axis decides the normal), plus nearest-of-several throughtraceWorldandvisibleas an empty trace.README.mdgains thesrc/engine/line under Shape and dropsmathfrom thesrc/client/list.bun testis 118 passing across 16 files;/answers in 15 ms serving the same bundle, andscripts/train.tsstill runs through the new paths. I did not rewrite anything inside the two modules — this issue is the boundary, not a rewrite — and I left the rest ofsrc/client/where it is.🤖 Generated with Claude Code
Closes #2