Status: done (2026-10-30, 3601184)
Priority: 1
Size: M
Arch: tooling
Phase: implement
Design ref: Vision and scope (up to about 1,000 pawns); Commands, time steps and views (Performance).
Goal: childrenOf, siblingsOf, spouseOf, isHolder and holdingOf (src/sim/records.js) scan all pawns, unions or households on every call, and heirRanking ranks every other household for each one it ranks. On a populous medium map at seed 7 (818 pawns), the moving round takes 2.6 s and the meetings 1.6 s, on the page’s main thread, so the game freezes; it gets worse as the dead accumulate (about 5,000 records after 150 years). Behaviour must not change.
Acceptance criteria:
person, marry, the moving round’s marriages, killPawn, transfer, succession, extinct, makeHousehold, births): children per pawn in id order, the current spouse per pawn, and the household each pawn holds. @state documented.childrenOf, siblingsOf, spouseOf (when t is now; a past t keeps the scan), isHolder and holdingOf read the indexes and return exactly what they return today, in the same order.heirRanking’s first-heir set (ownFirst) is computed once per moving round, meeting or handover, not once per ranked household.s.members() of a settlement does not filter all pawns on each call.movingRound’s marriage match, placeIfMarried for the man is computed once per man, not once per woman (src/sim/lifecycle.js:77); each call ranks heirs across all households (review, 2026-10-30).tests/perf.js (not part of either suite) prints, for populous medium at seed 7 after 2 years: ms per game day, the moving round and the meetings. Targets: moving round and meetings under 300 ms each. Report before and after in the PR.npm run verify passes and tests/golden.json is unchanged.A test asserts each index matches a full scan after 10 founders years and 3 populous years.
ownFirst is computed once in firstHeirs, refreshInterests and the moving round’s sort; the handover loop keeps recomputing it, as state changes between its calls. The index test is tests/indexes.js (in npm test); timing is tests/perf.js.