Build a capture from the session and the exact git observation token. `conversion_policy` and `snapshot` stay `None` (documented above); the caller signs the result with [`AgentSession::ensure_mac_key`].
(
session: &AgentSession,
turn: u32,
working_copy: String,
token: &atomic_repository::GitObservationToken,
)
| 221 | /// `conversion_policy` and `snapshot` stay `None` (documented above); the |
| 222 | /// caller signs the result with [`AgentSession::ensure_mac_key`]. |
| 223 | pub fn build_capture( |
| 224 | session: &AgentSession, |
| 225 | turn: u32, |
| 226 | working_copy: String, |
| 227 | token: &atomic_repository::GitObservationToken, |
| 228 | ) -> ManagedCommitCapture { |
| 229 | let (head_oid, head_symref) = match &token.head { |
| 230 | atomic_repository::GitHeadObservation::Attached { symref, oid } => { |
| 231 | (Some(oid.clone()), Some(symref.clone())) |
| 232 | } |
| 233 | atomic_repository::GitHeadObservation::Detached { oid } => (Some(oid.clone()), None), |
| 234 | atomic_repository::GitHeadObservation::Unborn { symref } |
| 235 | | atomic_repository::GitHeadObservation::MissingTarget { symref } => { |
| 236 | (None, Some(symref.clone())) |
| 237 | } |
| 238 | }; |
| 239 | ManagedCommitCapture { |
| 240 | version: CAPTURE_VERSION, |
| 241 | session_id: session.session_id.clone(), |
| 242 | turn, |
| 243 | working_copy, |
| 244 | head_oid, |
| 245 | head_symref, |
| 246 | index_digest: Some(token.index_digest.to_base32()), |
| 247 | index_tree: token.index_tree.clone(), |
| 248 | repository_state: token.repository_state.clone(), |
| 249 | markers: token |
| 250 | .markers |
| 251 | .iter() |
| 252 | .map(|marker| format!("{marker:?}")) |
| 253 | .collect(), |
| 254 | conversion_policy: None, |
| 255 | snapshot: None, |
| 256 | at_rfc3339: chrono::Utc::now().to_rfc3339(), |
| 257 | at_unix: chrono::Utc::now().timestamp(), |
| 258 | mac: String::new(), |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /// Write the capture for one turn of one session, signing it first. |
| 263 | /// |