VB-1582: The fetch is walked: the water job goes to the farm’s nearest source or well, and is ranked so that it is done
Status: done (2026-11-23)
Priority: 2
Size: M
Design ref: design.md, Goods and the farming year (Water by the site); backlog/VB-1543.md; backlog/VB-626.md; backlog/VB-1542.md
Goal: a household’s water costs the walk to it, and no farm draws where no water is
Acceptance criteria:
Each farm has its source (design.md, Goods and the farming year, Water by the site, A farm’s source): the tile it draws at, the class and the walk in hours, found by one search outward from the house that stops at the first source the household may draw at (a natural source; its village’s well; its own), bounded at WATER.search (8 hours); marsh only by WATER.marshShy. Found at founding, when a well appears in its village, and once a year on the farm’s planning day. Owner, @state, invariant (the tile is a source the household may draw at, or none), and the save.
The water job is posted at the farm’s source, not at the house or the green: the walk out, WATER.draw (0.1 hours; the job’s flat half hour goes), the walk home laden. A farm with no source in reach posts none and its panel says why. village.well is no longer read by the fetch.
Nobody draws where no water is: the starting villages’ wells are sources on their greens’ tiles (w.fresh well; w.fresh joins the WORLD list of src/sim/saves.js), and a farm that has stood for years more than WELL.startWalk from any source starts with a well on its house’s tile where its ground has one (At the start). Digging is VB-1584.
Ranked so that it is done (How it is ranked): the walk is not taken off the score of a vital kind; at the morning’s allotment the fetch heads the list of the member best fit and its hours count in that member’s day. The household’s panel shows the day’s fetch in hours.
Marsh water costs HEALTH.marsh (0.25, by HEALTH.frail) to those the day’s water covers, and the meal is cooked.
Checks on a small constructed state: a house beside a river fetches in about 0.36 hours; a house 7 steps of meadow off in about 1.95; a household with a good source within the half hour does not draw at a nearer marsh; a fetch whose walk is long is still taken before a nearer job of lower urgency.
Measured once, before and after (small, seeds 7 and 42; solo, founders and populous; 10 years): dry household-days, hours a household-day spent on water, deaths, and whether households, not only averages, are worse off; the farms with no source in reach, counted. A shortfall is a tuning note, not a reason to hold the task.
Cost, named before building: households (250 at 1,000 living) x one fetch a day x one route from the house to its source, the same every day, so a hit in the route cache; no search for a source in any day. The source search: a farm at founding, at a well’s finishing and once a year, about 250 a year, each stopping at the first source (tens to hundreds of tiles, bounded at 8 hours), with a work counter. node tests/counters.js and a late save (--report perf) before and after. (Unticked: the counters are reported below; the late save under --report perf is left to the night, fixtures and times not being a task’s to run beside other agents.)
Noted by VB-1543, 23 November 2026.
Built, 23 November 2026 (VB-1582). sim/water: WATER, source (the one search), find/sourceOf (farmstead.water {tile, cls, walk, year}), startWells, wellDug, waterOf (the panel); sim/chores posts the fetch at the source (hours = WATER.draw, first, trip); sim/jobs: a vital kind’s fit loses no walk, first heads its hand’s list and trip counts in its day; sim/hunger: HEALTH.marsh by household.marshDay; w.fresh in WORLD; tests/water.js.
Decided: village.well stays a boolean (the design has it become the well’s tile): the fetch no longer reads it, the well’s tile is village.center with w.fresh well there, and seven readers on the page and in tests keep working; VB-1584, which digs wells elsewhere, is where it changes. Close call, noted.
Decided: a farm’s source is found on its first morning, when the fetch’s rule first asks (sourceOf), not by a hook in each of the ways a farm is founded (seeding, the editor, a new site, a restored farm, an old save): one place, and no founding path can be missed. Then at a well’s finishing and on the planning day, once a year.
Decided: a lake is drawn at from its bank and a marsh from the tile or its edge, so a house on the bank walks 0 and fetches in 0.1 h, as a farm with a well does (Kim: a farm beside fresh water has the access of one with a well). Another village’s well is not drawn at; the walk is the ground’s as it is now (stepCost), bounded at 8 h.
Decided: every vital kind loses no walk in its fit, as the design says, so firewood in a cold house too. tests/afternoon.js rewritten to the new order (the water wanted at 13:00, not called from work, taken at 14:00); tests/head.js hay check moved from seed 3 to 4, as its comment says the seed is chosen (seed 3: 2.7 winters at the start of winter after a peak of 3.4); tests/green.js checks the well as a source.
Measured, small, 10 years, before -> after (dry household-days; hours a household-day with the water in hand; deaths): solo 7: 0/480 -> 0/480; 0.71 -> 1.14; 0 -> 0. Solo 42: 1 -> 0; 0.77 -> 0.86; 0 -> 0. Founders 7: 0/2353 -> 0/2111; 1.04 -> 0.74; 4 -> 5. Founders 42: 1 -> 0; 1.04 -> 0.55; 5 -> 7. Populous 7: 2816/36454 (7.7%) -> 2752/35897 (7.7%); 1.42 -> 0.82; 125 -> 118; households over half their days dry 10 -> 9. Populous 42: 1336/36415 (3.7%) -> 1898/36073 (5.3%); 1.57 -> 0.90; 69 -> 71; over half dry 3 -> 8. No farm without a source in reach in any run. Sources at the end, populous 7: 61 wells, 31 running water; populous 42: 57 wells, 21 running, 4 lake, 8 marsh; walks one way median 0.31 to 0.34 h, the longest 1.5 h (seed 7) and 4.4 h (seed 42: a fetch of 9.4 h).
Households, not averages: most are better off (the median household’s hours fell by 0.6 to 0.7 a day in populous), the lone settler pays more (0.1 to 0.4 h a day), and on populous 42 five more households are dry over half their days: farms founded in play far from water, which dig no well before VB-1584 and are sited without the water before VB-1583. Left as a tuning note; nothing retuned.
Counters (tests/counters.js, a pawn-day): sourceSettled new, 0.039; routeSearch 0.958 -> 0.969, routeExpand 3.81 -> 3.73, routeHit 1.85 -> 1.87, dayPair 10.38 -> 10.42. sim/jobs is at 702 lines: its split is noted as VB-1591 (priority 1; tests/lint.js is red until it is in the backlog).