1use crate::{
2 ActorRef, ArtifactRef, DecisionId, EvalId, FrameId, GoalId, HypothesisId, NodeId,
3 ObservationId, ProjectRef, RunId, TaskId,
4};
5use serde::{Deserialize, Serialize};
6use serde_json::{Value as JsonValue, json};
7
8pub const KIND_GOAL: &str = "goal";
9pub const KIND_TASK: &str = "task";
10pub const KIND_RUN: &str = "run";
11pub const KIND_OBSERVATION: &str = "observation";
12pub const KIND_FAILURE: &str = "failure";
13pub const KIND_HYPOTHESIS: &str = "hypothesis";
14pub const KIND_PATCH: &str = "patch";
15pub const KIND_EVAL: &str = "eval";
16pub const KIND_DECISION: &str = "decision";
17pub const KIND_PROJECT_SNAPSHOT: &str = "project_snapshot";
18pub const KIND_MODEL_CALL: &str = "model_call";
19pub const KIND_TOOL_CALL: &str = "tool_call";
20pub const KIND_FRAME: &str = "frame";
21
22pub const REL_SERVES: &str = "serves";
23pub const REL_BLOCKS: &str = "blocks";
24pub const REL_ADVANCES: &str = "advances";
25pub const REL_OBSERVES: &str = "observes";
26pub const REL_EXPLAINS: &str = "explains";
27pub const REL_ADDRESSES: &str = "addresses";
28pub const REL_MODIFIES: &str = "modifies";
29pub const REL_VALIDATED_BY: &str = "validated_by";
30pub const REL_APPROVED_BY: &str = "approved_by";
31pub const REL_REJECTED_BY: &str = "rejected_by";
32pub const REL_PRODUCED_BY: &str = "produced_by";
33pub const REL_DERIVED_FROM: &str = "derived_from";
34pub const REL_DEPENDS_ON: &str = "depends_on";
35pub const REL_SUPERSEDES: &str = "supersedes";
36pub const REL_CONTAINED_IN_FRAME: &str = "contained_in_frame";
37pub const REL_FORKED_FROM: &str = "forked_from";
38pub const REL_REFERENCES: &str = "references";
39
40#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
41pub enum GoalStatus {
42 Open,
43 InProgress,
44 Satisfied,
45 Abandoned,
46 Blocked,
47 Stale,
48}
49
50#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
51pub enum TaskStatus {
52 Open,
53 InProgress,
54 Done,
55 Blocked,
56 Abandoned,
57 Stale,
58}
59
60#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
61pub enum EvalStatus {
62 Started,
63 Passed,
64 Failed,
65 Error,
66 Skipped,
67}
68
69#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
70pub enum DecisionStatus {
71 Pending,
72 Approved,
73 Rejected,
74 Superseded,
75}
76
77#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
78pub enum BehaviorStatus {
79 Enabled,
80 Disabled,
81 Error,
82}
83
84#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
85pub enum PolicyStatus {
86 Enabled,
87 Disabled,
88}
89
90#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
91pub enum ForkStatus {
92 Open,
93 Merged,
94 Abandoned,
95}
96
97#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
98pub struct Goal {
99 pub id: GoalId,
100 pub title: String,
101 pub summary: String,
102 pub status: GoalStatus,
103 pub owner: ActorRef,
104 pub metadata: JsonValue,
105}
106
107impl Goal {
108 pub fn new(
109 id: GoalId,
110 title: impl Into<String>,
111 summary: impl Into<String>,
112 owner: ActorRef,
113 ) -> Self {
114 Self {
115 id,
116 title: title.into(),
117 summary: summary.into(),
118 status: GoalStatus::Open,
119 owner,
120 metadata: json!({}),
121 }
122 }
123}
124
125#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
126pub struct Task {
127 pub id: TaskId,
128 pub title: String,
129 pub summary: String,
130 pub status: TaskStatus,
131 pub goal: Option<GoalId>,
132 pub created_by: ActorRef,
133 pub metadata: JsonValue,
134}
135
136#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
137pub struct Observation {
138 pub id: ObservationId,
139 pub title: String,
140 pub summary: String,
141 pub observed_in: Option<RunId>,
142 pub metadata: JsonValue,
143}
144
145#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
146pub struct Hypothesis {
147 pub id: HypothesisId,
148 pub title: String,
149 pub summary: String,
150 pub confidence: Option<f64>,
151 pub metadata: JsonValue,
152}
153
154#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
155pub struct EvalResult {
156 pub id: EvalId,
157 pub command: String,
158 pub status: EvalStatus,
159 pub score: Option<f64>,
160 pub metadata: JsonValue,
161}
162
163#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
164pub struct Decision {
165 pub id: DecisionId,
166 pub status: DecisionStatus,
167 pub reason: String,
168 pub decided_by: ActorRef,
169 pub metadata: JsonValue,
170}
171
172#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
173pub struct ProjectSnapshot {
174 pub id: NodeId,
175 pub project: ProjectRef,
176 pub artifacts: Vec<ArtifactRef>,
177 pub metadata: JsonValue,
178}
179
180#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
181pub struct ModelCall {
182 pub id: NodeId,
183 pub run_id: RunId,
184 pub model: String,
185 pub prompt_summary: String,
186 pub output_summary: Option<String>,
187 pub metadata: JsonValue,
188}
189
190#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
191pub struct ToolCall {
192 pub id: NodeId,
193 pub run_id: RunId,
194 pub tool: String,
195 pub input_summary: String,
196 pub output_summary: Option<String>,
197 pub success: Option<bool>,
198 pub metadata: JsonValue,
199}
200
201#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
202pub struct Frame {
203 pub id: FrameId,
204 pub title: String,
205 pub summary: String,
206 pub parent: Option<FrameId>,
207 pub metadata: JsonValue,
208}