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

Function resolve_and_rank

atomic-cli/src/commands/vault/context.rs:476–547  ·  view source on GitHub ↗

Load candidate bodies from the vault, score, and rank them.

(
    repo: &Repository,
    candidates: HashMap<String, CandidateScore>,
    limit: usize,
    include_body: bool,
)

Source from the content-addressed store, hash-verified

474
475/// Load candidate bodies from the vault, score, and rank them.
476fn resolve_and_rank(
477 repo: &Repository,
478 candidates: HashMap<String, CandidateScore>,
479 limit: usize,
480 include_body: bool,
481) -> CliResult<Vec<MemoryItem>> {
482 let now = chrono::Utc::now();
483 let mut items: Vec<MemoryItem> = Vec::new();
484
485 for (node_id, candidate) in candidates {
486 let Some(path) = candidate
487 .path
488 .clone()
489 .or_else(|| legacy_memory_node_id_to_path(&node_id))
490 else {
491 continue;
492 };
493 let Some(entry) = repo.vault_retrieve(&path).map_err(CliError::Repository)? else {
494 continue; // stale KG node — the entry no longer exists
495 };
496
497 if !is_eligible_memory(&entry) {
498 continue;
499 }
500 let kind = frontmatter_kind(&entry.frontmatter_json);
501 let Some(status) = frontmatter_status(&entry.frontmatter_json) else {
502 continue;
503 };
504
505 let memory_id =
506 frontmatter_memory_id(&entry.frontmatter_json).unwrap_or_else(|| node_id.clone());
507 let name = frontmatter_name(&entry.frontmatter_json).unwrap_or_else(|| {
508 node_id
509 .rsplit_once(':')
510 .map(|(_, n)| n)
511 .unwrap_or(&node_id)
512 .to_string()
513 });
514 let recency = recency_score(&entry.updated_at, now);
515 items.push(MemoryItem {
516 memory_id,
517 kg_node_id: node_id,
518 revision_hash: vault_entry_revision_hash(&entry),
519 content_hash: Hash::from_bytes(entry.content_hash).to_base32(),
520 path,
521 name,
522 kind,
523 status,
524 updated_at: entry.updated_at.clone(),
525 introduced_by: entry.introduced_by,
526 score: final_score(&candidate, recency),
527 why_matched: why_matched(&candidate).to_string(),
528 body: if include_body {
529 String::from_utf8_lossy(&entry.content_bytes)
530 .trim()
531 .to_string()
532 } else {
533 String::new()

Calls 15

is_eligible_memoryFunction · 0.85
frontmatter_kindFunction · 0.85
frontmatter_statusFunction · 0.85
frontmatter_memory_idFunction · 0.85
frontmatter_nameFunction · 0.85
recency_scoreFunction · 0.85
final_scoreFunction · 0.85
why_matchedFunction · 0.85
vault_retrieveMethod · 0.80
partial_cmpMethod · 0.80