Status: done (2026-10-30) Priority: 2 Size: M Arch: tooling Phase: implement Design ref: none (test infrastructure) Goal: Most bugs in this code show up as inconsistent state long before they show on screen (a pawn in two households, a holder who is dead, a job claimed by nobody). Check the invariants automatically, so nightly work cannot break them silently. Acceptance criteria:
tests/lib/invariants.js exports checkState(st), returning a list of violations, each naming the record (e.g. households[3]: holder 17 is dead). At least: every living pawn is a member of exactly one undissolved household, and its household field names it; every undissolved household’s holder is alive and a member; dead pawns are in no household; every union has a start before its end and at most one open union per pawn; grain, wood, hunger and (once VB-050 is done) health are finite and within range; every claimed job is the job of the claiming agent; every farm with a household has state occupied, and every empty farm derelict or ruin; tile indexes on records are within the map; once VB-003 is done, every house and field tile has an owner.tests/invariants.js, in npm run verify: runs founders and heirs at seeds 7 and 42 for 20 years and populous tiny at seed 7 for 5 years, calling checkState after every game day; fails with the first violations and the day they appeared.