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

Method scan_memory_bodies

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

260 /// a linear scan at this layer keeps free-text queries useful
261 /// without touching the storage layer.
262 fn scan_memory_bodies(
263 &self,
264 repo: &Repository,
265 seed_query: &str,
266 candidates: &mut HashMap<String, CandidateScore>,
267 ) -> CliResult<()> {
268 let terms = search_terms(seed_query);
269 if terms.is_empty() {
270 return Ok(());
271 }
272 let metas = repo
273 .vault_list("memory/", Some(VaultEntryType::Memory))
274 .map_err(CliError::Repository)?;
275 for meta in metas {
276 let Some(node_id) = memory_path_to_node_id(&meta.path) else {
277 continue;
278 };
279 let Some(entry) = repo
280 .vault_retrieve(&meta.path)
281 .map_err(CliError::Repository)?
282 else {
283 continue;
284 };
285 if !is_eligible_memory(&entry) {
286 continue;
287 }
288 let body = String::from_utf8_lossy(&entry.content_bytes);
289 let matched = body_match_fraction(&terms, &body);
290 if matched > 0.0 {
291 let base = BODY_MATCH_WEIGHT * matched;
292 merge_candidate(candidates, &node_id, Some(meta.path), base, false);
293 }
294 }
295 Ok(())
296 }
297
298 /// Seed query terms and graph-neighbor candidates from an intent.
299 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