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

Function scan_memory_bodies

libatomic/src/daemon/services_agent.rs:425–457  ·  view source on GitHub ↗

Match seed terms against memory bodies directly — the KG FTS indexes only node ids/labels/summaries, so body words are invisible to the keyword search. Memories are few and small; a linear scan keeps free-text queries useful without a storage-layer change.

(
        repo: &Repository,
        seed_query: &str,
        candidates: &mut HashMap<String, CandidateScore>,
    )

Source from the content-addressed store, hash-verified

423 /// to the keyword search. Memories are few and small; a linear scan
424 /// keeps free-text queries useful without a storage-layer change.
425 fn scan_memory_bodies(
426 repo: &Repository,
427 seed_query: &str,
428 candidates: &mut HashMap<String, CandidateScore>,
429 ) -> Result<(), Status> {
430 let terms = search_terms(seed_query);
431 if terms.is_empty() {
432 return Ok(());
433 }
434 let metas = repo
435 .vault_list("memory/", Some(VaultEntryType::Memory))
436 .map_err(repository_error)?;
437 for meta in metas {
438 let Some(node_id) =
439 memory_path_to_node_id(&repo.project_id().map_err(repository_error)?, &meta.path)
440 else {
441 continue;
442 };
443 let Some(entry) = repo.vault_retrieve(&meta.path).map_err(repository_error)? else {
444 continue;
445 };
446 if !is_eligible_memory(&entry) {
447 continue;
448 }
449 let body = String::from_utf8_lossy(&entry.content_bytes);
450 let matched = body_match_fraction(&terms, &body);
451 if matched > 0.0 {
452 let base = BODY_MATCH_WEIGHT * matched;
453 merge_candidate(candidates, &node_id, Some(meta.path), base, false);
454 }
455 }
456 Ok(())
457 }
458
459 /// Seed query terms and graph-neighbor candidates from an intent.
460 fn seed_from_intent(

Callers 1

gather_candidatesFunction · 0.85

Calls 9

vault_listMethod · 0.80
vault_retrieveMethod · 0.80
search_termsFunction · 0.70
memory_path_to_node_idFunction · 0.70
is_eligible_memoryFunction · 0.70
body_match_fractionFunction · 0.70
merge_candidateFunction · 0.70
is_emptyMethod · 0.45
project_idMethod · 0.45

Tested by

no test coverage detected