Status: done (2026-11-08)
Priority: 1
Size: M
Arch: yardstick
Phase: implement
Design ref: none (code structure). docs/roadmap.md, section 5.3 (rule 2, no pass over pairs; rule 1, cost follows activity); Kim’s answer of 8 November 2026 in the VB-202 session: fix it first.
Goal: VB-202’s fresh fixtures fail tests/history.js: heir-ranking work per living pawn-day at small-y40 is 1.66 times that at small-y5 (limit 1.25; recorded excess 1.35, which may only fall). A full heirRanking outside the moving round (a holder’s death, a hand-on, a meeting’s check) asks ownFirstOf(st, hh), which ranks every other live household to learn whether a candidate is first in line for a farm of their own. The window of 30 days holds one such handover at small-y5 (88 households ranked) and three at small-y40 (173 each): a pass over handovers times households. A candidate can only be a direct heir of a farm whose line is one of its ancestors, one to four generations up (lineOf follows four generations), so ranking only those farms gives the same claims for every candidate.
Acceptance criteria:
sim/records indexes farms by line beside holds (st.idx.lines, caught up with new farmsteads, and noteLine where a farm’s line is written), and householdsOfLine(st, id) returns the live households whose farm’s line, or with none its holder, is id.heirRanking without ownFirstSet asks only the households of its candidates’ ancestors’ lines; the round’s shared ownFirstSet is unchanged. For every live household of a late state, the ranking equals the ranking given the full ownFirstOf(st) (a test, on a tiny state in npm test and on the fixtures in verify).checkState: each live household with a line is found by householdsOfLine under it.tests/golden.json unchanged, npm run verify passes; tests/history.js passes on VB-202’s fixtures, and its heir-ranking excess in tests/cost-baseline.json is lowered or removed with --update. Changed work counters (tests/counters.json) listed in the PR.
Cost: a handover ranks 1 + (the farms of its candidates’ lines) households, against 1 + every live household; the ancestor walk is at most 30 pawns a candidate.
Notes:sim/records indexes farms by line beside holds: st.idx.lines (pawn id to the farmsteads whose line it is or was, caught up with new farmsteads on each read), noteLine at the three runtime writes of a line (makeHousehold, a succession, an outright widow), householdsOfLine(st, id) (live household ids whose farm’s line, or with none its holder, is id) and ancestorsOf(st, ids, generations). In heirRanking, the claims without ownFirstSet are ownFirstOf(st, hh, among) over the households of the candidates’ ancestors’ lines, four generations up; ownFirstOf takes among, an optional list of household ids. sim/heirs stays at 399 lines.node tests/golden.js); npm test and npm run verify pass.tests/lib/heir-rankings.js compares each live household’s ranking with the one given the full ownFirstOf(st), under both ownHeir practices: the heirs scenario after ten years in tests/heirs.js (16 rankings, another farm’s claim mattered in 7), and the four fixtures in tests/fixtures.js (176, 346, 366 and 454 rankings; a claim mattered in 50, 307, 90 and 235).checkState finds each live household under its line; tests/cacheowners.js probes a line written without noteLine.Cost on the fixtures remade by VB-202 (at 75c34ec), one full ranking of every live household:
| Fixture | Households | Rankings a full ranking, before | after | ms, before | after |
|---|---|---|---|---|---|
small-y40 |
173 | 173 | 9.6 | 0.800 | 0.111 |
medium-ref |
227 | 227 | 3.5 | 0.591 | 0.022 |
tests/history.js (30 days with a moving round): heir rankings 375 to 201 at small-y5, 1,092 to 442 at small-y40; the ratio 1.66 to 1.24997, just inside the limit of 1.25, so its excess leaves tests/cost-baseline.json. The margin is thin: the round’s rankings alone are at 1.17, and the window holds one handover at year 5 against three at year 40. --update also lowered routeRefresh (1.821 to 1.813) and roundPairs (2.479 to 1.326), measured on the fresh fixtures.tests/counters.js) unchanged within their 10%.