Skip to main content

Module storage

Module storage 

Source
Expand description

Checkpoint storage — fold-state types + JSONL event-log reader.

See SRD-44a §“Reader behaviour” for the fold algorithm. Checkpoint is the in-memory representation produced by folding the on-disk checkpoint.jsonl event stream; each per-phase PhaseEntry records the entry’s identity, status, and any cursor state for in-flight Tier 2 resume.

Structs§

Checkpoint
In-memory checkpoint state — the fold of an append-only JSONL event stream at logs/<session>/checkpoint.jsonl. One per session. Per SRD-44a, the on-disk format is the event log; this struct is what consumers (resume planner, summary report) see after reading and folding.
EventIter
Iterator over CheckpointData records from a JSONL log.
OpCounts
Op-execution counts captured on every flush.
PhaseEntry
Per-phase entry in the checkpoint document.

Enums§

PhaseStatus
Lifecycle status as recorded in the checkpoint file. Mirrors crate::scene_tree::PhaseStatus semantically; kept as a separate type so the on-disk vocabulary doesn’t coupled-evolve with scene-tree internal status (e.g. if we ever add a transient state for a runtime invariant that has no on-disk meaning, the storage type stays clean).

Functions§

iter_events
Stream events from the JSONL log at path. Returns an iterator over CheckpointData records; malformed lines surface as Err items so the caller decides whether to stop or continue. Truncated-tail recovery is handled by read’s fold; this function is the lower-level building block for diagnostics tools that want raw event streams.
now_rfc3339
Format the current wall-clock time as an RFC 3339 UTC timestamp, e.g. 2026-01-01T00:00:00Z. Used by the writer for started_at / checkpoint_at and by the runner when stamping a fresh session. Local implementation to avoid dragging chrono in for one call site.
read
Read and fold every event in path into a Checkpoint. Returns Ok(None) when the file doesn’t exist (fresh session); returns Err only on hard parse failures mid-stream. A truncated last line is recovered with a Warn per SRD-44a §“Truncated-tail recovery”.