Reconcile lifecycle metadata for an agent session. Called from session start/end hooks. `ended_at: None` marks the session active (clearing a stale end marker on resume); `Some(ts)` marks it ended. Best-effort callers treat failures as recoverable divergence — the JSON session file remains the runtime fallback and `rebuild_session_index` can reconcile later.
(
&self,
session_id: &str,
view_name: Option<String>,
parent_view: Option<String>,
ended_at: Option<i64>,
)
| 820 | /// divergence — the JSON session file remains the runtime fallback and |
| 821 | /// `rebuild_session_index` can reconcile later. |
| 822 | pub fn upsert_session_lifecycle( |
| 823 | &self, |
| 824 | session_id: &str, |
| 825 | view_name: Option<String>, |
| 826 | parent_view: Option<String>, |
| 827 | ended_at: Option<i64>, |
| 828 | ) -> Result<(), RepositoryError> { |
| 829 | self.ensure_project_identity(atomic_core::kg::project_id::MintReason::Upgrade)?; |
| 830 | let json_path = self |
| 831 | .dot_dir |
| 832 | .join("sessions") |
| 833 | .join(format!("{}.json", session_id)) |
| 834 | .to_string_lossy() |
| 835 | .to_string(); |
| 836 | let mut txn = self |
| 837 | .pristine |
| 838 | .write_txn() |
| 839 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 840 | txn.upsert_session_lifecycle(session_id, &json_path, view_name, parent_view, ended_at) |
| 841 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 842 | txn.commit() |
| 843 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 844 | Ok(()) |
| 845 | } |
| 846 | |
| 847 | /// Persist a managed-agent incomplete outcome without indexing a turn. |
| 848 | /// |
nothing calls this directly
no test coverage detected