Status: done
Priority: 1
Size: S
Arch: yardstick
Phase: plan
Design ref: none (code structure and measurement). docs/roadmap.md, sections 3.0, 5 and 6; docs/architecture/target-v2.md, sections 4.1 (the rules registry) and 6.2 (bands); Kim’s decision 9 (target-v2, section 8).
Goal: Every later slice must be measured at its own cost, early and late in a run, without long timing runs. Measured on 3 November: one year from a year-40 save of populous small costs 227 ms a game day, its moving round 899 ms in one call, and the save 2.7 s to write; none of it shows at year 2, where tests/perf.js looks. Write slice 0’s implement tasks and its wrap-up.
Questions: QUESTIONS.md, Priority 1, “Roadmap”, questions 3 (the budget), 5 (counters in VB.count) and 6 (the ten rules).
Acceptance criteria:
VB.count, outside st, with one lint allowance, for the loops the roadmap names in section 6; asserted at tiny scale in npm test (VB-192);docs/bench/history.jsonl) and the budget table (docs/bench/budget.md), reported nightly, never failing (VB-194);npm run verify (its first bands VB-163’s floors) and the nightly full bands (VB-163, rewritten);death.hazard as its first rule: value() without allocation, explain(), tools/rules.js; golden unchanged (VB-197);AGENTS.md gains the counters and the ten rules (done with Kim’s answers, before this task ran: AGENTS.md, Rules for cost).
Notes:VB.count; the ten rules, now in AGENTS.md, Rules for cost). Set ready.fixtures, replaced and not stacked; work on the branch slice-0, a commit per task; and two debts of the roadmap’s section 5.4 brought into slice 0, the route cache (VB-198) and bounded history (VB-199, with its question in QUESTIONS.md).Measured for the plan (populous small at seed 7, this container, one run each, so about 10%), from saves made with tools/sim.js --save and timed 30 game days from each, every 6-minute step timed from outside:
| Year 5 | Year 40 | |
|---|---|---|
| Living / pawn records | 388 / 430 | 725 / 1,274 |
| ms a game day | 118 | 254 (268 over the whole of year 41) |
| ms per living pawn-day | 0.304 | 0.351 (1.15 times), the moving round left out |
| Longest step | 61 ms, midnight | 138 ms, midnight; 13 of 30 midnights over 50 ms |
| Moving round, one call | 37 ms | 485 to 539 ms after loading; 897 ms in its place in year 41 |
Events in st.record |
13,652 | 110,278, 81% friend and fellOut |
| Save: encode, stringify, gzip | 0.20, 0.07, 0.13 s | 0.71, 0.28, 0.61 s; 29 MB of JSON, 5.2 MB gzipped |
| Load: parse, decode | 0.14, 0.09 s | 0.62, 0.28 s |
| Cached routes | 8,212 | 25,723 |
| Time to make the save | 21 s | 270 s |
node --cpu-prof) at year 40: one moving round spends 444 of 511 ms in heirRanking, mostly ownFirstOf recomputed after every marriage and inside handsOnWell for every pair weighed (VB-196 starts with a fix that keeps behaviour). Over 30 game days, dailyLife takes 39 ms a day: Culture.dailyStep 17 ms and the daily decay of every tie about 18 ms. The step budget therefore fails at midnight as well as at the round. That adds one task, VB-201, after VB-195 and VB-127.