Status: done (2026-11-12)
Priority: 2
Size: M
Arch: crops
Phase: implement
Design ref: Goods and the farming year, Crops and rotations (design.md, section 8)
Goal: Seed is the crop’s own grain (Seed), so the store must know which grain it holds. hh.grain (31 sites in src/ on 11 Nov) becomes a good in subtypes, moved only through src/sim/stores.js.
Acceptance criteria:
sim/stores, and every site that reads or writes hh.grain goes through the stores’ operations, each with its good and reason. src/owners.json, @state, the WORLD list and the save codec follow; an old save’s grain loads as barley.Stores.reserved, VB-248) is kept a crop; the seven sites VB-248 lists read the sum as before.storeLoss) falls on each crop in proportion to what is held. The cook takes unreserved grain whatever its crop. Help, gifts, shares, deals and the fair’s loads move grain in the proportion the giver holds it, unless a later task names the crop.tests/golden.json unchanged (barley alone); npm test; npm run verify once, its targets reported.
Cost: a few numbers a household in place of one; no new loop.
Notes / questions:QUESTION_ARCHIVE.md, VB-345): its numbers are design.md’s starting values, Agreed.household.grain and village.grain are {[crop]: rations}, keys of CROPS (barley alone); an empty store is {}. The good
'grain/<crop>' (Stores.grainGood(crop)) is one crop’s grain, 'grain' any crop’s, as the registry names 'cattle/cow'. The ledger and
the yearly totals count grain as 'grain' whatever its crop (so they are unchanged). A pawn’s stake stays one number of no crop.sim/stores (the functions changed or added, for VB-300 beside it): added grainOf(holder, crop?) (the one reader of the total;
allocation-free, the crops added in CROPS’ order from 0, so one crop’s total is its number to the last bit), grainGood, partsOk,
partsSum, takeSpare(st, hh, n, why, into), CROP_LIST, STAKE_CROP, and the internal takeGrain, weight, split,
setHouseholdGrain, setVillageGrain, setGrain, isGrain; changed record (a crop’s grain recorded as grain), field, set
(setFood became setMeals, setVillage went), crossed (reads grainOf), put (a parts argument: 'grain' is put by its crops),
take (an into argument: the crops it took), move (carries the crops), cook (grain through takeSpare), thresh (puts
grain/barley), start (grain by crop), villageDay, brew (through takeSpare), reserve (grain is reserved by its crop),
reserved ('grain' sums the crops’ keys; a following rule gets the crop). No other function of the module changed.'grain' fall on each crop in proportion to what is held; the last crop with weight takes what is left, so one crop takes
exactly n. takeSpare weighs each crop by what is held above its own reservation (the cook, the meal’s grain above the seed, the brewer).
eatSeed and spoiling take by what is held (VB-352 orders the seed eaten). Gifts (sim/exchange: the giver’s take now comes before the
receiver’s put, which gets its crops; the events and ledgers are as before), shares, handing on and the village’s filling use move;
settlers’ and claimants’ provisions collect the crops of their takes (into) and found the household with them (the command
foundHousehold takes grain by crop).grain/barley (sim/plans, SEED), counted at read by seedNeed(st, hh, crop) (the fields
that bear or last bore the crop); a land project holds grain/barley (sim/fields, sim/meadows, the old-save path in sim/saves).
The readers of the seed (reserved(st, hh, 'grain')) read the sum, as before.hh.grain/v.grain read in src/ goes through Stores.grainOf (Sim.grainOf for the page and the tools). Sowing checks
and takes the field’s crop (grainOf(hh, fd.crop), grain/<crop>).oldGrain in sim/saves turns an older save’s number into {barley: n} and its plans’ grain reservation
into grain/barley. No world field: the WORLD list is unchanged. src/owners.json unchanged (the same fields, the same owner).@state: household.grain, village.grain in sim/stores; the households’ and villages’ lines in sim/scenarios say {crop: rations}.tests/lib/invariants.js (every crop of CROPS, none below 0, the sum is grainOf; a household’s reservation goods are crop
goods); new tests/grain.js (in npm test: loads the modules with rye added to CROPS in its own process: proportional takes, spoiling,
a crop’s take, moves, the gift verb, stakes, the cook and the meal by reservation, the village store, an old save loading as barley);
tests/stores.js (one crop exact to the last bit, the refusals); the tests that set or read hh.grain by hand use {barley: n} and
Sim.grainOf. tools/stocks.js reads grainOf calls as reads and crop goods and takeSpare as grain.grain/barley as grain) against
the base commit cfc7b1c: founders and heirs at seeds 7 and 42, seed and years 1 to 3; populous tiny seed 11 to year 8 and populous small
seed 3 to year 6; the counters’ tiny two-village state 30 days and a moving round: every state byte for byte the same, the work counters too.node tests/golden.js: differs only in households and villages of the 16 state entries, and in apiKeys/Sim (the new Sim.grainOf).
--dump against the base commit, diff -r: 250 differing lines, all households[i].grain (97) becoming households[i].grain.barley with
the same value, and villages[i].grain (32) becoming villages[i].grain.barley (24, same value) or no leaf (8, the village stores at 0 at
the seed, now {}). Not re-recorded (the orchestrator re-records at the merge).tests/counters.json unchanged. node tests/counters.js reports 6 counters out, as on the base commit (checked there with its own
counters.json); the counts are equal. node tests/scaling.js: 3 out, as on the base.npm test: all passed but tests/regress.js (it read h.grain as a number), fixed and passing after. Run singly: saves, plaindata,
invariants, review-tools, ownership, lint, smoke (the page in jsdom), grain, stores and every test touched. npm run verify
not run (the orchestrator’s instruction for tonight); its targets not reported.Sim.grainOf.sim/kinds cook.done: dried fish
first, then grain), reads Stores.grainOf; sim/stores keeps VB-300’s dry, cookLarder and the rack beside the grain by crop (a new
internal takeCrop; weight an arrow) and stays at 400 lines. On the merged tree: the whole state at full precision equals c9a5395’s
(founders and heirs, seeds 7 and 42, years 0 to 3; populous tiny 11 to year 8); the golden --dump differs only in the same 129 grain
leaves (8 zero village stores now {}), and the check besides in apiKeys/Sim; npm test 117 scripts passed, 9 targets out as on
c9a5395 (counters 6, scaling 3); saves, plaindata, invariants, review-tools, ownership, grain pass.grain (the fair’s, its worth and need); a crop is a subtype named 'grain/<crop>' in the store’s
operations and reservations only, not declared in the registry. The ledger records grain, not the crop.STAKE_CROP); VB-352 gives stakes their crops.{} (no key), not {barley: 0}: the golden dump loses 8 zero leaves of village stores.node tests/golden.js --dump before and after on the merged tree only the households and villages keys of the 16 state entries differ, every differing leaf a .grain leaf, and apiKeys/Sim (the new grainOf); the households and farms reports of founders 7 and heirs 42 small over 4 years and populous 11 tiny over 5 are byte for byte the same.