Skip to main content

Reporter

Struct Reporter 

Source
pub struct Reporter<'a> { /* private fields */ }
Expand description

Action-facing handle threaded into every action handler.

Implementations§

Source§

impl<'a> Reporter<'a>

Source

pub fn new( event_tx: &'a Sender<ExecEvent>, cmd_rx: &'a Receiver<UiCommand>, transcript: &'a mut dyn TranscriptSink, clock: Arc<dyn Clock>, ) -> Self

Build a reporter bound to the given channels, transcript sink, and clock.

Source

pub fn side_effects_emitted(&self) -> u64

Number of side-effect facts emitted so far in this run. Used by the executor to detect whether a step attempt performed work on the world before failing, which makes it unsafe to re-execute.

Source

pub fn seed_entropy(&mut self, m: &[u8])

Install the machine seed for the entropy source.

Called once by the runner at ceremony start, before any step can draw. Until this runs the source is absent and any draw fails. The caller is responsible for recording the corresponding StepFact::EntropySeeded so the source stays reconstructible from the transcript.

Source

pub fn set_current_step(&mut self, step: Option<StepId>)

Set the step that subsequent log lines and progress signals are attributed to. Called by the executor at each step boundary.

Source

pub fn current_step(&self) -> Option<&StepId>

The current step, if any. Mostly useful for tests.

Source

pub fn fact(&mut self, fact: StepFact) -> Result<(), ReporterError>

Record a transcript-worthy fact.

Facts are the audit record: everything durable flows through here, and it comes from an action in the plan (plus the runner’s own lifecycle facts). Writes to the transcript sink synchronously, then forwards to the UI as ExecEvent::Fact. The transcript is flushed before the UI observes the fact. To surface something to the operator without recording it, use Reporter::signal / Reporter::log instead.

§Errors

Returns ReporterError::Transcript if the sink fails to persist, or ReporterError::Disconnected if the frontend is gone.

Source

pub fn draw( &mut self, purpose: &str, len: usize, ) -> Result<Vec<u8>, ReporterError>

Draw len bytes from the ceremony entropy source for purpose.

The generic primitive behind every nonce, certificate serial, and challenge: the caller names a purpose, the source derives the value from the current epoch seed and records an StepFact::EntropyDrawn carrying the derivation path and value, so rite verify can re-derive it. Requires a current step (the path is step-scoped).

§Errors

ReporterError::NoCurrentStep if called outside a step, or ReporterError::Transcript / ReporterError::Disconnected if the fact cannot be emitted.

Source

pub fn fold_entropy(&mut self, contribution: &str) -> Result<(), ReporterError>

Fold a human entropy contribution into the seed, advancing the ratchet.

The contribution is public, witnessed entropy (the HMAC message keyed by the prior seed, never a secret), so any input is safe and only adds unpredictability. Records an StepFact::EntropyContributed carrying the verbatim contribution and the new epoch, so the chain re-folds identically on verification. Requires a current step.

§Errors

ReporterError::NoCurrentStep if called outside a step, or ReporterError::Transcript / ReporterError::Disconnected if the fact cannot be emitted.

Source

pub fn signal(&mut self, signal: UiSignal) -> Result<(), ReporterError>

Emit a raw UiSignal. Never recorded to the transcript.

Signals are ephemeral operator-assistance: a frontend may drop any of them without affecting correctness or the transcript. They are never promoted into the audit record; use Reporter::fact for anything that must persist. Most callers should use the specialized helpers (Reporter::log for narration, Reporter::progress for spinners). This method exists for structured signals (e.g. the pre-ceremony overview, the system snapshot) that don’t fit either shape.

§Errors

Returns ReporterError::Disconnected if the frontend is gone.

Source

pub fn log( &mut self, icon: Icon, text: impl Into<String>, ) -> Result<(), ReporterError>

Emit a UI-only narration line. Never recorded to the transcript.

§Errors

Returns ReporterError::Disconnected if the frontend is gone.

Source

pub fn progress( &mut self, phase: impl Into<String>, fraction: Option<f32>, ) -> Result<(), ReporterError>

Emit a progress signal (e.g. spinner phase, completion fraction).

Never recorded to the transcript. Requires a current step.

§Errors

Returns ReporterError::Disconnected or ReporterError::NoCurrentStep.

Source

pub fn check_abort(&mut self) -> Result<(), ReporterError>

Drain any pending commands. Returns ReporterError::Aborted if an abort command is in the queue.

Designed to be called liberally during long-running backend operations. try_recv on a crossbeam channel is on the order of nanoseconds, so the cost is negligible.

§Errors

Returns ReporterError::Aborted if abort was requested, or ReporterError::Disconnected if the frontend went away.

Source

pub fn prompt(&mut self, prompt: &Prompt) -> Result<Response, ReporterError>

Issue a prompt and block until a validated response is received.

While blocking, also handles UiCommand::Abort and UiCommand::LogDeviation so the user can deviate or abort mid-prompt. On rejection by the runtime’s validator, re-emits the prompt with the rejection reason attached so the frontend can surface it.

Automatically emits StepFact::PromptAnswered when the response is accepted.

§Errors

Returns ReporterError::Aborted if abort was requested, ReporterError::Disconnected if the frontend went away, or ReporterError::Transcript if the fact cannot be recorded.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Reporter<'a>

§

impl<'a> !Sync for Reporter<'a>

§

impl<'a> !UnwindSafe for Reporter<'a>

§

impl<'a> Freeze for Reporter<'a>

§

impl<'a> Send for Reporter<'a>

§

impl<'a> Unpin for Reporter<'a>

§

impl<'a> UnsafeUnpin for Reporter<'a>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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