Compose existing local/reactor read endpoints without opening redb client-side. The selection itself runs purely over one consistent workflow snapshot.
(
id: &str,
max_nodes: usize,
)
| 7142 | /// Compose existing local/reactor read endpoints without opening redb client-side. |
| 7143 | /// The selection itself runs purely over one consistent workflow snapshot. |
| 7144 | pub(crate) fn intent_graph( |
| 7145 | id: &str, |
| 7146 | max_nodes: usize, |
| 7147 | ) -> CliResult<atomic_repository::intent_graph::IntentGraph> { |
| 7148 | let root = super::find_repository_root()?; |
| 7149 | let session = Service::open_root(&root)?.ok_or_else(|| CliError::InvalidArgument { |
| 7150 | message: "intent graphs require a local repository service (local or reactor mode)".into(), |
| 7151 | })?; |
| 7152 | let canonical = atomic_core::kg::iri::parse_intent(id) |
| 7153 | .ok() |
| 7154 | .map(|_| id.to_owned()); |
| 7155 | let uid = if canonical.is_none() { |
| 7156 | let response = session.get_vault_entry(pb::GetVaultEntryRequest { |
| 7157 | repository: Some(session.reference.clone()), |
| 7158 | kind: Kind::Intent as i32, |
| 7159 | id: id.into(), |
| 7160 | path: None, |
| 7161 | include_bundle: true, |
| 7162 | view: None, |
| 7163 | })?; |
| 7164 | let bundle = response |
| 7165 | .entry_bundle |
| 7166 | .as_ref() |
| 7167 | .map(parse_entry_bundle) |
| 7168 | .transpose()? |
| 7169 | .ok_or_else(|| { |
| 7170 | CliError::Internal(anyhow::anyhow!("intent service returned no entry bundle")) |
| 7171 | })?; |
| 7172 | let inputs = crate::commands::intent::bridge::inputs_from_entry(&bundle.entry)?; |
| 7173 | Some( |
| 7174 | inputs |
| 7175 | .frontmatter |
| 7176 | .get("uid") |
| 7177 | .and_then(|v| v.as_str()) |
| 7178 | .ok_or_else(|| CliError::InvalidArgument { |
| 7179 | message: "intent has no canonical UID".into(), |
| 7180 | })? |
| 7181 | .to_uppercase(), |
| 7182 | ) |
| 7183 | } else { |
| 7184 | None |
| 7185 | }; |
| 7186 | let snapshot = decode_workflow_snapshot(session.get_workflow_snapshot( |
| 7187 | pb::GetWorkflowSnapshotRequest { |
| 7188 | repository: Some(session.reference.clone()), |
| 7189 | }, |
| 7190 | )?)?; |
| 7191 | let canonical = match canonical { |
| 7192 | Some(id) => id, |
| 7193 | None => { |
| 7194 | let candidates: Vec<_> = snapshot |
| 7195 | .nodes |
| 7196 | .iter() |
| 7197 | .filter(|node| { |
| 7198 | atomic_core::kg::iri::parse_intent(&node.id) |
| 7199 | .ok() |
| 7200 | .is_some_and(|(_, value)| Some(&value) == uid.as_ref()) |
| 7201 | }) |
no test coverage detected