salvor_replay/park.rs
1//! [`ParkReason`]: why a run stopped short of completing.
2//!
3//! A run parks for exactly two reasons, and both are recorded in the log
4//! before anything stops: a tool suspended the run
5//! ([`Event::Suspended`](crate::Event::Suspended)), or a declared budget was
6//! crossed ([`Event::BudgetExceeded`](crate::Event::BudgetExceeded)). This
7//! type names that pair and carries the fields a caller needs in order to act
8//! on it: the schema a resume input must satisfy, or the budget and the
9//! observed value that crossed it.
10//!
11//! # Purity
12//!
13//! Every field here is read back out of recorded events, so the vocabulary
14//! belongs with the event model rather than at the IO edge that produced it.
15//! A renderer that turns a parked run into text needs these names without
16//! needing the runtime, the store, or an executor behind them.
17
18use serde_json::Value;
19
20use crate::event::Budget;
21
22/// Why a run parked instead of completing.
23#[derive(Debug, Clone)]
24pub enum ParkReason {
25 /// A tool suspended the run, awaiting input matching the schema.
26 Suspended {
27 /// The recorded suspension reason.
28 reason: String,
29 /// The JSON Schema the resume input must satisfy.
30 input_schema: Value,
31 },
32 /// A declared budget was crossed. Resume may carry an extension.
33 BudgetExceeded {
34 /// The crossed budget, with its effective limit.
35 budget: Budget,
36 /// The observed value that crossed it.
37 observed: f64,
38 },
39}