Status: done (2026-11-16) Priority: 1 Size: M Design ref: docs/review-blocks.md; design.md section 7 (A leg, and its end, to The timetable); docs/mocks/blocks/README.md Goal: A step of the simulation touches only the pawns whose leg is due. Acceptance criteria:
w.wear, and the worn tiles, within a hundredth).idle) is a leg due when the pause ends; the start of the working day is one event for those waiting for it.st.journeys) use the same queue; st.awake, wake, sleep and the loop of stepAgents are gone.sim/agents (sim/relations, sim/society, sim/jobs, sim/lifecycle) reads placeOf; agent.x and agent.y are written only at a leg’s start and end. Talks a pawn-day and ties formed, before and after, within a twentieth.--report perf and the counters early and on a late save.
Notes / questions:docs/review-blocks.md, section 4, step 3). Kim, 15 Nov: scheduled blocks, a breaking change allowed.agent.x, agent.y between this task and VB-474: until then the simulation writes a walker’s place at each step it is asked for one (a shim the page task removes), or the two are merged if that is simpler.sim/agents, a section “legs”: every living pawn is in one leg (agent.leg): a walk {kind 'walk', t, x, y, seg, pace, h, end, due}
(h: the hours from its start to each point of a.path past seg, at the pace fixed as it begins; end the step those hours reach,
whole steps; due its end, or on a journey the night’s stop), a wait {kind 'wait', t, due} (a free pawn until its pause ends, in
the working hours; or a traveller resting on the road until 6:00), or work {kind 'work', t, x, y, seg 0} (its end is its task’s, in
st.workDue); none (null) for a free pawn waiting for the working day, and for the dead. begin, waitLeg, roadWait set a leg and
queue it; unleg takes it out; halt cuts a walk where its hours reach (along, by halving), treading the tiles entered so far
(treadTo), and stopAt writes the pawn’s place, facing and stride: a.x and a.y are written only at a leg’s start and end (and by
placeAtHome, placeByDoor for one standing at home).st.legDue: the pawns whose walk or wait is under way, by due then id, each once (binary search, splice); bounded by the living (an
invariant); plain data, saved; built from the pawns’ state when absent (legsOf: a fresh run, an older save). stepAgents takes the
tasks due (dueWork), then the legs due: a walk arrives (walkEnd, arrived) or stops for the night, a rest on the road sets out on
the next leg, a wait ends and its pawn, if it wants work, is offered to the planner. The working day’s start (WORK[0]) is one event:
dayStart walks the living once a day for the free pawns with no leg. After the planner, rest gives those it left free a wait to the
next step, as the stepping polled them. st.awake, wake, sleep, anchor, moveAgent, stepSide and the loop are gone.walkTo cuts the walk in hand; release waits a freed
pawn, or re-paces a walk that goes on (repace: a load put down); freeHands cuts a hand on its way and waits it; stopWorkFor,
haltForTalk, idle, moved, placeBorn, setOut, startLeg, retarget, delivered, endJourney, stillAtDeath (a death cuts
the walk where it had come to and unlegs the pawn); standStill (exported; tests that place pawns by hand use it).st.stepAt {moving, walked} replaces st.awake.moving (non-enumerable, not saved): workTick (work and places reckoned to the step
before until the step’s legs begin), walkTick (a walk begun before or while the legs are taken moves this step), pollTick. Between
steps, and in a fresh or loaded run, both are the tick.st.journeys keeps its records in the order they set out, with no due; their legs are their pawns’ (a walk that stops at
the last step before WORK[1], a wait on the road until 6:00). dueJourneys, stopJourneys, queueJourney and their two calendar
entries are gone.st.workDue like a task under work and ends there (sideEnded); its rate (minding) is constant over
its holder’s leg (standing free; at other work within reach; a walk that begins and ends within reach), and sideCheck looks at reach as
the holder’s leg begins and ends; dropJob lets its holders go at once; the end of the working day lets every holder go (sim/clock).sim/society outdoors(st, placeOf) (the clock passes placeOf, so society makes no upward call) fills each
outdoors pawn’s place, which sim/relations reads for cells and nearness; sim/jobs company (placeOf(mate)); sim/lifecycle a death
on the road. The page reads Sim.placeOf and Sim.poseOf (read only; see decisions); tests/browser.js and tests/browser-speed.js
compare drawn places with placeOf.walkStep is now the legs a step takes from the queue, walkAwake the living looked at by the day’s start, walkPoint the
points trodden at a walk’s end or cut; new walkPlace (places worked out along a walk). tests/counters.json: only these three
re-recorded; every other counter left at the run branch’s baseline (the probe’s values are the base’s to three digits).tests/legs.js rewritten (walks end at their due, never later; places at a walk’s start and end; waits; tasks; a cut treads only
the tiles entered and the next walk starts where it stopped; an older save with no legs loads with every pawn in its leg and goes on);
tests/attention.js steps the legs to walk into and out of reach; tests/journeys.js, tests/relations.js, tests/living.js,
tests/regress.js (the underflowing walk is now a leg a step long), tests/speed.js adapted. Invariants: the queue (living, distinct,
sorted, each due after its start), each living pawn’s leg as what it does, a walk’s hours and end, a free pawn with no leg only when its
next look falls outside the working hours, no leg for the dead, no st.awake; st.workDue may hold background tasks, and one minded is
in it; journeys in id order with no due.sim/agents is 1,227 lines (VB-422 splits it, waiting for this task); its exports fell from 32 to 31 (width baseline lowered).st.legDue; tasks’ ends in st.workDue, as VB-472 built it. One queue
of the pawns’ legs; a work leg’s end is its task’s, shared by its hands. Close call.release (an occasion, an order, a household dissolving) looks for work at its next step, where the stepping found it at
the next hour’s rebuild of the awake list. Close call.st (one made the page’s state differ from headless, tests/browser.js); the page reads walkers through
Sim.placeOf and Sim.poseOf, and the simulation writes facing and stride at a leg’s end only. Drawing from legs between steps stays
VB-474’s. Close call (the task’s note allowed merging).moved, carryGift) walked its old route to the
task’s site as its first leg, then was placed at its new home; setOut now cuts the walk in hand. Teleport found and left for its task:
release books a load on its way home at the barn from the road (VB-335): VB-581 (physical).npm test 55/55; npm run verify 112/112 (the same 11 targets out as on the run’s branch at 066671f; scaling.helpBid 1.23 -> 1.20);
node tests/smoke.js, tests/browser.js, tests/browser-speed.js pass. Screenshot: docs/img/vb473-legs.jpg.tests/legs.js over 12 days of the probe: 855 walks, 828 arrived at their due step, 9 cut, none past its due; 610 waits, none past;
298 tasks, 250 ended at their foretold step, none past; places at a walk’s start and end exact.Sim.poseOf read after every step, the two runs one after the
other): the same state.populous small, 3 years; founders small, 10 years; --report hours; scratch measures of talk, ties and wear:
| Run | Living (end) | Hungry household-days | Mean grain (end) | Idle share of workers’ hours |
|---|---|---|---|---|
| populous 7 | 374 -> 374 | 15 -> 25 (0/15/0 -> 5/20/0) | 564.2 -> 566.3 | 51.8% -> 51.9% |
| populous 42 | 369 -> 364 | 2 -> 3 | 484.2 -> 484.9 | 49.5% -> 50.0% |
| founders 7 | 19 -> 19 | 0 -> 0 | 693.5 -> 699.1 | 23.1% -> 22.7% |
Hours a household-year by kind (work and walking, mean over the groups by household-years): every kind within 1 to 3 hours; the most moved hunt 32 -> 29 (populous 7), wood 85 -> 83 and plow 84 -> 82 (42), mow 69 -> 71 and wood 58 -> 56 (founders). Households: no household-level change the summary shows beyond the runs’ drift; the hungry days of populous 7 rose by 10 (years 1 and 2), those of 42 by one, a description (VB-472’s change moved the same count by 7 the other way).
Talk and ties (criterion 4, within a twentieth): talks a pawn-day 6.989 -> 6.963 (populous 7), 7.026 -> 7.023 (42), 4.74 -> 4.73 (founders 7), 6.642 -> 6.633 (the late save, populous 7 at year 20, one year on); ties held among the living 14,474 -> 14,426, 17,098 -> 16,324 (a tie a pawn 46.3 -> 44.9, -3.2%, with 5 fewer living), 156 -> 158, 24,727 -> 24,731.
Wear over a day (criterion 1, within a hundredth): populous 7 from its start, the sum of w.wear 76,627.7 -> 76,648.4 (+0.03%), worn
tiles 726 -> 726 (stages 286 -> 286); from a save at year 1, 158,046.5 -> 158,095.8, 1,281 -> 1,281; populous 42, 101,489.8 -> 101,578.5,
707 -> 711 (+0.6%). The day’s own wear is 1.5% (populous 7) to 7% (42) higher: the runs part from the first step (a pawn freed looks for
work sooner), and the points trodden a day are within 2% (walkPoint). Founders 7 over 10 years: 9,889 -> 8,501 at year 10, within a few
percent either way in years 1 to 9.
Counters a living pawn-day (scratch runs, the whole run): walkStep 51.8 -> 6.82 (populous 7), 54.4 -> 6.90 (42), 52.1 -> 8.17
(founders 7), 54.1 -> 7.13 (the late save); walkAwake 24.0 -> 1.0 in all; walkPlace (new) 1.19, 1.53, 0.91, 1.36; walkPoint within
2%; helpBid 0.688 -> 0.707, 1.158 -> 1.116; pastureTiles 1.71 -> 1.68 (populous 7); the others within 2%. tests/counters.js probe:
walkStep 52.8 -> 7.05, walkAwake 24.0 -> 1.0, walkPlace 0.58; every other counter the base’s to three digits.
--report perf (a description: the machine was shared, the after runs under twice the load): “agents: walking and working” 18.3% ->
16.5% of simulation time at populous small year 3, 20.1% -> 16.3% on the late save; the times are left to the nightly bench.
counters/walkStep 52.8 -> 7.05 a pawn-day and counters/walkAwake 24.0 -> 1.0 (the probe), in; the change’s aim (re-recorded);
counters/walkPlace new, 0.58.scaling.helpBid 1.23 -> 1.20 against 1.15, still out; not this change’s aim.counters/heirRank, roundRank, helpBid, pastureTiles; scaling roundPairs,
roundWalk, heirRank, helpBid, takeInWeighed, frontTile, roundRank).st.workDue (the old queue left side tasks out): loaded
now queues every background task with a rate that is not queued, so it ends at its due (tests/legs.js: one taken out and loaded).dropSides treads a walk in hand up to where it has come to, at the weight of the herds it drives, and lets it go on
from there before the side tasks go (at 18:00 they went first, and the way walked with the herds was trodden at one crossing).tests/lib/clock.js marks it, non-enumerable) may hold legs due before it, as the next step takes them.tests/regress.js: the underflowing route (a first segment of a few smallest doubles, then cost 2.73) is given to a pawn and its leg
built as a loaded save would build it; its hours rise, it ends at its due step, walked in whole steps.release (a load put down, its cart left),
which re-paces the walk (repace); a cart is taken before a walk begins (ended) and worn out only at home (Carts.home, after
arrival). No other path changes it mid-walk.ended -> complete -> the kind’s done (farmclaims’ restored -> moveIn ->
foundHousehold -> moveTo -> moved) released the pawn and set it out on a journey; back in ended, the job, phase and leg were
cleared and a wait given, so the journey’s phase was wiped and the next takeDay put the pawn in ‘go’ with its journey still in
st.journeys (“a journey’s pawn left in phase go”, founders small 11 at day 1190; small-y40 in tests/fixtures.js). Fixed: after
complete, ended leaves the pawn be when its job is no longer the task (a completion that moved it released it); deposit the same
after a kind’s deliver. Siblings checked: sideEnded only sends home a holder with no phase, job or walk; arrived gives a wait only
to one with no leg; delivered and endJourney call no kind’s hook. Test: tests/legs.js, a task whose done moves its pawn to a
household of the other village: it sets out, walks, arrives, its journey ends, checkState clean each day (without the fix: phase null).careForOrphans -> goToKin -> holdInTrust(hh) moved hh’s people to its kin while hh held another farm in trust, and that trust
kept pointing at the emptied hh. Fixed in holdInTrust: each trust hh holds goes back to its holder first, by the goBack verb with
‘trustee gone’, as extinct does when a trustee dies out. Test: tests/trust.js case 7 (without the fix: the invariant above).careForOrphans as any. The rule is the verb (goBack, ‘trustee gone’); extinct (sim/heirs) and holdInTrust (sim/trust) each issue it
for the trusts the household holds: one function for both would need sim/heirs to call up into sim/trust (only command dispatch may) or
a seventeenth export of sim/heirs (its width baseline is 16, no split task open).npm test 55/55; npm run verify 118/118 (8 targets out, advisory); tests/invariants.js (5 runs), tests/saves.js,
tests/trust.js, tests/legs.js pass; tests/fixtures.js small-y5 and small-y40 made and checked, invariants pass (the medium saves
not made). The diagnosis probe, checkState every day: founders small 11, 30 years, and populous small 3, 12 years, clean.