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

Function seed_from_intent

libatomic/src/daemon/services_agent.rs:460–511  ·  view source on GitHub ↗

Seed query terms and graph-neighbor candidates from an intent.

(
        repo: &Repository,
        intent_id: &str,
        seed_terms: &mut Vec<String>,
        candidates: &mut HashMap<String, CandidateScore>,
    )

Source from the content-addressed store, hash-verified

458
459 /// Seed query terms and graph-neighbor candidates from an intent.
460 fn seed_from_intent(
461 repo: &Repository,
462 intent_id: &str,
463 seed_terms: &mut Vec<String>,
464 candidates: &mut HashMap<String, CandidateScore>,
465 ) -> Result<(), Status> {
466 let manifest = repo.vault_manifest().map_err(repository_error)?;
467 let Some((resolved_id, summary)) = manifest
468 .intents
469 .iter()
470 .find(|(id, _)| id.eq_ignore_ascii_case(intent_id))
471 else {
472 return Err(domain_status(
473 ErrorCode::NotFound,
474 format!("vault intent '{intent_id}' not found"),
475 ));
476 };
477
478 seed_terms.push(summary.title.clone());
479
480 // Legacy manifest entries may not carry `vault_path`; resolve the
481 // path rather than querying the empty and meaningless KG node.
482 let intent_path = repo
483 .vault_intent_path(resolved_id)
484 .map_err(repository_error)?
485 .ok_or_else(|| {
486 domain_status(
487 ErrorCode::NotFound,
488 format!("vault intent '{intent_id}' not found"),
489 )
490 })?;
491
492 if let Some(entry) = repo
493 .vault_retrieve(&intent_path)
494 .map_err(repository_error)?
495 {
496 seed_terms.extend(frontmatter_labels(&entry.frontmatter_json));
497 let body = String::from_utf8_lossy(&entry.content_bytes);
498 let body = truncate_chars(body.trim(), INTENT_BODY_SEED_CHARS);
499 if !body.is_empty() {
500 seed_terms.push(body);
501 }
502 }
503
504 if let Ok(node_id) = iri::mint_intent(
505 &repo.project_id().map_err(repository_error)?,
506 &summary.uid.to_uppercase(),
507 ) {
508 add_memory_neighbors(repo, &node_id, 2, candidates)?;
509 }
510 Ok(())
511 }
512
513 /// Load candidate bodies from the vault, score, and rank them — the
514 /// final ranked context items, truncated to `limit`.

Callers 1

gather_candidatesFunction · 0.85

Calls 14

domain_statusFunction · 0.85
mint_intentFunction · 0.85
vault_manifestMethod · 0.80
vault_intent_pathMethod · 0.80
vault_retrieveMethod · 0.80
extendMethod · 0.80
frontmatter_labelsFunction · 0.70
truncate_charsFunction · 0.70
add_memory_neighborsFunction · 0.70
iterMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected