Skip to main content

Module state

Module state 

Source
Expand description

Epoch+Phase state CRDT for work item lifecycle.

The lifecycle state (Open/Doing/Done/Archived) uses a non-standard (epoch, phase) CRDT that handles concurrent close/reopen correctly: if agent A closes an item while agent B reopens it, the higher epoch wins.

§Phase Ranking

Phases have a total ordering: Open(0) < Doing(1) < Done(2) < Archived(3)

§Merge Rules

Given two EpochPhaseState values a and b:

  1. If a.epoch != b.epoch: the one with higher epoch wins entirely.
  2. If a.epoch == b.epoch: the one with higher phase rank wins.

This satisfies the semilattice laws (commutative, associative, idempotent).

§Reopen Semantics

To reopen an item, increment the epoch and set phase to Open. This guarantees the reopen wins against any concurrent operations in the previous epoch.

Structs§

EpochPhaseState
CRDT state combining an epoch counter with a lifecycle phase.

Enums§

Phase
Work item lifecycle phase with total ordering by rank.
StateError
Error for invalid state transitions.