pub struct Reporter<'a> { /* private fields */ }Expand description
Action-facing handle threaded into every action handler.
Implementations§
Source§impl<'a> Reporter<'a>
impl<'a> Reporter<'a>
Sourcepub fn new(
event_tx: &'a Sender<ExecEvent>,
cmd_rx: &'a Receiver<UiCommand>,
transcript: &'a mut dyn TranscriptSink,
clock: Arc<dyn Clock>,
) -> Self
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.
Sourcepub fn side_effects_emitted(&self) -> u64
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.
Sourcepub fn seed_entropy(&mut self, m: &[u8])
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.
Sourcepub fn set_current_step(&mut self, step: Option<StepId>)
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.
Sourcepub fn current_step(&self) -> Option<&StepId>
pub fn current_step(&self) -> Option<&StepId>
The current step, if any. Mostly useful for tests.
Sourcepub fn fact(&mut self, fact: StepFact) -> Result<(), ReporterError>
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.
Sourcepub fn draw(
&mut self,
purpose: &str,
len: usize,
) -> Result<Vec<u8>, ReporterError>
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.
Sourcepub fn fold_entropy(&mut self, contribution: &str) -> Result<(), ReporterError>
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.
Sourcepub fn signal(&mut self, signal: UiSignal) -> Result<(), ReporterError>
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.
Sourcepub fn log(
&mut self,
icon: Icon,
text: impl Into<String>,
) -> Result<(), ReporterError>
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.
Sourcepub fn progress(
&mut self,
phase: impl Into<String>,
fraction: Option<f32>,
) -> Result<(), ReporterError>
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.
Sourcepub fn check_abort(&mut self) -> Result<(), ReporterError>
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.
Sourcepub fn prompt(&mut self, prompt: &Prompt) -> Result<Response, ReporterError>
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.