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

Function resolve_paths

atomic-repository/src/query_plan.rs:396–425  ·  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

394/// If it starts with `$`, extract vault paths from the bound nodes
395/// (using the node label or metadata path field).
396fn resolve_paths(source: &str, bindings: &HashMap<String, Vec<KgNode>>) -> Vec<String> {
397 if let Some(var_name) = source.strip_prefix('$') {
398 bindings
399 .get(var_name)
400 .map(|nodes| {
401 nodes
402 .iter()
403 .filter_map(|n| {
404 // Try metadata.path first (from vector search results)
405 n.metadata
406 .as_ref()
407 .and_then(|m| m.get("path"))
408 .and_then(|p| p.as_str())
409 .map(String::from)
410 .or_else(|| {
411 // Fall back to node label if it looks like a path
412 if n.label.contains('/') || n.label.contains('.') {
413 Some(n.label.clone())
414 } else {
415 None
416 }
417 })
418 })
419 .collect()
420 })
421 .unwrap_or_default()
422 } else {
423 vec![source.to_string()]
424 }
425}
426
427/// Get a field value from a KgNode for filtering.
428fn get_node_field(node: &KgNode, field: &str) -> Option<String> {

Calls 6

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