Skip to main content

Module fold

Module fold 

Source
Expand description

The deterministic left-fold over a risk’s events and the status machine that governs lifecycle transitions.

The fold is a pure function of the event list: last-write-wins per field, status follows the latest lifecycle event, finding refs accumulate. The status machine (see docs/risks.md) is enforced at append time so an illegal status-changed never lands in the log.

Structs§

TransitionError
An attempted lifecycle transition that the status machine rejects.

Functions§

fold
Fold events in seq order into the current RiskState.
fold_at
fold restricted to events dated at or before cutoff — the risk’s state as of that day’s end. Borrows the slice, never clones events. Returns None when no event qualifies. Same contract as fold otherwise: the first qualifying event must be opened.
validate_transition
The status machine, as drawn in docs/risks.md: