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

Function render_candidates_json

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

Render the compact candidate contract. It deliberately contains no body, preview, or prompt-ready context field.

(
    items: &[MemoryItem],
    request: &Context,
    limit: usize,
)

Source from the content-addressed store, hash-verified

890/// Render the compact candidate contract. It deliberately contains no body,
891/// preview, or prompt-ready context field.
892pub(crate) fn render_candidates_json(
893 items: &[MemoryItem],
894 request: &Context,
895 limit: usize,
896) -> String {
897 let values: Vec<serde_json::Value> = items
898 .iter()
899 .map(|item| {
900 serde_json::json!({
901 "memory_id": item.memory_id,
902 "path": item.path,
903 "name": item.name,
904 "kind": item.kind,
905 "revision_hash": item.revision_hash,
906 "score": (item.score * 1000.0).round() / 1000.0,
907 "why_matched": item.why_matched,
908 "updated_at": item.updated_at,
909 })
910 })
911 .collect();
912 let envelope = serde_json::json!({
913 "schema_version": CANDIDATE_JSON_SCHEMA_VERSION,
914 "mode": "candidates",
915 "candidate_authority": "untrusted_historical_data",
916 "retrieval": {
917 "query": &request.query,
918 "intent": &request.intent,
919 "files": &request.files,
920 "limit": limit,
921 "ranker_version": RANKER_VERSION,
922 },
923 "pull_command": "atomic vault show <PATH> --revision <REVISION> --json",
924 "candidates": values,
925 });
926 serde_json::to_string_pretty(&envelope).unwrap_or_else(|_| "{}".to_string())
927}
928
929/// Render a single-call envelope containing both injectable text and exact
930/// memory exposure metadata for run provenance.

Calls 2

collectMethod · 0.45
iterMethod · 0.45

Tested by 1