Status: done (2026-11-10)
Priority: 2
Size: M
Arch: yardstick
Phase: implement
Design ref: Balance loops and targets (Bands, Decided, Kim, 3 November). docs/architecture/target-v2.md, sections 6.2 (calibration and bands) and 8 (Kim’s decision 9); docs/roadmap.md, section 3.0 (this task’s floors become the first asserted bands). External review of 2 November (docs/review-external.md).
Goal: The wrap-ups report long-run numbers once, by hand, and nothing fails when a later change starves a village in year 30. Kim decided (3 November, decision 9) that full simulations cost too much to assert: they run nightly and are reported, never failing. Reduced scenarios (a tiny map, a few years, toy setups) are asserted in npm run verify and fail outside their band. Build both on one table of bands, starting with the floors against collapse drafted here on 2 November. Later slices add their loops’ bands to the same table: kin help in slice 1, the town’s natural decrease in slice 9.
Acceptance criteria:
tests/lib/bands.js, in target-v2’s Loop shape (section 6.2) cut to what is needed now: {id, probe, kind, report?: {lo, hi, afterYear, scenario, map, years, seeds}, assert?: {lo, hi, afterYear, setup, years, seeds}}. probe names a function of a finished run, kept in the same file and fed by yearly samples taken during the run.checkState (tests/lib/invariants.js) passes at every year end.tests/bands.js in npm run verify:
assert band checked; a failure names the band, the seed and the value;tools/bands.js:
report band printed as in or out;docs/bench/bands.jsonl; the tool never fails;tools/nightly.js (VB-193) runs it for a commit not yet run; if VB-193 is not done, this task adds tools/nightly.js with this step alone.HEAD in this file.AGENTS.md, Commands: tests/bands.js and tools/bands.js; a line in Working rules that a slice’s wrap-up adds its loops’ bands to tests/lib/bands.js.ready: it waited for this harness.
Cost: about 45 core-seconds in verify; the full runs an estimated 15 to 20 minutes on 4 cores, nightly.
Notes:docs/roadmap.md, section 3.0; the slices Decided by Kim): moved to slice 0, arch yardstick (from tooling).QUESTIONS.md, “VB-162, VB-163 and VB-165”, 1 and 2) are taken up: the roadmap, whose slices Kim decided on 3 November, makes the floors the first asserted bands, and Kim’s decision 9 says which runs may fail (reduced) and which are reported (full). So it is set ready; Kim may still change a floor there. It replaces the earlier criteria (all four long runs in verify, under 60 s), which decision 9 rules out.tests/lib/bands.js holds the table (BANDS, one entry per floor and full run, e.g. population/populous; the populous entries carry the assert), the probes (PROBES), the reduced setups (SETUPS), the full runs (FULL) and runScenario, which advances a day at a time and samples each year end: living, live households per village, births, marriages and deaths by cause read from the record appended that year, each household’s hungry days over its days present, and checkState. Deaths by hunger count the causes hunger and starvation (as sim/notable does). A household present fewer than 12 days of a year is not judged on it, and its share is capped at 1 (one made or dissolved during a day may be fed that day and not be counted present). tests/bands.js (verify) runs each seed in its own process, in parallel; tools/bands.js runs the full ones, one per core, and appends to docs/bench/bands.jsonl; tools/nightly.js calls it with --if-new. Day-at-a-time runs are not the same runs as tools/sim.js’s year-at-a-time ones (the clock’s 0.1-hour steps round differently), so their numbers differ from tools/sim.js at the same seed.QUESTIONS.md, “VB-162, VB-163 and VB-165”, 5): on the reduced run hunger deaths are asserted at most 10% (not 2%) and the worst household at most 60% of its days (not 30%); the full runs keep the drafted floors and report them out.HEAD (reduced, populous tiny, 8 years): seed 3: 161 to 179 living, hunger deaths 5.9%, worst household 31%; seed 7: 143 to 168, 0%, 2.1%; seed 11: 150 to 186, 0%, 2.1%; seed 42: 152 to 172, 7.1%, 50%; no village emptied, no invariant broken. About 11 s a seed alone, 44 to 46 s of CPU in all (V8’s compiler and GC threads included), 12 s wall on 4 cores alone, 21 s inside verify. Verify: 304 s after (370.6 s before, measured while other runs shared the machine; browser-mobile.js failed once on its search panel and passed alone, unrelated).