Skip to main content

Module reducer

Module reducer 

Source
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§

ReplayVerification

Constants§

REDUCER_MUTATION_KINDS
Single source of truth for the event kinds whose mutations the reducer enforces. The no-op anchor frontier.created is excluded because it does not mutate state. Used by:

Functions§

apply_event
Apply one canonical event to state, mutating it in place.
replay_from_genesis
Replay an entire event log from genesis state.
verify_replay
Verify that state.events, when replayed from state.findings_at_genesis (or a derived genesis if absent), produces a frontier whose finding states match the materialized state. Returns the diff if any.