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

Function agent_push_pack

atomic-cli/tests/clone_sidecar_integration_test.rs:66–120  ·  view source on GitHub ↗

A small session-scoped `SyncPack` for one change: the change object, the `dev` view's snapshot + ref, a provenance graph explaining the change, and an attestation covering it — the object mix push produces for agent-made changes.

(change_bytes: Vec<u8>, change_hash: &Hash)

Source from the content-addressed store, hash-verified

64/// an attestation covering it — the object mix push produces for agent-made
65/// changes.
66fn agent_push_pack(change_bytes: Vec<u8>, change_hash: &Hash) -> SyncPack {
67 let change_key = change_hash.to_base32();
68
69 // Provenance graph explaining the change.
70 let graph = ProvenanceGraph::builder("session-clone-e2e", "opencode")
71 .add_change_explained(*change_hash)
72 .build();
73 let prov_bytes = graph.serialize().expect("serialize provenance");
74 let prov_key = Hash::of(&prov_bytes).to_base32();
75
76 // Attestation covering the change.
77 let attest = Attestation::builder(
78 "session-clone-e2e",
79 AttestAgent::new("opencode", "OpenCode", "atomic"),
80 )
81 .add_change(*change_hash)
82 .build();
83 let attest_bytes = attest.serialize().expect("serialize attestation");
84 let attest_key = Hash::of(&attest_bytes).to_base32();
85
86 // The view snapshot: shared root "dev" owning exactly this change. The
87 // merkle state must equal the fold of the change log (manifest verify)
88 // and the set-id the order-invariant fold of it.
89 let mut merkle = Merkle::ZERO;
90 let mut set_id = SetId::ZERO;
91 merkle = merkle.next(change_hash);
92 set_id = set_id.add(change_hash);
93 let snapshot = ViewSnapshot::new(
94 ViewScopeLabel::Shared,
95 None,
96 Vec::new(),
97 vec![change_key.clone()],
98 set_id.to_base32(),
99 Some(merkle.to_base32()),
100 );
101 let snap_key = snapshot.content_key();
102
103 SyncPack {
104 objects: vec![
105 ObjectRecord::new(ObjectFamily::Change, change_key, change_bytes),
106 ObjectRecord::new(
107 ObjectFamily::View,
108 snap_key.clone(),
109 snapshot.to_canonical_bytes(),
110 ),
111 ObjectRecord::new(ObjectFamily::Provenance, prov_key, prov_bytes),
112 ObjectRecord::new(ObjectFamily::Attest, attest_key, attest_bytes),
113 ],
114 refs: vec![RefRecord {
115 name: "dev".to_string(),
116 expect_old: None,
117 new_target: snap_key,
118 }],
119 }
120}
121
122/// Serve the `/code` sync protocol: any GET whose path ends in `/code` gets
123/// the canned `SyncPack`; everything else is a 404. One request per

Calls 8

add_change_explainedMethod · 0.80
content_keyMethod · 0.80
to_base32Method · 0.45
buildMethod · 0.45
serializeMethod · 0.45
add_changeMethod · 0.45
nextMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected