Seal governance before any recording attempt, including one that fails before publishing a checkpoint. The caller holds `turn-end.lock`.
(&self, session_id: &str, turn_number: u32)
| 918 | /// Seal governance before any recording attempt, including one that fails |
| 919 | /// before publishing a checkpoint. The caller holds `turn-end.lock`. |
| 920 | pub(crate) fn freeze_turn_intent(&self, session_id: &str, turn_number: u32) -> AgentResult<()> { |
| 921 | validate_session_id(session_id)?; |
| 922 | // Validate existing evidence before recording any content. |
| 923 | self.turn_intent_binding(session_id, turn_number)?; |
| 924 | let dir = self.sessions_dir.join(session_id); |
| 925 | std::fs::create_dir_all(&dir)?; |
| 926 | let path = dir.join(format!("intent-{turn_number}.frozen")); |
| 927 | let file = std::fs::OpenOptions::new() |
| 928 | .write(true) |
| 929 | .create(true) |
| 930 | .truncate(false) |
| 931 | .open(path)?; |
| 932 | file.sync_all()?; |
| 933 | #[cfg(unix)] |
| 934 | std::fs::File::open(dir)?.sync_all()?; |
| 935 | Ok(()) |
| 936 | } |
| 937 | |
| 938 | /// Create a new session store at the given directory path. |
| 939 | /// |