loopd: a turn's speaker in the log, its number in SessionUpdated

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-09-28 10:33:36 -07:00
co-authored by ornith-1.5-35b-a3b
parent c798714af1
commit 4866353ac9
10 changed files with 362 additions and 26 deletions
+6 -6
View File
@@ -22,8 +22,9 @@ pub const MEMORY_WAIT: Duration = Duration::from_secs(10);
pub trait MemorySource: Send + Sync {
/// The block for a new session. `Err` ends in `UNAVAILABLE`: no session starts without it.
fn block(&self) -> Result<String, String>;
/// The session has new records; best effort, a failure is only logged by the caller.
fn updated(&self, session: &SessionId) -> Result<(), String>;
/// The session's turn number `turn` has ended, and its records are in the log; best effort,
/// a failure is only logged by the caller.
fn updated(&self, session: &SessionId, turn: u64) -> Result<(), String>;
}
/// No memory: for tests and the self-test, never for `loopd serve`.
@@ -33,7 +34,7 @@ impl MemorySource for NoMemory {
fn block(&self) -> Result<String, String> {
Ok(String::new())
}
fn updated(&self, _session: &SessionId) -> Result<(), String> {
fn updated(&self, _session: &SessionId, _turn: u64) -> Result<(), String> {
Ok(())
}
}
@@ -91,11 +92,10 @@ impl MemorySource for MemoryPort {
}
}
fn updated(&self, session: &SessionId) -> Result<(), String> {
fn updated(&self, session: &SessionId, turn: u64) -> Result<(), String> {
match self.ask(Message::SessionUpdated(SessionUpdated {
session: session.clone(),
// Set in M5c-1 task 02. `memoryd` does not read it before M5c-1 task 09.
turn: 0,
turn,
}))? {
Message::Ok(_) => Ok(()),
Message::Error(e) => Err(format!("memoryd: {}", e.detail)),