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

Method scan_memory_bodies

atomic-cli/src/commands/vault/context.rs:317–354  ·  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 `vault_kg_search`. Memories are few and small; a linear scan at this layer keeps free-text queries useful without touching the storage layer.

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

Source from the content-addressed store, hash-verified

315 /// a linear scan at this layer keeps free-text queries useful
316 /// without touching the storage layer.
317 fn scan_memory_bodies(
318 &self,
319 repo: &Repository,
320 seed_query: &str,
321 candidates: &mut HashMap<String, CandidateScore>,
322 ) -> CliResult<()> {
323 let terms = search_terms(seed_query);
324 if terms.is_empty() {
325 return Ok(());
326 }
327 let metas = repo
328 .vault_list("memory/", Some(VaultEntryType::Memory))
329 .map_err(CliError::Repository)?;
330 for meta in metas {
331 let Some(node_id) = memory_path_to_node_id(
332 &repo.project_id().map_err(CliError::Repository)?,
333 &meta.path,
334 ) else {
335 continue;
336 };
337 let Some(entry) = repo
338 .vault_retrieve(&meta.path)
339 .map_err(CliError::Repository)?
340 else {
341 continue;
342 };
343 if !is_eligible_memory(&entry) {
344 continue;
345 }
346 let body = String::from_utf8_lossy(&entry.content_bytes);
347 let matched = body_match_fraction(&terms, &body);
348 if matched > 0.0 {
349 let base = BODY_MATCH_WEIGHT * matched;
350 merge_candidate(candidates, &node_id, Some(meta.path), base, false);
351 }
352 }
353 Ok(())
354 }
355
356 /// Seed query terms and graph-neighbor candidates from an intent.
357 fn seed_from_intent(

Callers 1

gather_candidatesMethod · 0.80

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