Status: done (2026-11-11)
Priority: 3
Size: S
Design ref: none (code structure). docs/architecture/target-v2.md, section 3.2 (events; Kim’s decision 25) and 4.1 (Workflows, rule 4).
Goal: A lower layer’s act reaches a higher layer by an event (Kim, 9 November): the lower module emits, higher modules subscribe at load and run at once, in load order, and cannot veto. Today five calls go the wrong way instead: sim/stakes, sim/territory and sim/herds call remember, and sim/claims calls tieOf, in sim/relations. Build the channel with these as its first use.
Acceptance criteria:
sim/records, or a new sim/events loaded before every emitter) gives on(kind, fn), at load only and sealed with the registries, and emit(st, kind, data), which calls the subscribers at once in the order they registered. Subscribers are code and never enter st; emit allocates nothing beyond its caller’s data.sim/stakes, sim/territory and sim/herds emit (a claim taken, a border lost, a bull lent) where they called remember; sim/relations subscribes and writes the same memories at the same point in the step, so the golden file holds.sim/claims no longer imports sim/relations: what it took from tieOf is passed in by its caller, or asked through a read that needs no import. If neither fits without a behaviour change, leave it and say why in the notes.tools/writes.js (or tools/rules.js) lists every event kind with its emitters and subscribers; a kind with no subscriber, or a subscriber to a kind nothing emits, fails npm test.BACKLOG.md: behaviour unchanged, tests/golden.json and tests/counters.json unchanged, npm run verify’s hard checks pass, its targets reported with their residuals.
Notes:log and personEvent stay as they are and nothing subscribes to the record.medium-ref (tools/sim.js --report counts, with a work counter if the channel loops over a growing list).sim/commands’ neighbourhood; otherwise beside it.Implementation notes (night run, 11 Nov 2026):
sim/events (src/sim/events.js, after sim/registry, layer kernel): on(kind, fn) guarded by the registry’s atLoad (so sealed at the first seed or load), emit(st, kind, data) loops the kind’s subscriber array in registration order; no allocation, no veto (return ignored). Subscribers are closures in a module-level Map, never in st.claimTaken {loser, taker} (sim/stakes), borderLost {loser, winner} (sim/territory), bullLent {borrower, lender} (sim/herds); each emitted where remember was called, with the aliveness and holder checks left at the emitter. sim/relations subscribes to all three and calls remember with the same arguments, synchronously, so the order of writes is unchanged.sim/claims -> sim/relations: the read tieOf (and its helper scaleOf, a pure read of pawn.ties and pawn.tieT) moved into sim/records (kernel); sim/relations imports them and still exports tieOf. The writes stay in relations. No caller had to change.tools/events.js scans the sources for emit(st, 'kind' and on('kind' and lists each kind with emitters and subscribers; tests/events.js (in npm test) fails on a kind with no subscriber or no emitter, and shows that a subscriber’s refused command changes nothing and the next subscriber still runs. tools/dependencies.js needs no exclusion for emit: it is a call down into the kernel, not an upward lookup (its comment says so).node tests/dependencies.js --update: 24 to 20 upward calls (claims, territory, stakes and herds, each -> sim/relations).sim/relations; no lines saved (about 60 added in the new module, tool and test).tests/counters.js unchanged, 0 out).node tests/golden.js matches, node tests/counters.js ok, npm test run after the last edit (see the final report).Orchestrator’s decisions for Kim to overturn:
tieOf lives in sim/records rather than being passed in by callers: passing it would have changed the signatures of CL.settle, support and their callers (stakes, territory, farmclaims) and pushed the upward import to them.loser/taker), allocated by the emitter; the kinds are not declared in a list, the tool finds them by scanning.