pub fn archive_session(
filestore: &FileStore,
definition_id: &str,
) -> Result<Option<(String, i64)>, String>Expand description
Archive agent:<defId>:current to agent:<defId>:archive:<now_ms>.
Atomicity contract:
- We write the archive zone first, then clear the current zone.
- A crash between those two steps leaves both zones populated; replay-time behaviour is “current wins” so this is safe.
- We never clear
:currentbefore the archive write has been acked by FileStore, so the archive-missing case can’t happen without a FileStore I/O failure on the write itself (which is surfaced asErrand aborts the clear step).
Returns:
Ok(Some((archive_zoneid, archived_at_ms)))on successful archive (current zone had content).Ok(None)when there was nothing to archive (nooutput.state.jsonin :current, OR it was zero-byte). The caller should treat this as “session was empty, nothing to do” — we explicitly do NOT create an empty archive zone.