VB-1683: Invariant: every id resolves, and an ended party holds nothing
Status: done (2026-11-28)
Priority: 2
Size: M
Design ref: docs/review-principles-2026-11-24/synthesis.md (Invariant catalogue, M1 and M3); tests/lib/invariants.js; design.md, Principles for decisions (Nothing teleports)
Touches: tests/lib/invariants.js (checkState); src/owners.json; new tests/endings.js; tests/suites.js
Goal: Every pawn, household, farm, village and holder id reachable in st names a live party or lies in a field declared as history, and a dead pawn or dissolved household holds nothing, checked by one general walk instead of per-collection checks added after each bug.
Acceptance criteria:
Id-typed fields of st (pawn, household, farm, village, holder) are declared once, beside @state or in src/owners.json, each as live or as history; one walk in checkState (tests/lib/invariants.js) fails on a live-declared id that names a dead pawn or a dissolved household, and on a pawn in two households.
A dead pawn holds no stake, load or task, and a dissolved household holds no good in any store, herd, cart, claim, right or obligation (M3), checked in the same walk.
An ending sweep (tests/, on a constructed village from tests/tiny.js): each pawn, then each household, is ended in turn at each phase of a day, and checkState runs after each.
A breach the open repairs already cover (VB-1476, VB-1485, VB-1620) is listed in the check as known, with that task’s ID, and not mended here; any other breach found gets a repair task.
The per-collection checks the walk subsumes are removed, and the PR lists them.
Notes
From the principles review of 24 November (synthesis, M1 and M3). Would have caught VB-779, 1476, 1481, 1485, 1362, 1562 and PRs #152, #199, #201, #212, #263: the largest repair cluster.
Kim, 24 Nov (QUESTION_ARCHIVE.md, Archived 24 November 2026, question 3): Nothing is left to no one; a died-out household stands as an estate until its goods pass with the farm (VB-1697). This task makes a breach visible; the repairs mend it.
28 Nov (VB-1683): the declaration is ids in src/owners.json (‘KIND live|history [unique]’ a path; tools/owner-policy.js validates
it); the walk is idBreaches in tests/lib/invariants.js, its M3 part reading a dissolved household’s store fields as they lie
(sim/stores refuses a dissolved holder). A dead pawn’s or dissolved household’s own record keeps its ids as history.
Declared history where the design lets an ended id stand until a later turn: offers (lapse at due), claims (the round), a talk’s
record, relationships (the season’s pass), a dead alderman and the keep owed his household (the autumn meeting). The record is left
to VB-075’s appended check (cost), the graph’s edges (parties of several kinds) to sim/graph’s check.
Known: VB-1476 (stake), VB-1620 (shoes), VB-1697 (flour, meals, wood under a trip, the quern left in the closed record), and the new
repairs VB-1982 (a dissolved household’s obligations stay open) and VB-1983 (a death left in st.demand and household.guardian).
VB-1485’s breach no longer shows (done 27 Nov).
Removed, subsumed: peopleCheck’s live ids, VB-1481’s holder check, households’ dead or missing member, a pawn in two households, a
dead holder, a dead pawn in a household, a claimant that does not exist or a dissolved household, a herd’s missing or dissolved
household, a dead herder, a lord who is dead (looksTo).