Status: done (2026-11-12)
Priority: 2
Size: M
Arch: year
Phase: implement
Design ref: Economy and jobs (Jobs, owners and roles: Multi-step jobs; Long work and processing: Building jobs). Job review, second pass, 30 Oct 2026.
Goal: A project is held in three shapes today: a land project is f.project = {tile, stage, hours} (src/sim/fields.js, src/sim/meadows.js), a plot is village.plots[] (src/sim/expansion.js) and a restoration is f.claim (src/sim/farmclaims.js): each is a plan with steps, each step opening when the one before is done. Make them one: a project plan in st.plans, whose steps reserve what they spend and are reconsidered when they become impossible. The job’s own shapes (go, work, fetch, carry) are left as built until a building needs materials fetched (slice 6).
Acceptance criteria:
kind: 'project', written by sim/plans): a holder (a household, a village or a claimant), a list of steps each with its opportunity kind, its place and what it spends, and the index of the open step. A step’s task is made when the step before is done.tests/golden.json unchanged (the state’s shape changes: list the golden entries that move, with behaviour the same; tests/saves.js passes). Their readers read the plan through sim/plans.sim/stores (VB-248), released when the step is done or the plan dropped.contest (src/sim/stakes.js) goes through it.docs/architecture/stress-tests.md, section 5), as a test with a test-only project that spends 40 timber over three steps: the household’s field work and needs go on beside it; a second project cannot reserve the same timber; with the timber removed mid-way the plan is reviewed and dropped, and nothing stays reserved.npm run verify’s hard checks pass, its targets reported with their residuals.
Notes / questions:docs/roadmap.md, section 3.3; the slices Decided by Kim): moved to slice 3, arch year (from work). blocked until the slice’s plan (VB-164) confirms, rewrites or closes it; its questions in QUESTIONS.md wait for that plan, which may reframe them.worktree-agent-a4b05fa332029e24c, commits VB-123: Project plans: the land and meadow projects as project plans in st.plans and ... Test C, timber reservations and the review of a plan made impossible):
st.plans.projects = {household, village, pawn}, each a Map of the holder’s id to its project plans in the order made; a plan is {id, holder, kind: 'project', what, steps: [{kind, place, hours, stake?, spends?}], open, reserved, reasons}; st.plans.projectSeq numbers them. A finished or dropped plan is removed and an empty list deleted, so nothing walks finished plans (rule 1). A household holds at most one (design.md section 7).sim/plans writes it (makeProject, advance, dropProject, review, dropAll; a new section of src/sim/plans.js). The reads are a new module, src/sim/projects.js (projectsOf, projectOf, openOf, openStep, forEach, holderOf), placed just below sim/stores in the manifest and in the material layer, because the plan’s readers and the acts that finish its steps (sim/kinds’ done, sim/fields, sim/meadows, sim/building, sim/expansion, sim/stores itself) load before sim/plans and sit in lower layers; modules above read it through sim/plans (projectOf, projectsOf, openOf re-exported), the page through VB['sim/plans']. The lower modules reach sim/plans by events (target-v2 3.2): stepDone (sim/fields’ clearing and breaking, sim/meadows’ meadow), rightLost (sim/stakes: a stake contested away, lapsed, or dropped with its household) and storeShort (sim/stores, after a take that leaves a holder’s stock below what its plans’ steps will spend). No new upward call (the layers’ baseline holds at 20).farmstead.project is gone. startProject and startMeadow stake the tile and return the plan (fieldProject: clear then break, both under the field stake; meadowProject: one meadow step under the meadow stake); the land step of sim/plans makes it. settle’s first field does the same. finishClear, finishBreak, finishMeadow emit stepDone. kinds’ landProject posts the open step, under the same key as before (clear:f12); the kinds’ and sim/jobs’ onProject read the open step.sim/stores keeps them per plan, the standing plan’s and the project plans’ summed by reserved (allocation-free). Two new reasons: field, the seed a land project holds back for its new field (released when the field is made, when the standing plan’s seed counts it; not checked against the stock, as the seed is not); build, what the steps spend, made only from free stock (reserve returns false beyond it), lowered as each step takes its share through the stores (new ledger reason build). The standing plan’s seedNeed now counts the unsown fields only; the total is as before. The firewood rule reads the woodpile’s free wood.review(st, plan) asks whether the open step is still possible (the holder there; the step’s stake held; each build reservation covered by the stock); if not, the plan is dropped and its reservations released, told by a projectDropped event (notable, kept for good), or by the line of the change that caused it: a contested stake keeps its stake line and a lapsed one its stakeLapsed line, so the record is as before. A store fallen short and a right lost review at once.farmstead.project gets the plan made from its stage at load (fillPlans, fromFarms)..project leaf (farmstead.project, also reached through jobs’ and agents’ farm); no other leaf differs (people, crops, the record and the events the same). Re-recorded once, for that. The second commit leaves it unchanged.npm test: 110 scripts passed (356 s); 4 targets out (scaling.routeRefresh +0.53, scaling.roundPairs +0.85, scaling.takeInWeighed +0.44, counters/oppAsk +0.29), as on the base commit (counters/oppAsk measured the same, 10.89 against 10.60, on b32ae90). node tests/golden.js matches; tests/saves.js, tests/plaindata.js, tests/invariants.js (5 runs), tests/record.js, tests/ownership.js, tests/dependencies.js pass. npm run verify not run (the orchestrator runs it on the merged wave).tests/projects.js (in npm test): Test C at heirs 7: a test-only barn of three steps spending 13, 13 and 14 loads of wood is built in 3.4 days at spring’s start, its steps opening in order; members worked at other things (tilling, water, cooking) in all 15 of its building hours; no hungry day; a second plan cannot reserve the same timber; the timber taken after the first step drops the plan at once, told, with nothing reserved, and its task goes. Also: a lost stake drops a land project; a store change that leaves the step possible does not; a save before project plans loads.reserved read; no counter changed.VB-123: ... a village's plot with its cottage as one project plan, VB-123: ... a claimed farm's restoration as its claimant's project plan, and two merges of claude/backlog-orchestration-t73ngj):
what: 'plot', with plot its number in the village, intended, to the pawn it is allotted to, hours worked by pawn, started). Its first step, clear, has several places: the plot’s tiles, each with its own steps (fell, grub, clear, break) and index, one task a place, worked side by side as before; the step is done when all its places are. Then foundation, walls and roof at the house, each with the hours worked (done), the walls holding the timber brought to the site (wood). sim/expansion begins it by the event projectBegun (sim/plans makes it) and finishes steps by stepDone; sim/cottage finishes the plan when the household moves in, and leaves the village’s record of the plot in village.plots ({id, village, intended, holder, started, farmstead, tiles}), which now holds only built plots. A plot cleared with nobody to have it, or a cottage left empty, stays a plan, stalled, as it stayed a plot before. Readers: livePlots, tilesOf, cottageAt (sim/expansion), sim/building’s timber, sim/fields’ built tiles, sim/claims’ holdings, sim/settle, the verb finishCottage (its target is the plot’s number), the page’s map and village panel.farmstead.claim is gone; a claim on an empty farm is its claimant’s plan (holder a pawn, what: 'restore', farm, since, one step restore at the house under the claim farm, its hours and hours worked). Begun by projectBegun, dropped through rightLost when the claim ends (told by sim/farmclaims’ own line) or lapses (its lapse line passed with the event), finished by stepDone when the claimants move in. Readers: sim/projects’ onFarm, sim/farmclaims’ claimOn (the old {by, since, hours, done} view), claimable(st, f).sim/plans stays under 400 lines beside VB-257’s routines: the old saves’ migration moved to sim/saves (oldProjects: land projects, plots, claims), the reads impossible and dropWords to sim/projects. sim/cottage reaches sim/plans by stepDone (an upward call would have raised the layers’ baseline). sim/projects now loads just after sim/records, so sim/claims can read it. One line in src/sim/clock.js (VB-241’s calendar): the empty farms’ decay asks onFarm for a restoration in place of farmstead.claim. No date test changed.node tests/golden.js --dump) of the orchestration branch’s commit and the merged tree, every differing leaf listed by pattern: the plot conversion moved the villages key of 11 state entries, 300 leaves all under villages[].plots[] (live plots’ leaves gone to st.plans, built ones’ moving parts gone), no job, agent, pawn or record leaf; the restoration moved the farmsteads, agents, jobs and idlers keys of the 16 state entries, 292 leaves all farmsteads[].claim (null: no restoration falls within the golden runs; tests/farmclaims.js and the 20-year tests/invariants.js runs exercise it). Against fd1b5ca the merged tree differs in 884 leaves, all of the three patterns (.project, villages[].plots[], .claim). npm test 113 scripts passed, 4 targets out as before (scaling.routeRefresh, scaling.roundPairs, scaling.takeInWeighed, counters/oppAsk); tests/saves.js, tests/plaindata.js, tests/invariants.js (5 runs) and tests/projects.js (now also a plot as one plan with a save of the old shape, and a claim loaded as its plan) pass. Verify not run (the orchestrator’s).places), not a plan a tile: one plot, one project plan, in today’s order.wood), not a village store: nothing else can take it, so nothing is reserved; as before it goes with the plot (left over to the new household and the plot’s workers, or burnt).sim/expansion, sim/building, sim/agents, sim/farmclaims); the plan’s making, opening, finishing and dropping only by sim/plans.village.plots, so that what read built plots (a pawn who got one has a plot, VB-142; the built tiles; the village panel) reads as before.sim/projects) and written by sim/plans, which hears the lower modules by events; the criterion’s “their readers read the plan through sim/plans” holds for the modules above sim/plans and the page.farmstead.project), so a commit between them would have left a half-converted shape.projectDropped.field) is not checked against the stock, as the standing plan’s seed is not (a hungry household eats its seed); only what steps spend (build) is.node tests/golden.js --dump before and after: 882 differing leaves, every one a .project, villages[].plots[] or .claim leaf; 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 as before the merge.