MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / build_capture

Function build_capture

atomic-agent/src/turn/capture.rs:225–262  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

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

Callers 1

write_captureFunction · 0.85

Calls 5

cloneMethod · 0.45
to_base32Method · 0.45
collectMethod · 0.45
iterMethod · 0.45
timestampMethod · 0.45

Tested by

no test coverage detected