Status: done (2026-11-02)
Priority: 1
Size: M
Arch: core
Phase: implement
Design ref: Commands, time steps and views (Unified commands: Decided); answers to VB-076 in QUESTION_ARCHIVE.md (Kim, 30 Oct: every proposal accepted).
Goal: Pawns act only through commands, so the player or a debug tool can take control without changing the systems below. Today planRound (src/sim/jobs.js) matches a pawn to a job and calls start (src/sim/agents.js) in the same step, as do the interrupt and the joining of helpers. This first step puts a command between choosing and acting, with no change in behaviour.
Acceptance criteria:
src/sim/commands.js (@sys sim/commands): a command is plain data {actor, verb, target, args, source} (actor a pawn id; target a job key for work; source planner, later player, debug, meeting, round). issue(st, cmd) checks the command and carries it out through a table of verbs, returning true, or the reason it was refused as a string; it changes nothing when it refuses.work: the actor is alive and has an agent, the job is in st.jobs and has room for another pair of hands (as planRound counts it); the pawn releases its current job, if any, and starts the new one (today’s release and start).start in src/sim/jobs.js (the matching round, the interrupt and the helpers who join) becomes issue(st, { actor, verb: 'work', target: j.key, source: 'planner' }); outside src/sim/commands.js and src/sim/agents.js nothing calls start, checked statically by a test (the tokenizer of tools/wrap.js, as tests/record.js checks log).tests/commands.js (npm test): a work command is carried out as start would; refusals for a dead actor, an unknown job and a job with no room leave the state unchanged (its canonical text the same).tests/golden.json unchanged; npm run verify passes; jobs time in tools/sim.js --report perf (populous small, seed 7, 3 years) within 5% of before, both reported in the PR.src/sim/commands.js (issue, VERBS), listed between sim/agents and sim/jobs; the three calls of start in src/sim/jobs.js (the cooks called off other work, the look-up for better work, the matching round) issue work from planner. Golden file unchanged (the commands module is not in the Sim API yet). tests/commands.js (npm test) checks the verb, five refusals (a dead actor, no such pawn, no such job, no such verb, a job with no room) leaving the state’s canonical text unchanged, and statically that only sim/commands calls start (its list WRAPPED grows with VB-168).tools/sim.js --report perf, populous small, seed 7, 3 years, jobs refresh and matching: two runs before 2,033 and 1,819 ms (18.6% and 18.4% of the simulation), after 2,148 and 1,833 ms (18.6%, 18.7%); means 1,926 and 1,990 ms, +3.4%, with runs of the same code apart by up to 11%.