Status: done
Priority: 3
Size: S
Arch: animals
Phase: implement
Design ref: Animals (Hay and the hard winter limit: hay in the barn spoils as grain does; Kim, 2 Nov 2026); docs/review-balance.md (grain spoiling in store).
Goal: Grain in store spoils by years of need held (ECON.storeLoss, spoilGrain in src/sim/hunger.js), but hay in the barn (hh.hay) keeps for ever. Haymaking stops at two winters’ need, yet a household whose herd shrinks (the autumn count, a death, a sale) keeps a barn it never uses up. Kim, 2 Nov 2026: hay spoils in tiers, as grain does.
Acceptance criteria:
HERD.hayLoss = [0.05, 0.25, 0.5] (in src/sim/rules.js): each day, hay up to one winter’s need of the household’s animals now (winterNeed, src/sim/herds.js) loses 5% a year, the second winter’s worth 25% a year, the rest 50% a year, compounded daily as in spoilGrain. A household with no animals has a winter’s need of 0, so all its hay is in the last tier.hh.haySpoilt counts the hay lost since the start (@state line updated, invariant: a finite number ≥ 0 in tests/lib/invariants.js); the household panel shows it beside the hay, as “spoilt” is shown for grain.tests/hay.js and tests/byre.js still pass; report from tools/balance.js (4 seeds) whether hungry household-days or animals culled for want of hay change.QUESTION_ARCHIVE.md).Implementation notes (5 November 2026):
sim/byre.spoilHay reads barn hay and current herds through winterNeed, writes hay and the new cumulative
haySpoilt; sim/records initializes it, sim/saves initializes absent counters in older format-1 saves, and the household
view in page/words reads it. haySpoilt is owned by sim/byre in the ownership table. No new module or upward dependency.winterNeed traversal of that household’s animals, constant tier arithmetic and one number per household; no history grows.Balance probe: node tools/balance.js --scenario populous --seeds 3,7,11,42 --map tiny --years 5 --from 1 --json before/after.
Emergency culls were counted from st.record slaughter events starting “Hay runs short”, summing n; routine autumn culls
combine several causes in one event and are not attributed to hay by this probe.
| Seed | Household-years | Hungry household-days before → after | Emergency hay-shortage culls before → after |
|---|---|---|---|
| 3 | 170 | 10 → 9 | 1 → 1 |
| 7 | 134 | 49 → 62 | 0 → 0 |
| 11 | 164 | 25 → 24 | 5 → 5 |
| 42 | 158 | 179 → 179 | 2 → 3 |
Hunger totals rise 263 → 274, emergency culls 8 → 9. Of 625 matching household-years, 11 improve, 10 worsen and 604 are unchanged; one household-year changes identity in the divergent runs. This implements the agreed storage cost, rather than improving household food security. These are early, tiny-map runs, not a late-game balance claim.
Intentional golden update: household hashes at all seed/year entries for founders/heirs, seeds 7 and 42. Events/record change wherever hay log amounts differ; downstream jobs change in heirs/7/year2. At year 3, founders/7, heirs/7 and founders/42 also change agents, culture context, idlers, job sequence/jobs, route cache, pawns, RNG, talks and villages (plus wear/pathDirty where applicable); heirs/7 additionally changes biomeDirty, claims, farmsteads and herds. World hashes, calibration and public API hashes are unchanged. Work-counter baselines are unchanged.
index.html; lint, build freshness and git diff --check pass. npm run verify passes all 78 scripts,
including both real-browser checks, five invariant runs, save/load continuity, four late-game fixtures (none missing), scaling
and history checks. The execution-only browser adapter in gitignored work/ used SwiftShader, fulfilled the same page at an
HTTPS test origin, and limited the speed-check renderer to 20 fps for this CPU-only environment. Assertions and shipped code
were unchanged by the adapter; this verifies functionality, not a rendering-time budget. Golden baselines were intentionally
updated as listed above; work-counter and cost-growth baselines were not changed.