Skip to main content

edda_derive/
types.rs

1use std::collections::BTreeMap;
2
3// ── Data structures ──
4
5#[derive(Debug, Clone)]
6pub struct CommitEntry {
7    pub ts: String,
8    pub event_id: String,
9    pub title: String,
10    pub purpose: String,
11    pub prev_summary: String,
12    pub contribution: String,
13    pub evidence_lines: Vec<String>,
14    pub labels: Vec<String>,
15}
16
17#[derive(Debug, Clone)]
18pub enum SignalKind {
19    NoteTodo,
20    NoteDecision,
21    CmdFail,
22}
23
24#[derive(Debug, Clone)]
25pub struct SignalEntry {
26    pub ts: String,
27    pub kind: SignalKind,
28    pub text: String,
29    pub event_id: String,
30    /// Event ID this decision supersedes (from refs.provenance).
31    pub supersedes: Option<String>,
32}
33
34#[derive(Debug, Clone)]
35pub struct MergeEntry {
36    pub ts: String,
37    pub event_id: String,
38    pub src: String,
39    pub dst: String,
40    pub reason: String,
41    pub adopted_commits: Vec<String>,
42}
43
44/// A task snapshot entry within a session digest.
45#[derive(Debug, Clone)]
46pub struct TaskSnapshotEntry {
47    pub subject: String,
48    pub status: String,
49}
50
51/// A session digest note extracted from the workspace ledger.
52pub struct SessionDigestEntry {
53    pub ts: String,
54    pub event_id: String,
55    pub session_id: String,
56    pub tool_calls: u64,
57    pub tool_failures: u64,
58    pub user_prompts: u64,
59    pub duration_minutes: u64,
60    pub files_modified: Vec<String>,
61    pub failed_commands: Vec<String>,
62    pub commits_made: Vec<String>,
63    pub tasks_snapshot: Vec<TaskSnapshotEntry>,
64    /// Session outcome: "completed", "interrupted", or "error_stuck".
65    pub outcome: String,
66    /// Session notes written by agent via `edda note --tag session`.
67    pub notes: Vec<String>,
68    /// Per-tool call counts (e.g. "Read" -> 15, "Edit" -> 8).
69    pub tool_call_breakdown: BTreeMap<String, u64>,
70    /// Ratio of edit tools (Edit, Write, NotebookEdit) to total tool calls.
71    pub edit_ratio: f64,
72    /// Ratio of search tools (Read, Grep, Glob, Agent) to total tool calls.
73    pub search_ratio: f64,
74    /// Activity classification for this session.
75    pub activity: String,
76}
77
78pub struct BranchSnapshot {
79    pub branch: String,
80    pub created_at: String,
81    pub last_event_id: Option<String>,
82    pub last_commit_id: Option<String>,
83    pub last_commit: Option<CommitEntry>,
84    pub commits: Vec<CommitEntry>,
85    pub signals: Vec<SignalEntry>,
86    pub merges: Vec<MergeEntry>,
87    pub session_digests: Vec<SessionDigestEntry>,
88    pub uncommitted_events: usize,
89}
90
91#[derive(Debug, Clone, Copy)]
92pub struct DeriveOptions {
93    pub depth: usize,
94}
95
96impl Default for DeriveOptions {
97    fn default() -> Self {
98        Self { depth: 5 }
99    }
100}