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

Method scan_memory_bodies

atomic-cli/src/commands/vault/context.rs:297–331  ·  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

295 /// a linear scan at this layer keeps free-text queries useful
296 /// without touching the storage layer.
297 fn scan_memory_bodies(
298 &self,
299 repo: &Repository,
300 seed_query: &str,
301 candidates: &mut HashMap<String, CandidateScore>,
302 ) -> CliResult<()> {
303 let terms = search_terms(seed_query);
304 if terms.is_empty() {
305 return Ok(());
306 }
307 let metas = repo
308 .vault_list("memory/", Some(VaultEntryType::Memory))
309 .map_err(CliError::Repository)?;
310 for meta in metas {
311 let Some(node_id) = memory_path_to_node_id(&meta.path) else {
312 continue;
313 };
314 let Some(entry) = repo
315 .vault_retrieve(&meta.path)
316 .map_err(CliError::Repository)?
317 else {
318 continue;
319 };
320 if !is_eligible_memory(&entry) {
321 continue;
322 }
323 let body = String::from_utf8_lossy(&entry.content_bytes);
324 let matched = body_match_fraction(&terms, &body);
325 if matched > 0.0 {
326 let base = BODY_MATCH_WEIGHT * matched;
327 merge_candidate(candidates, &node_id, Some(meta.path), base, false);
328 }
329 }
330 Ok(())
331 }
332
333 /// Seed query terms and graph-neighbor candidates from an intent.
334 fn seed_from_intent(

Callers 1

gather_candidatesMethod · 0.80

Calls 8

search_termsFunction · 0.85
memory_path_to_node_idFunction · 0.85
is_eligible_memoryFunction · 0.85
body_match_fractionFunction · 0.85
merge_candidateFunction · 0.85
vault_listMethod · 0.80
vault_retrieveMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected