Skip to main content

CheckpointWriter

Struct CheckpointWriter 

Source
pub struct CheckpointWriter { /* private fields */ }
Expand description

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).

Implementations§

Source§

impl CheckpointWriter

Source

pub fn new( path: PathBuf, session: String, started_at: String, invocation: u32, ) -> Self

Construct a fresh writer for a brand-new session. Emits the leading session_start record before returning. Subsequent declare_phase / lifecycle calls append events onto the same log.

Source

pub fn from_existing( path: PathBuf, doc: Checkpoint, new_checkpoint_at: String, new_invocation: u32, ) -> Self

Restore a writer from a previously-written document on resume. The caller is responsible for having parsed and version-checked the document via super::storage::read. The restored writer keeps the existing phase entries and emits a fresh session_start event with the new invocation counter — appending continues onto the same JSONL log per SRD-44a.

Source

pub fn disabled(path: PathBuf) -> Self

A resume-inert writer for dry-runs: no checkpoint.jsonl is created, no flock is taken, and every lifecycle event is dropped before it reaches disk. A dry-run short-circuits ops and may run against placeholder params, so persisting its phases as “completed” would poison a later --resume-latest (SRD-44) — this constructor guarantees it can’t. The file handle targets /dev/null purely to keep the struct total; append_event never writes to it.

Source

pub fn declare_phase(&self, identity: PhaseIdentity, skip_eligible: bool)

Declare a phase the run plans to execute. Called during pre-map for every phase; idempotent (re-declaration is a no-op so the resume path can declare the same phases the saved doc already lists).

Source

pub fn phase_started(&self, identity: &PhaseIdentity)

Mark a declared phase as Running.

Source

pub fn phase_completed(&self, identity: &PhaseIdentity, duration_secs: f64)

Mark a declared phase as Completed with the given wall-clock duration.

Source

pub fn phase_failed(&self, identity: &PhaseIdentity, error: &str)

Mark a declared phase as Failed. The error message is preserved for resume diagnostics.

Source

pub fn update_op_counts(&self, identity: &PhaseIdentity, counts: OpCounts)

Record op-execution counts from the live activity. Called from the metrics tick callback for the currently-running phase. Folds into the matching PhaseEntry and emits one phase_progress event per call — the reader keeps only the most recent per identity when folding.

Source

pub fn update_phase_hash( &self, identity: &PhaseIdentity, hash: [u8; 32], params_consumed: Option<String>, )

Set the program-canonical hash on a declared phase.

Source

pub fn update_cursor(&self, identity: &PhaseIdentity, cursor_state: Value)

Record the latest cursor-state snapshot for a Tier 2 phase.

Source

pub fn emit_scope_enter( &self, kind: &str, coords: BTreeMap<String, Value>, path: Vec<BTreeMap<String, Value>>, )

Emit a scope_enter event marking entry into a for_each / for_combinations / do_while / do_until iteration. Per SRD-44a §“Event taxonomy”, coords is the {var: value} map for THIS scope’s own bindings and path is the leaf-first chain of enclosing scopes’ coords — together they pin the executor’s position in the scenario tree at iteration time. Scope events are write-and-go: the in-memory mirror has no slot to fold them into (the reader’s fold is also a no-op today), so this is one direct append_event.

Source

pub fn emit_scope_exit( &self, kind: &str, coords: BTreeMap<String, Value>, path: Vec<BTreeMap<String, Value>>, outcome: &str, )

Emit a scope_exit event marking the end of one iteration. outcome is "completed" when the iteration’s terminal action returned Ok, "interrupted" when it returned an error or the executor unwound through a stop signal. Same write-and-go shape as emit_scope_enter.

Source

pub fn flush(&self) -> Result<(), String>

Force a fdatasync(2) on the underlying log. Per SRD-44a §“Writer behaviour”, lifecycle records (start / completed / failed) deserve a per-event sync; the periodic progress tick can batch. The runtime calls this at every phase-lifecycle boundary so a crash between ticks loses at most one tick’s worth of progress.

Source

pub fn snapshot(&self) -> Checkpoint

Read-only snapshot of the current in-memory document. Useful for diagnostics and tests.

Source

pub fn mark_run_reached_end(&self)

Record that the runner reached its session-end boundary (the convergence point right before run_finished()). Early error returns and interrupts never get here, so the flag cleanly separates “the run ended” from “the run was cut short” for Self::resume_hint.

Source

pub fn resume_hint(&self) -> Option<String>

If the workload has incomplete phases declared checkpoint: idempotent, return a multi-line hint string the runtime can show the operator on exit.

Source

pub fn path(&self) -> &Path

Path the writer flushes to.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more