Status: done (2026-11-25)
Priority: 3
Size: M
Design ref: none (code structure). AGENTS.md, Conventions (ids are array indexes; st is plain data).
Goal: Every other record of st names another by its id, but a job holds objects: job.farm, job.field, job.meadow, job.stretch, and an owner object shared between jobs and fences; st.idlers holds agent objects. These are the shared objects the save codec’s first pass exists to find (2,932 references in a two-year save).
Touches: sim/jobs (post); sim/layout (makeFence); sim/relations (idlersBy, companyFor); sim/society (initCulture); sim/attitudes (dailyStep); tests/codec.js; tests/sleep.js; tests/lib/invariants.js
Acceptance criteria:
farm, field, meadow and plot as ids (field and meadow as the id within their farm, beside the farm’s id) and stretch as its fence’s place ({village | farm, index}); its owner is two fields, ownerType and ownerId, as a fence’s is. A helper in sim/agents, where jobs are owned, gives the record for a job (farmOf(st, j), fieldOf(st, j), and so on), and every reader goes through it. st.idlers.by holds agent ids. st.cenv.people is the one shared object left (it is st.pawns): either sim/society reads st.pawns and the field goes, or it is rebuilt on load (VB-239’s DERIVED).$ref and no $id; a test holds that for the tiny map too. encode’s first pass, $id, $ref and $arr go from sim/saves.js, and encode fails, naming the path, on an object reached twice; tests/codec.js follows. FORMAT rises by one (the fixtures are a local cache keyed by the sources since VB-272: node tools/fixtures.js make makes the new ones).tools/writes.js: the ALIAS entries for job.field, job.meadow, job.farm, job.plot and job.stretch go or follow the helpers, and the ownership check still places every write through them (no new unresolved write, VB-243).BACKLOG.md, since the state’s canonical text moves: node tools/same.js --base REF differs only in a job’s back-references (ids for objects); list them and show that no number of the simulation moved (living, households, grain; populous and founders, small, seeds 3, 7, 11, 42, 15 years).node tools/bench.js before and after, since the planner reads a job’s field and farm in its bids (“jobs refresh and matching”, 41.7 ms a day at medium-ref, docs/bench/budget.md of 10 Nov): no higher beyond the runs’ spread; save and load no slower. The PR says what fell (lines of the codec, the save’s size).npm run verify’s hard checks pass, its targets reported with their residuals.
Notes:docs/bench/budget.md), the fixtures are local (VB-272), and the order note with VB-227 and VB-245 dropped, both done.fb35e75, populous, seed 7, small map, 2 years: 2,932 references to shared objects in the save: 1,246 from a job’s farm, field, meadow and stretch; 699 from st.jobsBy’s sets of job objects (VB-239 rebuilds jobsBy on load); 677 shared owner objects of jobs and fences; 309 agents in st.idlers; 1 st.cenv.people. st holds 33,267 objects, all of which encode’s first pass puts in a Map to find these.sim/saves.js and raise FORMAT; one remake of the fixtures if they land together).docs/review-blocks.md): a leg and the queue of ends (VB-472, VB-473) name a job by its key and a pawn by its id, never the object, so they add no shared references; either order works. The cost line’s “the planner reads a job’s field and farm in its bids” now reads “when it allots the day”.st.workDue holds job objects; agent.job and agent.side.* hold
them, and a pawn can hold a job after dropJob (hay, 3 pawn-hours a year at populous seed 7), so a key there changes behaviour unless
the dropped job is kept; plans.projects.heirPlots shares household plans; jobs hold a plan’s step (timberFor, step), a plot’s
tile record (tr), a herd and its cull entry, a claim, a cart (shared with st.lying[].of), and a village’s common field. Removing the
codec’s first pass needs all of these: more than an M. Owners copied in post and per fence stretch is safe (nothing mutates them).st.idlers.by holds agent ids; st.cenv.people is gone (sim/attitudes reads hooks.living, the simulation’s). Shared references at
populous 7, small, 2 years: 880 left (429 job.farm, 259 agent.job, 113 job.meadow, 39 job.stretch, 28 job.field, 12 others).
Decided: owners copied, not split into ownerType/ownerId (about 50 readers and sim/eligibility’s {owner} unchanged; nothing mutates a
job’s owner, records sets each stretch’s id). Not done, split out: the back-references as ids (VB-1739) and the codec’s first pass with the
rest of the 22 Nov census (VB-1740, after VB-1739). Bench not run: the machine is shared (the night measures).