Skip to main content

fold

Function fold 

Source
pub fn fold(ops: &[OpRecord]) -> SyncState
Expand description

Fold an op-set into its materialized state. Order-independent (per-key winner selection under a total order), idempotent (ops dedup on op_id first), and pure.

ยงInput contract: verify before folding untrusted input

fold does NOT verify ids or chains โ€” that is the explicit, separate crate::oplog::verify_log pass, and any caller feeding ops from a remote/untrusted source (the B3 relay pull path) MUST run it first. fold stays order-independent even on invalid input (two records forging the same claimed op_id with different content dedup by a content-deterministic tiebreak, not arrival order), but which forged record wins is meaningless โ€” verification is what makes the answer mean something.