Status: done (2026-11-02)
Priority: 2
Size: M
Arch: core
Phase: implement
Design ref: none (saves); REVIEW.md, Development, debugging and inspection.
Goal: st holds functions: st.countDemand, and on st.cenv byId, settlementOf, voiceOf, nameCulture and onSplit, and members() on each settlement. A state with closures cannot be saved (VB-074), and closures over st hide what a function depends on. Depends on VB-072 (which removes st.rand); if it is not done, mark this blocked.
Acceptance criteria:
st.countDemand() becomes countDemand(st) in src/sim/heirs.js, exported in Sim as Sim.countDemand; callers change.Culture functions take the environment’s lookups as an argument (hooks: byId, settlementOf, voiceOf, membersOf, nameCulture, onSplit), built once in src/sim/society.js from st; nothing on st.cenv or its settlements is a function. calibrate.js builds its own hooks.st (except st.w) and fails on any function value, after seeding each scenario and after 1 year.npm run verify passes; in tests/golden.json only cenv entries (whose nested functions hashed as fn) and the Sim and Culture API-key hashes may change; list them in the PR.Sim API-key hash changed, by the new keys countDemand, membersOf, voiceOf and hooks; cenv entries are unchanged, as functions were never hashed; calibrate and apiKeys / Culture unchanged).countDemand(st) (sim/heirs): the moving round’s own copy of the same computation (lifecycle.js) now calls it, so the rule is written once.membersOf(st, sid) and voiceOf(st, p, s) are plain functions in sim/records, not sim/society, because sim/claims (loaded before sim/society) needs them; hooks(st) in sim/society builds the lookups on each call (a few closures a day; nothing cached on st). Sim exports all four; the page’s customs drawer and the tests use them.Culture.dailyStep, entrepreneurs, meeting, cultureYear and split take hooks after env; Culture.support already took its lookups.tests/plaindata.js (in npm test, 8 s): founders, heirs and populous (tiny map) at seed 7, after seeding and after a year. st.cenv.people is st.pawns itself (a shared reference, not a function): VB-074 must save it once.