Skip to main content

ri_agent_graph/
receipt.rs

1//! Receipt types for graph execution auditability.
2//!
3//! Receipts capture the full state of graph execution steps for replay,
4//! debugging, and compliance auditing.
5
6use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8
9/// Digests the full state of a graph execution step for auditability.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct StepExecutionReceiptV1 {
12    pub step_index: usize,
13    pub agent_id: String,
14    pub started_at: DateTime<Utc>,
15    pub finished_at: DateTime<Utc>,
16    pub input_digest: String,
17    pub output_digest: String,
18    pub tool_calls: Vec<ToolCallReceipt>,
19    pub error: Option<String>,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct ToolCallReceipt {
24    pub tool_name: String,
25    pub arguments_digest: String,
26    pub result_digest: String,
27    pub duration_ms: u64,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct GraphExecutionReceiptV1 {
32    pub graph_id: String,
33    pub execution_id: String,
34    pub started_at: DateTime<Utc>,
35    pub finished_at: DateTime<Utc>,
36    pub steps: Vec<StepExecutionReceiptV1>,
37    pub outcome: ExecutionOutcome,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub enum ExecutionOutcome {
42    Completed,
43    Partial { failed_step: usize },
44    Cancelled,
45    InternalError { message: String },
46}