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

Method project_node

atomic-repository/src/repository/query.rs:39–74  ·  view source on GitHub ↗

Project ambient candidates before ranking. File identities are canonical, but their presence must come from the selected view's current projection.

(
        &self,
        txn: &T,
        node: KgNode,
    )

Source from the content-addressed store, hash-verified

37 /// Project ambient candidates before ranking. File identities are canonical,
38 /// but their presence must come from the selected view's current projection.
39 pub fn project_node<T: KgTxnT>(
40 &self,
41 txn: &T,
42 node: KgNode,
43 ) -> Result<Option<KgNode>, RepositoryError> {
44 let visible = if node.has_type(Class::File) {
45 return Ok(self.nodes.get(&node.id).cloned());
46 } else if node.has_type(Class::Change) {
47 self.changes.contains(&node.id)
48 } else if node.has_type(Class::View) {
49 self.views.contains(&node.id)
50 } else if node.has_type(Class::Identity) && node.source == "vcs" {
51 let mut visible = false;
52 for edge in txn.get_kg_edges_to(&node.id)? {
53 if edge.kind != Predicate::AuthoredBy {
54 continue;
55 }
56 let Some(authoring_node) = txn.get_kg_node(&edge.from_id)? else {
57 continue;
58 };
59 // An identity shared with a vault record stays shared. A VCS-only
60 // identity needs an authored change visible in the selected view.
61 if !authoring_node.has_type(Class::Change)
62 || self.project_node(txn, authoring_node)?.is_some()
63 {
64 visible = true;
65 break;
66 }
67 }
68 visible
69 } else {
70 // Vault and session resources have no VCS view membership.
71 true
72 };
73 Ok(visible.then_some(node))
74 }
75
76 pub fn search_content(
77 &self,

Callers 1

vault_kg_search_innerMethod · 0.80

Calls 5

has_typeMethod · 0.80
getMethod · 0.65
containsMethod · 0.45
get_kg_edges_toMethod · 0.45
get_kg_nodeMethod · 0.45

Tested by

no test coverage detected