Skip to main content

Module writer

Module writer 

Source
Expand description

CheckpointWriter — append-only event-log owner for the per-session checkpoint document. SRD-44a §“Writer behaviour”.

Per SRD-44a, every state-changing observation is one event line written to logs/<session>/checkpoint.jsonl. The writer:

  • is created at session bootstrap (or restored from a saved document on resume) — emits a session_start event,
  • has phases declared into it during pre-map — one phase_declared event each,
  • receives phase-lifecycle calls (phase_started, phase_completed, phase_failed) — one event per call,
  • receives op-count and cursor-state updates from the metrics tick callback — one phase_progress event per tick.

No whole-document rewrite. The file is opened in append mode (O_APPEND); each event is a single \n-terminated line. In-memory state is the same Checkpoint document as before so snapshot() and resume_hint() keep working without re-folding from disk.

The writer is Send + Sync (interior mutex) so the executor, the tick callback, and the cursor-state collector can all hold one Arc<CheckpointWriter>.

Structs§

CheckpointWriter
Writer-side handle to the per-session checkpoint event log. One instance per session; held as Arc<CheckpointWriter> and shared between the executor (lifecycle calls) and the metrics tick (count + cursor + flush calls).

Constants§

CHECKPOINT_VERSION
On-disk checkpoint version this build emits / accepts. Bump only when an incompatible schema change ships; resume against a different version is rejected at read time.