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

Function resolve_paths

atomic-repository/src/query_plan.rs:479–508  ·  view source on GitHub ↗

Resolve a source path that may be a `$variable` reference. If it starts with `$`, extract vault paths from the bound nodes (using the node label or metadata path field).

(source: &str, bindings: &HashMap<String, Vec<KgNode>>)

Source from the content-addressed store, hash-verified

477/// If it starts with `$`, extract vault paths from the bound nodes
478/// (using the node label or metadata path field).
479fn resolve_paths(source: &str, bindings: &HashMap<String, Vec<KgNode>>) -> Vec<String> {
480 if let Some(var_name) = source.strip_prefix('$') {
481 bindings
482 .get(var_name)
483 .map(|nodes| {
484 nodes
485 .iter()
486 .filter_map(|n| {
487 // Try metadata.path first (from vector search results)
488 n.metadata
489 .as_ref()
490 .and_then(|m| m.get("path"))
491 .and_then(|p| p.as_str())
492 .map(String::from)
493 .or_else(|| {
494 // Fall back to node label if it looks like a path
495 if n.label.contains('/') || n.label.contains('.') {
496 Some(n.label.clone())
497 } else {
498 None
499 }
500 })
501 })
502 .collect()
503 })
504 .unwrap_or_default()
505 } else {
506 vec![source.to_string()]
507 }
508}
509
510/// Get a field value from a KgNode for filtering.
511fn get_node_field(node: &KgNode, field: &str) -> Option<String> {

Calls 7

as_refMethod · 0.80
getMethod · 0.65
collectMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45
containsMethod · 0.45
cloneMethod · 0.45