Seed query terms and graph-neighbor candidates from an intent.
(
&self,
repo: &Repository,
intent_id: &str,
seed_terms: &mut Vec<String>,
candidates: &mut HashMap<String, CandidateScore>,
)
| 355 | |
| 356 | /// Seed query terms and graph-neighbor candidates from an intent. |
| 357 | fn seed_from_intent( |
| 358 | &self, |
| 359 | repo: &Repository, |
| 360 | intent_id: &str, |
| 361 | seed_terms: &mut Vec<String>, |
| 362 | candidates: &mut HashMap<String, CandidateScore>, |
| 363 | ) -> CliResult<()> { |
| 364 | let manifest = repo.vault_manifest().map_err(CliError::Repository)?; |
| 365 | let (resolved_id, summary) = manifest |
| 366 | .intents |
| 367 | .iter() |
| 368 | .find(|(id, _)| id.eq_ignore_ascii_case(intent_id)) |
| 369 | .ok_or_else(|| CliError::VaultEntityNotFound { |
| 370 | kind: "intent", |
| 371 | id: intent_id.to_string(), |
| 372 | hint: None, |
| 373 | })?; |
| 374 | |
| 375 | seed_terms.push(summary.title.clone()); |
| 376 | |
| 377 | // Legacy manifest entries may not have `vault_path`. Reuse the same |
| 378 | // path resolution fallback as the rest of the Intent API rather than |
| 379 | // querying an empty path and the meaningless `intent:` KG node. |
| 380 | let intent_path = repo |
| 381 | .vault_intent_path(resolved_id) |
| 382 | .map_err(CliError::Repository)? |
| 383 | .ok_or_else(|| CliError::VaultEntityNotFound { |
| 384 | kind: "intent", |
| 385 | id: intent_id.to_string(), |
| 386 | hint: None, |
| 387 | })?; |
| 388 | |
| 389 | if let Some(entry) = repo |
| 390 | .vault_retrieve(&intent_path) |
| 391 | .map_err(CliError::Repository)? |
| 392 | { |
| 393 | seed_terms.extend(frontmatter_labels(&entry.frontmatter_json)); |
| 394 | let body = String::from_utf8_lossy(&entry.content_bytes); |
| 395 | let body = truncate_chars(body.trim(), INTENT_BODY_SEED_CHARS); |
| 396 | if !body.is_empty() { |
| 397 | seed_terms.push(body); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | if let Ok(node_id) = iri::mint_intent( |
| 402 | &repo.project_id().map_err(CliError::Repository)?, |
| 403 | &summary.uid.to_uppercase(), |
| 404 | ) { |
| 405 | // Identity comes from the manifest, including old-layout entries. |
| 406 | add_memory_neighbors(repo, &node_id, 2, candidates)?; |
| 407 | } |
| 408 | Ok(()) |
| 409 | } |
| 410 | |
| 411 | fn has_explicit_seeds(&self) -> bool { |
| 412 | self.query.iter().any(|q| !q.trim().is_empty()) |
no test coverage detected