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

Method scan_memory_bodies

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

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