Hydrate older KG projections from verified immutable change headers. This only changes the returned read model, never the repository database.
(
&self,
nodes: &mut [KgNode],
)
| 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. |
no test coverage detected