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

Function resolve_and_rank

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

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