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)
| 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 | |
| 74 | fn invalid(message: &str) -> RepositoryError { |