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

Method hydrate_workflow_usage

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

Hydrate older KG projections from verified immutable change headers. This only changes the returned read model, never the repository database.

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

Source from the content-addressed store, hash-verified

93 /// Hydrate older KG projections from verified immutable change headers.
94 /// This only changes the returned read model, never the repository database.
95 pub(crate) fn hydrate_workflow_usage(
96 &self,
97 nodes: &mut [KgNode],
98 ) -> Result<(), RepositoryError> {
99 for node in nodes.iter_mut().filter(|node| node.has_type(C::Change)) {
100 let metadata = node.metadata.as_ref();
101 let availability = metadata
102 .and_then(|m| m.get("object_availability"))
103 .and_then(|v| v.as_str());
104 if matches!(availability, Some("absent" | "unknown")) {
105 set_change_records(node, None)?;
106 continue;
107 }
108 if metadata
109 .and_then(|m| m.get("ai_usage_record_version"))
110 .and_then(|v| v.as_u64())
111 == Some(1)
112 {
113 continue;
114 }
115 let hash = iri::parse_change(&node.id)
116 .map_err(|error| RepositoryError::Serialization(error.to_string()))?;
117 match self.load_change(&hash) {
118 Ok(change) => set_change_records(node, Some(change_records(&change, &hash)))?,
119 Err(RepositoryError::ChangeNotFound { .. }) => set_change_records(node, None)?,
120 Err(error) => return Err(error),
121 }
122 }
123 Ok(())
124 }
125
126 /// Copy full-snapshot usage summaries into a selected subgraph. Aggregate
127 /// scope does not shrink when the exported graph is capped or filtered.

Callers 1

workflow_snapshotMethod · 0.80

Calls 9

set_change_recordsFunction · 0.85
change_recordsFunction · 0.85
iter_mutMethod · 0.80
has_typeMethod · 0.80
as_refMethod · 0.80
as_u64Method · 0.80
getMethod · 0.65
as_strMethod · 0.45
load_changeMethod · 0.45

Tested by

no test coverage detected