Skip to main content

envoy/
types.rs

1use serde::{Deserialize, Serialize};
2
3/// A communication channel that agents publish events to.
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct Channel {
6    pub id: i64,
7    pub name: String,
8    pub description: String,
9    #[serde(default)]
10    pub created_at: String,
11}
12
13/// An immutable event in a channel's append-only log.
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct Event {
16    pub id: i64,
17    pub channel_id: i64,
18    pub channel_name: String,
19    pub sender: String,
20    pub payload: EventPayload,
21    pub timestamp: String,
22    pub sequence_id: i64,
23}
24
25/// The required fields every coordination message must carry.
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct EventPayload {
28    pub status: AgentStatus,
29    pub working_on: String,
30    #[serde(default)]
31    pub waiting_for: Option<String>,
32    #[serde(default)]
33    pub can_start: Option<String>,
34    #[serde(default)]
35    pub verified: bool,
36    #[serde(default)]
37    pub magellan_trace: Option<MagellanTrace>,
38    #[serde(default)]
39    pub extra: serde_json::Value,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
43#[serde(rename_all = "lowercase")]
44pub enum AgentStatus {
45    Working,
46    Waiting,
47    Blocked,
48    Done,
49}
50
51/// Proof of what code actually changed, verifiable against the live magellan index.
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct MagellanTrace {
54    #[serde(default)]
55    pub files_changed: Vec<String>,
56    #[serde(default)]
57    pub symbols_added: Vec<String>,
58    #[serde(default)]
59    pub symbols_removed: Vec<String>,
60    #[serde(default)]
61    pub db_state: Option<MagellanDbState>,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct MagellanDbState {
66    pub schema_version: u32,
67    pub symbol_count: u64,
68}
69
70/// Subscription info for an agent.
71#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct Subscription {
73    pub agent_id: String,
74    pub channel_id: i64,
75    pub channel_name: String,
76    pub last_seen_sequence: i64,
77    #[serde(default)]
78    pub created_at: String,
79    #[serde(default)]
80    pub updated_at: String,
81}
82
83/// Engine-level statistics.
84#[derive(Debug, Clone, Serialize, Deserialize)]
85pub struct EngineStats {
86    pub channels: i64,
87    pub events: i64,
88    pub subscriptions: i64,
89}