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

Method intent_graph

atomic-repository/src/intent_graph.rs:53–71  ·  view source on GitHub ↗

Resolve a human intent key, UID, or canonical intent IRI and select its asserted semantic lineage. Does not enrich/rebuild the graph or read files.

(&self, id: &str, max_nodes: usize)

Source from the content-addressed store, hash-verified

51 /// Resolve a human intent key, UID, or canonical intent IRI and select its
52 /// asserted semantic lineage. Does not enrich/rebuild the graph or read files.
53 pub fn intent_graph(&self, id: &str, max_nodes: usize) -> Result<IntentGraph, RepositoryError> {
54 let uid = if let Ok((project, uid)) = iri::parse_intent(id) {
55 if project != self.project_id()? {
56 return Err(invalid("intent belongs to a different project"));
57 }
58 uid
59 } else {
60 let inputs = crate::intent_bridge::read_intent(self, id)?;
61 inputs
62 .frontmatter
63 .get("uid")
64 .and_then(|v| v.as_str())
65 .ok_or_else(|| invalid("intent has no canonical UID"))?
66 .to_uppercase()
67 };
68 let root = iri::mint_intent(&self.project_id()?, &uid)
69 .map_err(|error| invalid(&error.to_string()))?;
70 IntentGraph::from_snapshot(&self.workflow_snapshot()?, &root, max_nodes)
71 }
72}
73
74fn invalid(message: &str) -> RepositoryError {

Calls 8

parse_intentFunction · 0.85
read_intentFunction · 0.85
mint_intentFunction · 0.85
workflow_snapshotMethod · 0.80
invalidFunction · 0.70
getMethod · 0.65
project_idMethod · 0.45
as_strMethod · 0.45