Skip to main content

sochdb_memory/
episode.rs

1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4/// Unique episode identifier within a namespace.
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6pub struct EpisodeId(pub u64);
7
8impl fmt::Display for EpisodeId {
9    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10        write!(f, "ep:{}", self.0)
11    }
12}
13
14/// Raw episode write — no LLM extraction on the hot path.
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct EpisodeWrite {
17    pub namespace: String,
18    pub text: String,
19    /// Optional world-time valid-from (microseconds). Defaults to write time.
20    pub t_valid_from: Option<u64>,
21    pub metadata: Option<serde_json::Value>,
22}
23
24/// Stored episode record.
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct Episode {
27    pub id: EpisodeId,
28    pub namespace: String,
29    pub text: String,
30    pub t_created: u64,
31    pub t_valid_from: u64,
32    pub enriched: bool,
33    pub metadata: Option<serde_json::Value>,
34}