Status: done (2026-11-12)
Priority: 2
Size: S
Arch: crops
Phase: implement
Design ref: Goods and the farming year, Crops and rotations (design.md, section 8)
Goal: The first step to several crops: today’s grain becomes the row barley of a table of crops, and the field cycle reads its numbers from the field’s crop. Behaviour is unchanged.
Acceptance criteria:
CROPS in src/sim/rules.js (or declared to VB['sim/registry'] before the seal, if the plan’s tunables go there: say which and why): the row barley holds today’s numbers (fieldYield 100, seedPerField 25, sowWindow, ripeAfterDays 26, the hours of each stage, soil wear 0.08, the frost that kills it). Rules never enter saved state.crop (a key of the table; @state line, tests/lib/invariants.js: a known crop on every field not in stubble or fallow); src/sim/fields.js and the field kinds read sowing, ripening, yield, seed and hours through the crop’s row, not through ECON. A loaded save without the field gets barley.tests/golden.json unchanged (NOT MET, see below: not re-recorded); npm test passes; the hard checks of verify pass. docs/architecture/modules.md (Adding things) gains “a new crop”.
Cost: none: a table lookup in place of a constant; value() allocates nothing.
Notes / questions:QUESTION_ARCHIVE.md, VB-345): its numbers are design.md’s starting values, Agreed.CROPS is a plain constant in src/sim/rules.js (after ECON), not a registry rule: nothing changes a row at run time yet, so there are no
contributions to combine and it needs no seal; it never enters st. Row barley: yield 100, seed 25, sow [0, 0, 9] (season, first, last
day), ripe 26, wear 0.08, frost [2, SEASON_DAYS - 1], hours {plow 20, sow 2, weed 2, reap 5, thresh 6}. ECON.fieldYield, seedPerField,
sowWindow, ripeAfterDays and SOIL.wear are gone (moved, not copied); tests/ and tools/balance.js read the row.fd.crop is set at all three places a field is made (finishBreak, two in layout.js); saves.js gives an older save’s fields barley.
sim/fields (yield, ripening, soil wear, the frost day, per field), sim/kinds (sowing window, seed) read the field’s row.CROPS.barley.hours in src/sim/rules.js; KINDS.plow/sow/weed/reap/thresh.hours take them from it (VB-333 and
VB-334 change the row, not the kinds). They are read by crop only once a second crop exists (a job’s hours can carry the field’s then).sim/plans, sim/hunger, settle, farmclaims, scenarios) and plans’ closing window read CROPS.barley directly: they have
no field in hand; they follow when the head chooses the crop.crop field (on farmsteads, and on the copies in jobs and agents)
and the removed ECON keys (checked with a diff of the full dumps, tests/out/head against new). Every one of the 16 entries moves
(founders and heirs, seeds 7 and 42, seed and years 1 to 3: entries ECON, farmsteads, agents, jobs, idlers). So the file CANNOT stay
byte for byte with a new state field and the moved ECON keys; not re-recorded, the orchestrator decides. tests/counters.json unchanged.npm test: all but lint passed in the first run; the lint (long lines) is fixed; tests/lint.js, plaindata, saves, invariants, counters,
crops, plans, soil, fresh, farmclaims, weeding pass after.CROPS is a plain table, not a registry declaration (reason above).CROPS.barley.hours by the kinds, not per field, until a second crop exists.node tests/golden.js --dump before and after: every differing leaf of the 16 state entries is a crop = "barley" line (774) or one of the four keys that left ECON (fieldYield, seedPerField, sowWindow, ripeAfterDays; 80); pawns, households, the record and all else are leaf for leaf the same, and 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. tests/counters.json unchanged. The row’s frost day was dropped at the merge: VB-241 had moved the frost to the calendar (sim/clock, FROST), so the row’s would have been read by nothing; a second crop with its own frost day brings it back.