Multi-version state management keeps system data immutable while allowing a mutable reference to select the current version. Instead of changing a hash map in place, each mutation produces a new version, then advances the state reference. Structural sharing reuses unchanged data, avoiding an expensive deep copy. section 4.1 section 4.8
A mutation separates the risky work from the small stateful boundary:
- Calculation computes the next data version with stateless, immutable functions. section 4.0 section 4.8
- Commit validates the complete result and moves the system reference forward. section 4.0 section 4.8
- Structural sharing preserves unchanged portions across versions, keeping memory use practical. section 4.1 section 4.7
Undoing a committed mutation
Suppose systemData points to V12 and previousSystemData to V11. Committing a mutation advances them to V13 and V12. Undoing the mutation makes systemData point back to V12, reusing the retained immutable version rather than reconstructing it. section 4.7
Table 4.1 The two phases of a mutation (view table figure)
Compare calculation and commit by responsibility, statefulness, and whether their implementation is specific or common. section 4.0
