archive_session

Function archive_session 

Source
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 :current before 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 as Err and 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 (no output.state.json in :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.