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

Method from_serialized

atomic-agent/src/provenance/accumulator/mod.rs:192–229  ·  view source on GitHub ↗

Reconstruct an accumulator from a serialized graph.

(s: SerializedGraph)

Source from the content-addressed store, hash-verified

190
191 /// Reconstruct an accumulator from a serialized graph.
192 fn from_serialized(s: SerializedGraph) -> Self {
193 let session_prefix = make_session_prefix(&s.session_id);
194
195 // Rebuild commitments_since_last_patch by scanning nodes from the
196 // end backward to find commitment nodes that haven't been followed
197 // by a patch proposal.
198 let mut commitments_since_last_patch = Vec::new();
199 for node in s.nodes.iter().rev() {
200 if node.kind == NodeKind::PatchProposal {
201 break; // Stop at the last patch proposal
202 }
203 if node.kind == NodeKind::Commitment {
204 commitments_since_last_patch.push(node.id.clone());
205 }
206 }
207 commitments_since_last_patch.reverse();
208
209 let nodes_saved_count = s.nodes_saved_count.unwrap_or(s.nodes.len());
210 let edges_saved_count = s.edges_saved_count.unwrap_or(s.edges.len());
211
212 Self {
213 session_id: s.session_id,
214 session_prefix,
215 nodes: s.nodes,
216 edges: s.edges,
217 stats: s.stats,
218 counter: s.counter,
219 current_goal: s.current_goal,
220 pending_explorations: s.pending_explorations,
221 last_commitment: s.last_commitment,
222 last_node: s.last_node,
223 pending_human_gate: s.pending_human_gate,
224 commitments_since_last_patch,
225 last_provenance_hash: s.last_provenance_hash,
226 nodes_saved_count,
227 edges_saved_count,
228 }
229 }
230
231 // =========================================================================
232 // Accessors

Callers

nothing calls this directly

Calls 6

make_session_prefixFunction · 0.85
iterMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
reverseMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected