Skip to main content

areev_run/
lib.rs

1//! # areev-run — the `areev run` driver
2//!
3//! A host over Areev (governed-agents §4), peer of `areev-mcp`: executes
4//! OMS Workflow grains through the pure scheduler (`areev-run-core`),
5//! journaling every effect as content-addressed grains — intent before
6//! dispatch, result as a supersession re-stating identity and links — with
7//! checkpoints per superstep, resume from the file alone, HITL respond with
8//! separation of duties, budgets, cancel, and journal-consistent `verify`.
9//!
10//! The replay contract (§5, stated honestly): the **journal** is
11//! exactly-once — a result-journaled effect is never re-executed or
12//! double-counted, across interrupts and across crashes. The **external
13//! effect** is at-most-once per attempt in normal operation and
14//! at-least-once across the dispatch-to-result crash window: a dangling
15//! intent re-delivers under the same idempotency key and the redelivery is
16//! journaled as an Observation — recorded, never silent.
17
18pub mod clock;
19pub mod executor;
20pub mod journal;
21pub mod manifest;
22pub mod otel;
23pub mod reducers;
24pub mod runner;
25pub mod stream;
26
27pub use clock::{Clock, ScriptedClock, SystemClock};
28pub use executor::{CommandExecutor, ExecResult, ExecutorRegistry, HostToolExecutor};
29pub use manifest::{BudgetsSpec, ForkBase, PinnedTool, RunManifest};
30pub use runner::{CrashPoint, OnDangling, RunOptions, Runner};
31pub use otel::OtelObserver;
32pub use stream::{RunEvent, RunObserver};
33// Downstream hosts (MCP, bindings) speak the run vocabulary without a
34// direct run-core dependency.
35pub use areev_run_core::{FailCause, RunError as CoreRunError, RunOutcome as CoreRunOutcome};
36
37use areev_core::error::AreevError;
38use areev_run_core::{RunError, RunOutcome};
39
40/// Map a store failure into the RUN domain (the underlying `DOMAIN-Ennn`
41/// message survives in the detail).
42pub fn err_run(e: AreevError) -> RunError {
43    RunError::Storage { detail: e.to_string() }
44}
45
46/// What a drive returned to its caller.
47#[derive(Debug, Clone)]
48pub enum RunSession {
49    Finished { outcome: RunOutcome, run_id: String },
50    /// Parked on Client asks; the envelope is the §6.6 `requires_action`
51    /// shape, addressed by `tool_call_id`.
52    Parked { envelope: serde_json::Value, run_id: String },
53}
54
55/// One verify finding (§5.5 tiers, labeled output).
56#[derive(Debug, Clone, serde::Serialize)]
57pub struct VerifyStep {
58    pub superstep: u64,
59    pub verdict: String,
60    pub ok: bool,
61}
62
63/// The verify report: journal-consistency per checkpoint, honest about what
64/// was NOT verifiable (missing results, parks).
65#[derive(Debug, Clone, Default, serde::Serialize)]
66pub struct VerifyReport {
67    pub verified: bool,
68    pub steps: Vec<VerifyStep>,
69}
70
71/// One run's row in a shadow evaluation (§8 Wave 4): replayed entirely from
72/// its journal — zero effect dispatches by construction (the shadow path
73/// holds no executor, no pool, and no LLM; there is nothing to dispatch TO).
74#[derive(Debug, Clone, serde::Serialize)]
75pub struct ShadowRun {
76    pub run_id: String,
77    /// Journal-consistent under replay?
78    pub consistent: bool,
79    /// Effects answered FROM THE JOURNAL during the replay.
80    pub effects_replayed: u64,
81    /// Per-step verdicts (the verify report's rows).
82    pub steps: Vec<VerifyStep>,
83}
84
85/// A shadow evaluation over N journaled runs — the §7.4 pre-apply check for
86/// Tier-B code ("shadow replay of N recent journaled runs, zero effect
87/// dispatches, before Apply").
88#[derive(Debug, Clone, Default, serde::Serialize)]
89pub struct ShadowReport {
90    pub runs: Vec<ShadowRun>,
91    /// Every run journal-consistent?
92    pub all_consistent: bool,
93    /// Always 0 — stated in the report so the gate's claim is explicit in
94    /// the artifact, not implied by the code.
95    pub effect_dispatches: u64,
96}