Status: done
Priority: 2
Size: S
Arch: ownership
Phase: implement
Design ref: none (code structure). Architecture review of 3 November 2026 (docs/review-architecture.md, section 2, point 1); Rules 1 and 3 of docs/architecture/target-architecture.md; layer 6 (“architectural fitness tests”) of docs/architecture/stress-tests.md, section 14.
Goal: Every field the simulation keeps has one owner module; other modules read it freely and change it only through the owner’s operations. Enforce it statically, as tests/commands.js allows only the command verbs to call the acts they wrap, so a new write past the owner fails npm test. VB-172 names the owners and how they are declared; blocked until it is done and Kim has reviewed its map.
Acceptance criteria:
src/owners.json (Kim’s answer 4 of 3 November, QUESTION_ARCHIVE.md, “VB-172: the ownership map”), keyed by the fields as tools/writes.js names them (household.grain): each field’s owner module, or signal; with the creation modules (sim/scenarios, sim/layout, sim/people), which may write the records they seed, and the exempt save codec (sim/saves). The check reads it, so a new owned field needs no change to the check.docs/architecture/ownership.md, section 7): st.owner (sim/ownership) and st.claims (sim/claims), which pass today; household and village food (household.grain, rations, unthreshed, ledger, spoilt, village.grain, pawn.stake, owed, owedFrom: sim/stores, VB-174); membership (pawn.household, household.members, pawn.servant: sim/records, VB-175); a pawn’s movement (agent.path, phase, anim, inside, idleUntil, x, y: sim/agents, VB-177); ties and attitudes (pawn.ties, pawn.rel: sim/relations; pawn.att, anc, advocate: culture, VB-178); the crop (farmstead.fields: sim/fields, VB-179); and the page flags (st.visualDirty, biomeDirty, rigDirty, treeDirty, pathDirty, landDirty) as signal (Kim’s answer 5), which any module may write.tools/writes.js: in src/sim and src/culture.js, a write (assignment, compound assignment, ++/--, delete, or a mutating call) on an owned field outside its owner and the creation modules fails, naming the file, line, field and owner. Writes to a new record before it is pushed are creation and are not checked. // lint-allow: owner <reason> exempts a line, as the clock rule does.tests/lint-baseline.json), so the check lands before the refactors that clear them (VB-174 to VB-179); each of those empties its fields’ entries.tools/writes.js prints the owner column from the table, and marks writes past the owner.npm test, under 1 s; a test plants a write outside the owner and sees it fail.AGENTS.md, Conventions: one line on the rule (reads free, writes through the owner, page flags are signals) and the check.src/owners.json, not on the @state lines (answer 4). Set ready; it may land before the refactors, with their writes in the baseline.3 Nov 2026 (target-v2, section 11.2): the owners table gains a “cache” category, so pawn.household, hh.members, pawn.role and st.owner are checked like fields: one writer each, and a check that each equals what it is derived from (principle 2).
2a45626. src/owners.json declares 34 boundaries, including four caches
and six signals. The shared writes scanner now carries owner/category and marks out-of-owner sites in Markdown, --field and JSON.
The initial baseline records 124 existing writes across 26 fields; tile ownership and claims need no allowances. Sites are keyed by
field, module, operation and tokenized receiver, with multiplicities, so moving lines or wrapping code does not create new debt.
tests/ownership.js --update refuses new sites before writing a lower baseline. Creation before insertion, declared creators, the
codec and reasoned line exemptions pass; later writes to inserted records do not. The check and planted-write tests run in npm test.
Membership and ownership retain their existing consistency checks; added role-cache rebuilding and corrupt-membership probes.
No simulation module, API, game rule, golden state or counter baseline changes; rebuilding leaves index.html identical.
Initial validation: npm test passed all 60 scripts; npm run verify passed all 69, including golden state, five invariant runs,
save/load continuity and both page smoke tests (Chromium: no console or page errors). The ownership check took 0.37 s alone
and 0.8 s in verify; its rule tests took 0.7 s. The full and simulation-only scans agree on every baselined site.Reflect.set. Dynamic writes check all possibly affected owned fields.
Normal checks reject stale baseline allowances; --update can only remove them. Policy validation rejects malformed declarations,
unknown modules/categories and bad exemption lists; sim/stores is explicitly planned until VB-174 introduces its module.
Added cache corruption tests before repair, exact farm tile ownership in daily invariants, and independent role derivation from
member lists and union records. Roles are checked strictly after every refresh in the five long runs; daily checks allow only
the existing fourteenth-birthday lag. Two fixtures that jump time/call low-level acts now finish the coordinator’s refresh before
asserting completed-state invariants. The initial baseline remains 124 writes across 26 fields, unchanged by the stronger scan.
Impact: Acorn and the new scope/policy helpers are development tooling only. Cache checks and refresh instrumentation are test-only.
No new game state, runtime coupling, simulation changes or golden/counter baseline changes. The rebuilt page stays identical.
Final validation after review fixes: all 61 npm test scripts and all 70 npm run verify scripts pass. That includes both page
smoke tests, golden state, save/load continuity, and five long invariant runs with strict checks after every role refresh.
The ownership check took 0.68 s alone (1.86 s while competing with the browser in verify); no allowances were added to the baseline.