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

Function signed_fixture

atomic-cli/tests/intent_evidence_replay_test.rs:66–136  ·  view source on GitHub ↗
(root: &Path)

Source from the content-addressed store, hash-verified

64}
65
66fn signed_fixture(root: &Path) -> (String, String) {
67 let repo = Repository::init(root).unwrap();
68 repo.init_vault().unwrap();
69 let created = repo
70 .vault_intent_create(IntentCreateOptions {
71 title: "Retain selected source passages".into(),
72 priority: None,
73 assignee: None,
74 labels: Vec::new(),
75 session_id: None,
76 turn_id: None,
77 kind: None,
78 })
79 .unwrap();
80 repo.vault_intent_update(&created.id, IntentUpdateOptions {
81 content: Some(format!(":::why\nKeep a reviewable retained report.\n:::\n\n:::acceptance-criterion{{#{}-ac-1 status=unmet}}\nSelected passages remain in the retained report.\n:::\n", created.uid)),
82 force: true, ..Default::default()
83 }).unwrap();
84 let entry = repo.vault_intent_show(&created.id).unwrap();
85 let fm: serde_json::Map<String, Value> = serde_json::from_str(&entry.frontmatter_json).unwrap();
86 let body = String::from_utf8(entry.content_bytes).unwrap();
87 let key = KeyPair::generate();
88 let identity = Identity::new("synthetic-reviewer", &key);
89 let node = lift_and_attest(&fm, &body, &identity, &key).unwrap();
90 // Native legacy sidecar format, with the same source anchor as the tracked
91 // path. No globally installed identity/configuration is needed by the test.
92 let mut hash = blake3::Hasher::new();
93 hash.update(serde_json::to_string(&fm).unwrap().as_bytes());
94 hash.update(b"\0");
95 hash.update(body.as_bytes());
96 let safe: String = created
97 .id
98 .chars()
99 .map(|c| {
100 if c.is_ascii_alphanumeric() || c == '-' || c == '_' {
101 c
102 } else {
103 '_'
104 }
105 })
106 .collect();
107 let source_hash = format!("blake3:{}", hash.finalize().to_hex());
108 let dir = repo.dot_dir().join("canonical/intents").join(&safe);
109 std::fs::create_dir_all(&dir).unwrap();
110 std::fs::write(
111 dir.join("attested.jsonld"),
112 serde_json::to_vec(&json!({
113 "node":node, "source":{ "sourceContentHash": source_hash }
114 }))
115 .unwrap(),
116 )
117 .unwrap();
118 // `atomic intent attest` writes the sidecar and a tracked attestation entry.
119 // The service/daemon path reads only the latter, so mirror both stores.
120 let vault_path = format!("attestations/{safe}/attested.md");
121 let mut attested_body = serde_json::to_vec_pretty(&node.to_value()).unwrap();
122 attested_body.push(b'\n');
123 repo.vault_store(

Calls 15

lift_and_attestFunction · 0.85
vault_intent_createMethod · 0.80
vault_intent_updateMethod · 0.80
vault_intent_showMethod · 0.80
vault_storeMethod · 0.80
vault_materializeMethod · 0.80
writeFunction · 0.70
initFunction · 0.50
unwrapMethod · 0.45
init_vaultMethod · 0.45
updateMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected