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

Function capture_root

atomic-agent/src/turn/orchestrator/attestation.rs:32–60  ·  view source on GitHub ↗

The capture evidence root: BLAKE3 over `(file name, content hash)` pairs of every capture file in the session's captures directory, sorted by name. Matches the `capture_root` construction contract.

(
    sessions_dir: &Path,
    session_id: &str,
)

Source from the content-addressed store, hash-verified

30/// of every capture file in the session's captures directory, sorted by
31/// name. Matches the `capture_root` construction contract.
32pub(crate) fn capture_root(
33 sessions_dir: &Path,
34 session_id: &str,
35) -> AgentResult<atomic_core::types::Hash> {
36 let dir = crate::turn::capture::capture_dir(sessions_dir, session_id)?;
37 let mut pairs: Vec<(String, Vec<u8>)> = Vec::new();
38 if let Ok(entries) = std::fs::read_dir(&dir) {
39 for entry in entries.flatten() {
40 let path = entry.path();
41 if !path.is_file() {
42 continue;
43 }
44 let name = entry.file_name().to_string_lossy().to_string();
45 let bytes = std::fs::read(&path)?;
46 pairs.push((
47 name,
48 atomic_core::types::Hash::of(&bytes).as_bytes().to_vec(),
49 ));
50 }
51 }
52 pairs.sort_by(|a, b| a.0.cmp(&b.0));
53 let mut buf = Vec::new();
54 for (name, hash) in pairs {
55 buf.extend_from_slice(name.as_bytes());
56 buf.push(0);
57 buf.extend_from_slice(&hash);
58 }
59 Ok(atomic_core::types::Hash::of(&buf))
60}
61
62impl TurnOrchestrator {
63 /// Load the configured agent DID identity for attestation signing

Calls 8

capture_dirFunction · 0.85
readFunction · 0.50
pathMethod · 0.45
is_fileMethod · 0.45
file_nameMethod · 0.45
pushMethod · 0.45
as_bytesMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected