agtrace_index/records.rs
1use agtrace_types::{ProjectHash, RepositoryHash, SpawnContext};
2
3/// Project metadata record from the index database.
4///
5/// Stores project-level information discovered during scanning.
6#[derive(Debug, Clone)]
7pub struct ProjectRecord {
8 /// Project identifier (hash of root path).
9 pub hash: ProjectHash,
10 /// Absolute path to project root directory, if known.
11 pub root_path: Option<String>,
12 /// Last time this project was scanned (ISO 8601 timestamp).
13 pub last_scanned_at: Option<String>,
14}
15
16/// Complete session record from the index database.
17///
18/// Contains all indexed metadata for a session, including validity status.
19/// Used internally by the index layer.
20#[derive(Debug, Clone)]
21pub struct SessionRecord {
22 /// Session UUID.
23 pub id: String,
24 /// Project this session belongs to.
25 pub project_hash: ProjectHash,
26 /// Git repository hash for worktree support (None for non-git directories).
27 pub repository_hash: Option<RepositoryHash>,
28 /// Provider name (claude, codex, gemini).
29 pub provider: String,
30 /// Session start timestamp (ISO 8601).
31 pub start_ts: Option<String>,
32 /// Session end timestamp (ISO 8601), if completed.
33 pub end_ts: Option<String>,
34 /// First user message snippet for display.
35 pub snippet: Option<String>,
36 /// Whether the session was successfully parsed and validated.
37 pub is_valid: bool,
38 /// Parent session ID for subagent sessions.
39 pub parent_session_id: Option<String>,
40 /// Spawn context for subagent sessions (turn/step where spawned).
41 pub spawned_by: Option<SpawnContext>,
42}
43
44/// Log file metadata record from the index database.
45///
46/// Tracks individual log files that contribute to sessions.
47#[derive(Debug, Clone)]
48pub struct LogFileRecord {
49 /// Absolute path to the log file.
50 pub path: String,
51 /// Session UUID this file belongs to.
52 pub session_id: String,
53 /// File role (main, metadata, etc.).
54 pub role: String,
55 /// File size in bytes.
56 pub file_size: Option<i64>,
57 /// File modification time (ISO 8601 timestamp).
58 pub mod_time: Option<String>,
59}
60
61/// Lightweight session summary for list operations.
62///
63/// Returned by session listing APIs. Contains only the essential
64/// information needed for session selection and preview.
65/// This is the primary type SDK users interact with when browsing sessions.
66#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
67pub struct SessionSummary {
68 /// Session UUID.
69 pub id: String,
70 /// Provider name (claude, codex, gemini).
71 pub provider: String,
72 /// Project this session belongs to.
73 pub project_hash: ProjectHash,
74 /// Git repository hash for worktree support (None for non-git directories).
75 #[serde(skip_serializing_if = "Option::is_none")]
76 pub repository_hash: Option<RepositoryHash>,
77 /// Absolute path to project root directory, if known.
78 pub project_root: Option<String>,
79 /// Session start timestamp (ISO 8601).
80 pub start_ts: Option<String>,
81 /// First user message snippet for display.
82 pub snippet: Option<String>,
83 /// Parent session ID for subagent sessions.
84 #[serde(skip_serializing_if = "Option::is_none")]
85 pub parent_session_id: Option<String>,
86 /// Spawn context for subagent sessions (turn/step where spawned).
87 #[serde(skip_serializing_if = "Option::is_none")]
88 pub spawned_by: Option<SpawnContext>,
89}