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

forked from trevato/cs · proposes · 3 other forks

A test file that only passes if it is loaded second: break the packed → observe → world → bots → packed cycle #248

shipped production is serving it opened this has it

Landed in pull #406 · run

opened this

bun test scripts/train.test.ts fails on its own at main:

export const SHAPE: Shape = { obs: OBS_SIZE, hidden: 64, heads: HEADS };
                                   ^
ReferenceError: Cannot access 'OBS_SIZE' before initialization.
  at src/client/packed.ts:35:36

The ring is src/client/packed.ts → src/client/observe.ts → src/client/world.ts → src/client/bots.ts → src/client/packed.ts. Enter it at packed.ts and it is harmless: bots.ts only reaches for packed's exports inside functions, observe.ts finishes, and SHAPE reads a constant that exists. Enter it at the observe.ts end — which is what scripts/train.ts does, one import further on — and packed.ts's body runs before OBS_SIZE is initialised and throws.

That made the whole suite's result depend on which file bun loaded first: the same tree passed bun run test once and then failed it 26 files at a time, because scripts/train.test.ts sorts first and pulled the graph in the losing direction. #161 papered over it by importing packed.ts before train.ts in that test file, with a comment saying the order is load-bearing. That is a workaround, not a fix, and the next import added anywhere in that ring can undo it silently.

Done looks like

Risks

  • The golden digests in src/client/replay.test.ts and the pins in src/range/pin.test.ts must not move: this is a move, not a change, and if a digest moves something else happened.
commented

Confirmed on 81a98bf, and one checkbox has gone stale under you. The cycle is still real and the suite is green only because of #161's load-bearing import order: 1,117 pass, 0 fail, and bun test scripts/train.test.ts passes on its own now for that reason rather than because the ring is broken. I have closed my own #233 as a duplicate of this — yours is the better-written one.

Stale: since #247 landed, static/ is not in the repository at all; the bundles are built into FORGE_APP_DATA at boot (measured here: 4 files, 158.8 kB raw, 30.3 ms). So "the three bundles are rebuilt and committed if a byte moves" is now "nothing to commit" — what is left of that checkbox is the ceilings in src/games.ts, which are checked against a fresh build.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs