Skip to main content

modelrelay/workflow/
run.rs

1//! Workflow run status and result types.
2//!
3//! This module contains types for tracking workflow execution:
4//! - `RunStatusV0` - Status of a workflow run (from generated)
5//! - `NodeStatusV0` - Status of a node within a run (from generated)
6//! - `NodeErrorV0` - Error information for a failed node (from generated)
7//! - `RunCostSummaryV0` - Cost summary for a run (from generated)
8//! - `RunCostLineItemV0` - Individual cost line item (from generated)
9//! - `NodeResultV0` - Result of a completed node (hand-written for field naming)
10//! - `PayloadInfoV0` - Metadata about a payload
11
12use chrono::{DateTime, Utc};
13use serde::{Deserialize, Serialize};
14use serde_json::Value;
15
16use super::ids::{ArtifactKey, NodeId, Sha256Hash};
17use super::spec::NodeTypeV1;
18
19// Re-export types from generated module (single source of truth)
20pub use crate::generated::{
21    NodeErrorV0, NodeStatusV0, RunCostLineItemV0, RunCostSummaryV0, RunStatusV0,
22};
23
24/// Metadata about a payload (node output or run outputs).
25#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
26pub struct PayloadInfoV0 {
27    pub bytes: u64,
28    pub sha256: Sha256Hash,
29    pub included: bool,
30}
31
32/// Artifact reference plus payload metadata.
33#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
34pub struct PayloadArtifactV0 {
35    pub artifact_key: ArtifactKey,
36    pub info: PayloadInfoV0,
37}
38
39// NodeErrorV0 is now imported from crate::generated (identical structure)
40
41/// Result of a completed node.
42#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
43pub struct NodeResultV0 {
44    pub id: NodeId,
45    #[serde(rename = "type")]
46    pub node_type: NodeTypeV1,
47    pub status: NodeStatusV0,
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub started_at: Option<DateTime<Utc>>,
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub ended_at: Option<DateTime<Utc>>,
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub output: Option<Value>,
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub error: Option<NodeErrorV0>,
56}
57
58// RunCostSummaryV0 and RunCostLineItemV0 are now imported from crate::generated
59// (they use ProviderId and ModelId strong types from the OpenAPI spec)