use crate::event::EventType;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct BackfillEvent {
pub event_type: EventType,
pub task_id: String,
pub text: String,
pub timestamp: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct BackfillInput {
pub tasks: Vec<BackfillTaskContext>,
pub transcript: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct BackfillTaskContext {
pub task_id: String,
pub title: String,
pub existing_events: Vec<String>,
}
pub trait DreamBackend {
fn backfill(&self, input: &BackfillInput) -> anyhow::Result<Vec<BackfillEvent>>;
}
pub struct MockDreamBackend {
pub events: Vec<BackfillEvent>,
}
impl DreamBackend for MockDreamBackend {
fn backfill(&self, _input: &BackfillInput) -> anyhow::Result<Vec<BackfillEvent>> {
Ok(self.events.clone())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn mock_backend_returns_canned_events() {
let be = MockDreamBackend {
events: vec![BackfillEvent {
event_type: EventType::Decision,
task_id: "tj-1".into(),
text: "Chose A over B.".into(),
timestamp: "2026-06-08T10:00:00Z".into(),
}],
};
let input = BackfillInput {
tasks: vec![],
transcript: "x".into(),
};
let out = be.backfill(&input).unwrap();
assert_eq!(out.len(), 1);
assert_eq!(out[0].task_id, "tj-1");
assert_eq!(out[0].event_type, EventType::Decision);
}
}