(root: &Path)
| 30 | String::from_utf8(output.stdout).unwrap() |
| 31 | } |
| 32 | fn fixture(root: &Path) -> String { |
| 33 | let repo = Repository::init(root).unwrap(); |
| 34 | repo.init_vault().unwrap(); |
| 35 | repo.vault_store(&format!("intents/{UID}/intent.md"), VaultEntryType::Intent, |
| 36 | b":::why\nInspect exact lineage.\n:::\n".to_vec(), |
| 37 | serde_json::json!({"uid":UID,"id":KEY,"title":"Graph </script><script>alert(1)</script>","kind":"feature","status":"in_progress"}).to_string()).unwrap(); |
| 38 | repo.vault_reconcile_intent_manifest().unwrap(); |
| 39 | let mut bytes = vec![]; |
| 40 | let mut change = Change::empty(ChangeHeader::new("Exact recorded change")); |
| 41 | let mut provenance = atomic_core::change::Provenance::builder() |
| 42 | .vendor(atomic_core::change::AIVendor::OpenAI) |
| 43 | .model("graph-test-model") |
| 44 | .tool(atomic_core::change::AITool::cli("graph-test-agent")) |
| 45 | .request_id("graph-test-usage") |
| 46 | .cost_usd(0.125) |
| 47 | .build(); |
| 48 | provenance.tokens = atomic_core::change::TokenUsage::full(100, 40, 10, 60, 20); |
| 49 | change.add_provenance(provenance); |
| 50 | let hash = change.serialize(&mut bytes).unwrap(); |
| 51 | repo.import_change_bytes(&hash, &bytes).unwrap(); |
| 52 | repo.save_provenance_graph( |
| 53 | &ProvenanceGraph::builder("graph-test-session", "opencode") |
| 54 | .plan_id(UID) |
| 55 | .add_change_explained(hash) |
| 56 | .build(), |
| 57 | ) |
| 58 | .unwrap(); |
| 59 | repo.rebuild_kg(true).unwrap(); |
| 60 | let root = iri::mint_intent(&repo.project_id().unwrap(), UID).unwrap(); |
| 61 | assert_eq!(repo.intent_graph(KEY, 100).unwrap().root, root); |
| 62 | assert_eq!(repo.intent_graph(&root, 100).unwrap().root, root); |
| 63 | root |
| 64 | } |
| 65 | |
| 66 | #[test] |
| 67 | fn graph_resolves_ids_renders_all_formats_and_preserves_database() { |
no test coverage detected