Status: done (2026-11-11)
Priority: 2
Size: S
Arch: year
Phase: implement
Design ref: design.md, Households short of people (Short of people, checked at the change; Proposed, VB-283); backlog/VB-283.md
Goal: careForOrphans (src/sim/service.js) runs every day from dailyLife (src/sim/lifecycle.js) and walks every live household to find one with no member of 18 or more (Rules for cost, 4: schedule, don’t poll). A household can only come to have no grown member when its membership changes, so note the household at the change and let the guardian rule read only the households noted. Behaviour-preserving; it is also the hook VB-308 reads.
Acceptance criteria:
st as plain data (st.peopleCheck, household ids, in the WORLD list of src/sim/saves.js), with its operations in sim/records, its one writer: every site that takes a member out of a household notes it (leaveHousehold, which deaths and moveTo go through; clearMembers; a household made by makeHousehold with no grown member, if any can be). Grep the sites that write household.members and pawn.household and list them in the task file.careForOrphans reads the queue (in ascending household id, as st.liveHouseholds is ordered) at the same place in dailyLife, and empties it; a dissolved or empty household is skipped, as today. No other daily pass over households is added.tests/golden.json unchanged (node tests/golden.js), tests/counters.json unchanged but for the walk this removes, if a counter counts it; the queue’s invariant in tests/lib/invariants.js (ids of live households, no duplicates); a load in the middle of a run gives the same run (tests/saves.js).src/owners.json, the @state lines and docs/architecture/ownership.md name the new field and its owner.
Cost: today one check of members.some(adult) a live household a day (about 150 households on populous small, 250 at medium-ref, times 48 days a year); after, one entry a membership departure (deaths and moves: the replay counts 7 households a year becoming lone on populous small seed 3, and 804 over the ten full runs’ 350 years), each checked once. Name it measured: --report counts on small-y40 before and after.
Order: first of VB-283’s three; before VB-308, which reads the same queue. One at a time with VB-090 and VB-290, which edit sim/service.tests/golden.js gets peopleCheck in its DERIVED skip list (a queue, like liveHouseholds), so golden.json stays unchanged. WORLD in saves.js holds tile arrays, so the queue is not there; st fields are saved whole.st.peopleCheck (ids, plain data). sim/records: notePeopleCheck, takePeopleCheck (sorted, empties); noteDissolved drops the id; rebuildLiving fills it with every live household at a seed or an older load.household.members / pawn.household, all in sim/records: makeHousehold (seed households, covered by the seed fill; the in-play one in sim/membership starts empty), joinHousehold (notes when the joiner is a minor), leaveHousehold (notes; deaths and moveTo), clearMembers (empty household is skipped, so not noted).careForOrphans iterates takePeopleCheck(st) at the same place in dailyLife. A household orphaned mid-round is checked the next day.owners.json and ownership.md updated.npm test passes (91 scripts; the 2 targets out as before); tests/golden.js matches; tests/saves.js, tests/invariants.js ok.tests/counters.js shows 0 counters out. --report counts on small-y40 not run (fixture build too slow on the shared machine); the daily walk of 150 to 250 checks becomes a few entries a year.main gave VB-307 to the menu screens (PR #103) the same night.