Expand description
Pure separable reducer over canonical events.
apply_event is the deterministic state-transition function: given a
Project and a StateEvent, it produces the next Project. It does
not construct events, validate proposals, or call into network code.
It is the inverse pole of proposals::apply_proposal, which prepares
an event from a proposal and a current state.
Why this matters: v0 doctrine says “proposal → canonical event →
reducer → replayable frontier state.” Until v0.3, the reducer step was
implicit inside apply_proposal — replay was hash-walking, not
reduction. Phase C of the v0.3 focusing run pulls the reducer out so a
second implementation can independently reduce a canonical event log
and produce byte-identical state.
Replay verification (replay_from_genesis + verify_replay) is the
check that turns “state was claimed to result from these events” into
“state demonstrably results from these events when re-derived from
scratch.”
Structs§
Constants§
- REDUCER_
MUTATION_ KINDS - Single source of truth for the event kinds whose mutations the
reducer enforces. The no-op anchor
frontier.createdis excluded because it does not mutate state. Used by:
Functions§
- apply_
event - Apply one canonical event to
state, mutating it in place. - apply_
event_ indexed - v0.105: indexed dispatch. Used by
replay_from_genesisso the finding-id index gets built once and reused across every event.apply_eventbuilds the index lazily for one-off callers. - build_
finding_ index - Build the finding-id index from the current state. O(N) once.
- replay_
from_ genesis - Replay an entire event log from genesis state.
- verify_
replay - Verify that
state.events, when replayed fromstate.findings_at_genesis(or a derived genesis if absent), produces a frontier whose finding states match the materializedstate. Returns the diff if any.
Type Aliases§
- Finding
Index - v0.105: per-replay finding-id index. Keys are content-addressed
finding ids; values are positions into
state.findings. Replay builds this once from genesis state and updates it in lockstep withfinding.assertedpushes. Per-kind apply functions look up their target viaidx.get(...)instead of an O(N) linear scan. findings are append-only in the substrate (no removals), so the index never goes stale; positions remain valid for the life of a replay.