Public: anyone can read this; the crew can change it.
forked from trevato/cs
A test file that only passes if it is loaded second: break the packed → observe → world → bots → packed cycle #406
Check · Review · Land · Live done — Landed and live in production.
Breaks the load-time cycle `packed.ts` → `observe.ts` → `world.ts` → `bots.ts` → `packed.ts`, so the suite's result no longer depends on which file bun loads first. `bun test scripts/train.test.ts` now passes on its own, and so does every other test file (140 of 140).
shipped production is serving it deploy ae07c2d
Sign in to join this conversation.
Breaks the load-time cycle
packed.ts→observe.ts→world.ts→bots.ts→packed.ts, so the suite's result no longer depends on which file bun loads first.bun test scripts/train.test.tsnow passes on its own, and so does every other test file (140 of 140).The cut.
OBS_SIZEnow lives insrc/client/obs-size.ts, which imports nothing.packed.tsreads it from there, andobserve.tsre-exports it, so no caller changes. I cut this edge because it is the only thing any module in the ring reads at load time:packed.tsbuildsSHAPEfrom it, whilebots.tsonly uses what it imports frompacked.tsinside functions. The workaround from #161 inscripts/train.test.tsis gone: the imports are in their normal order and the comment explaining the old order is deleted.Test that fails without the fix.
scripts/alone.test.tsloads every module undersrc/andscripts/as the first thing a fresh process imports, which enters every import cycle from every end. Withpacked.tspointed back atobserve.tsit fails, becauseobserve.tsandscripts/train.tsboth throw theOBS_SIZEerror. It takes about 3 s.ENTRIESinscripts/alone.tswith a reason each:src/server.ts, the two browsermain.tsfiles it lists, andscripts/mutate-result.ts. They do their work when loaded, so loading one alone would start it rather than check it.Full per-file loop.
bun run scripts/alone.tsruns every test file in a process of its own. It runs the whole suite a second time (about 25 s at 8 at a time), so it is a command rather than part ofbun test. It gives each test a minute instead of bun's 5 s, because under 8-way loadscene.test.tswent past 5 s.Two more test files that failed alone. The loop found that
src/client/grenade.test.tsandsrc/client/world.test.tsplayed rounds with bots whose policy another test file had set up. Both now calluseShipped()at the top, likecover.test.tsandpredict.test.tsalready do. The tests were wrong here, not the code. The policy they now load themselves is the same shipped one they had been borrowing.Bundles. As @atlas noted, nothing is committed for them since #247. A fresh build moves only
app: 137,564 → 137,568 raw and 53,443 → 53,440 gzipped.rangeandexampleare unchanged, no ceiling moves, and the note underappinsrc/games.tsrecords the numbers.Tests.
bun run testpasses: the typecheck and 1,678 tests. The golden digests insrc/client/replay.test.tsand the pins insrc/range/pin.test.tsdidn't move. The README lists the new command and says how load order is checked.To try it:
bun test scripts/train.test.tsandbun run scripts/alone.ts.🤖 Generated with Claude Code
Closes #248