Status: blocked
Waits for: VB-377
Priority: 3
Size: M
Arch: yardstick
Phase: implement
Design ref: none (code structure). docs/typescript-plan.md (P6); the survey in backlog/VB-055.md.
Goal: Convert modules 43 to 63 (sim/eligibility, sim/agents, sim/commands, sim/occasions to sim.js). Then the late lookups go: the 17 later('...') calls of sim/commands (nine modules: sim/lifecycle 5, sim/heirs 2, sim/settle 2, sim/occasions 2, sim/farmclaims 2, sim/service, sim/membership, sim/cottage, sim/clock 1 each) and the four issue shims become plain imports. All 19 cycles tools/writes.js finds pass through sim/commands, command dispatch, the one upward door; ES modules allow such a cycle if no module uses an import of the cycle at load, only inside functions, so they stay as they are (decision, with the evidence: tools/writes.js and the new import graph). VB.register, the VB object in src/vb.js, and the codemod go; src/load.js builds globalThis.VB for the tests from the namespaces, as the only place that still does (the 120 test and tool files keep VB['sim/x']).
Acceptance criteria:
src/ is an ES module with imports; no VB[ in src/ outside src/load.js and the page script (the page’s 64 VB references stay: it reads the namespaces the bundle puts on VB, or imports them in a later task).tests/dependencies.js: for each cycle, every use of the cyclic import is inside a function); the 19 cycles are listed in the task file with the sites that cause them.node tools/same.js --base REF prints same, and tests/counters.js and tests/saves.js pass unchanged; the first npm run verify makes new fixtures (the key changed) and tests/fixtures.js, tests/history.js pass on them.docs/architecture/modules.md, “Adding things”: a module is a file with imports and exports and no longer an entry in the manifest’s order; AGENTS.md, “Finding things” and “Conventions”: the module map greps, and “a module reads only modules listed before it” goes.docs/typescript-plan.md, where this task is P6): waits for Kim’s answers to QUESTIONS.md, “VB-055: the move to TypeScript” (the formatter, the bundler, the hook, the width measures, when, the page and the tests, strict), which may change its criteria; the three rules common to these tasks are at the top of the plan.src/.