StateReconstructor

Reconstructs full state from an initial state snapshot and sequential module-level deltas.

Each action captures only the changed module's state (a delta). Full state at any point can be reconstructed by starting from the initial state and applying deltas sequentially.

Usage:

val fullState = StateReconstructor.applyDelta(currentStateJson, "CounterModule", deltaJson)
val stateAtIndex = StateReconstructor.reconstructAtIndex(initialStateJson, actions, 5)

Functions

Link copied to clipboard
fun applyDelta(currentStateJson: String, moduleName: String, deltaJson: String): String

Applies a single module delta to the current full state JSON.

Link copied to clipboard
fun reconstructAtIndex(initialStateJson: String, actions: List<CapturedAction>, index: Int): String

Reconstructs the full state at a given action index by applying all deltas from index 0 through the given index onto the initial state.