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

Method enrich_workflow_usage

atomic-repository/src/workflow_usage.rs:128–151  ·  view source on GitHub ↗

Copy full-snapshot usage summaries into a selected subgraph. Aggregate scope does not shrink when the exported graph is capped or filtered.

(&self, nodes: &mut [KgNode])

Source from the content-addressed store, hash-verified

126 /// Copy full-snapshot usage summaries into a selected subgraph. Aggregate
127 /// scope does not shrink when the exported graph is capped or filtered.
128 pub fn enrich_workflow_usage(&self, nodes: &mut [KgNode]) -> Result<(), RepositoryError> {
129 if !nodes
130 .iter()
131 .any(|node| node.has_type(C::Change) || node.has_type(C::View) || is_intent(node))
132 {
133 return Ok(());
134 }
135 let snapshot = self.workflow_snapshot()?;
136 let summaries: BTreeMap<_, _> = snapshot
137 .nodes
138 .iter()
139 .map(|node| (node.id.as_str(), node))
140 .collect();
141 for node in nodes {
142 if let Some(usage) = summaries
143 .get(node.id.as_str())
144 .and_then(|source| source.metadata.as_ref())
145 .and_then(|metadata| metadata.get("ai_usage"))
146 {
147 metadata_object(node)?["ai_usage"] = usage.clone();
148 }
149 }
150 Ok(())
151 }
152}
153
154fn is_intent(node: &KgNode) -> bool {

Calls 10

is_intentFunction · 0.85
metadata_objectFunction · 0.85
has_typeMethod · 0.80
workflow_snapshotMethod · 0.80
as_refMethod · 0.80
getMethod · 0.65
iterMethod · 0.45
collectMethod · 0.45
as_strMethod · 0.45
cloneMethod · 0.45