Skip to main content

rite_runtime/
lib.rs

1//! Execution runtime for Rite ceremonies.
2//!
3//! `rite-runtime` defines the protocol that frontends use to drive a
4//! ceremony to completion, the executor that walks the ceremony plan,
5//! and the supporting machinery for transcripts and action handlers.
6//!
7//! # Key types
8//!
9//! - [`Executor`], channel-driven engine that walks a ceremony plan.
10//! - [`Action`] / [`ActionRegistry`], the handler trait and registry.
11//! - [`BackendRegistry`] / [`BackendFactory`], lazy backend store.
12//! - [`Reporter`], action-facing handle for facts, signals, and prompts.
13//! - [`TranscriptSink`], durable JSONL audit log with hash chaining.
14//!
15//! # Stability
16//!
17//! Internal crate. This is an implementation detail of the `rite` CLI, with no
18//! stable API and no semver guarantees across releases. Build against the
19//! public `rite-sdk`, `rite-model`, or `rite-resolver` crates instead.
20
21#![warn(missing_docs)]
22
23mod actions;
24mod artifact_resolver;
25mod backend;
26mod clock;
27mod display;
28mod entropy;
29mod executor;
30mod expressions;
31mod os_random;
32mod output_config;
33mod protocol;
34mod reporter;
35mod runner;
36mod state;
37mod step_info;
38mod system_info;
39pub mod test_support;
40mod transcript;
41mod transcript_sink;
42
43// Execution
44pub use executor::{ExecutionError, write_new_file};
45
46// Actions
47pub use actions::{ArtifactValue, Share, ShareSet};
48
49// Backend registry (traits live in `rite-sdk`, not here)
50pub use backend::{BackendFactory, BackendRegistry};
51
52pub use clock::{Clock, SystemClock};
53
54// Channel vocabulary for the runtime ↔ frontend boundary.
55// Persisted transcript types (`StepFact`, `Prompt`, `ResponseRecord`, …)
56// live in `rite_model::transcript` and are not re-exported here.
57pub use protocol::{
58    ExecEvent, Icon, MaterialOverview, MaterialOverviewKind, PromptId, Response, UiCommand,
59    UiSignal,
60};
61
62// Structured machine/build/environment facts carried by UI signals.
63pub use system_info::{
64    BackendVersion, BuildInfo, Disk, Environment, FeatureCheck, FeatureStatus, Hardening, HostInfo,
65    ParseError as SystemInfoParseError, StartupSnapshot, SystemInfo,
66};
67
68// Shared formatter for live frontends.
69pub use display::{fact_summary, signal_summary, truncate_for_display};
70
71// Entropy source: the single auditable source of ceremony randomness, plus
72// the pure `rite-kdf/v1` derivation used by both the draw path and `rite verify`.
73pub use entropy::{
74    CeremonyRandom, DERIVATION_V1, Draw, MAX_DRAW_LEN, build_path, derive_value, fold_seed,
75    initial_seed,
76};
77
78// Reporter: action-facing handle for facts, signals, and prompts.
79pub use reporter::{Reporter, ReporterError};
80
81// Executor and its action trait.
82pub use runner::{
83    Action, ActionError, ActionRegistry, ExecutionSummary, Executor, PRODUCER,
84    StepUnsupportedParam, parse_params,
85};
86
87// Transcript sink, the durable consumer of `StepFact`s.
88pub use transcript_sink::{
89    EntropyVerified, InMemorySink, JsonlFileSink, LoadedTranscript, TimedFact,
90    TranscriptFingerprint, TranscriptSink, TranscriptVerified, UnknownFact, VerifyError,
91    WithheldLine, disclose_transcript, read_verified_transcript, verify_entropy, verify_jsonl,
92    verify_transcript as verify_step_fact_transcript,
93};
94
95// State (needed by `Action` implementors in downstream crates).
96pub use state::{ExecutionState, HandlerContext, StepResult};
97pub use step_info::StepInfo;
98
99// Output / fingerprint helpers.
100pub use output_config::OutputConfig;
101pub use transcript::{compute_file_fingerprint, compute_fingerprint};
102
103// Expression evaluation (used by action implementors).
104pub use expressions::{
105    evaluate, evaluate_expr_value, evaluate_expr_value_to_string, value_to_json,
106};
107
108// Artifact resolution (used by action implementors).
109pub use artifact_resolver::{
110    BackendKeyMeta, resolve_artifact_bytes, resolve_backend_key, resolve_share,
111};