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,
)
| 30 | /// of every capture file in the session's captures directory, sorted by |
| 31 | /// name. Matches the `capture_root` construction contract. |
| 32 | pub(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 | |
| 62 | impl TurnOrchestrator { |
| 63 | /// Load the configured agent DID identity for attestation signing |
no test coverage detected