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

Function checkpoint

libatomic/src/review/incremental.rs:1227–1276  ·  view source on GitHub ↗
(
        repo: &Repository,
        session: &str,
        timestamp: i64,
        hashes: Vec<Hash>,
        plan: Option<&str>,
    )

Source from the content-addressed store, hash-verified

1225 }
1226
1227 fn checkpoint(
1228 repo: &Repository,
1229 session: &str,
1230 timestamp: i64,
1231 hashes: Vec<Hash>,
1232 plan: Option<&str>,
1233 ) -> u32 {
1234 let mut builder = ProvenanceGraph::builder(session, "test").timestamp(timestamp);
1235 let previous = repo
1236 .get_session_ledger(session)
1237 .unwrap()
1238 .and_then(|(_, turns)| turns.last().map(|turn| turn.provenance_hash));
1239 if let Some(previous) = previous {
1240 builder = builder.previous(previous);
1241 }
1242 for hash in &hashes {
1243 builder = builder.add_change_explained(*hash);
1244 }
1245 if let Some(plan) = plan {
1246 builder = builder.plan_id(plan);
1247 }
1248 let graph = builder.build();
1249 let graph_hash = Hash::of(&graph.serialize().unwrap());
1250 repo.publish_provenance_checkpoint(
1251 &graph,
1252 SessionTurn {
1253 session_id: session.into(),
1254 turn_number: 0,
1255 goal: None,
1256 provenance_hash: graph_hash,
1257 change_hashes: hashes,
1258 previous_provenance: previous,
1259 timestamp,
1260 plan_id: plan.map(str::to_owned),
1261 todos: vec![],
1262 boundary_start: None,
1263 boundary_end: None,
1264 outcome: None,
1265 },
1266 )
1267 .unwrap();
1268 repo.get_session_ledger(session)
1269 .unwrap()
1270 .unwrap()
1271 .1
1272 .into_iter()
1273 .find(|turn| turn.provenance_hash == graph_hash)
1274 .unwrap()
1275 .turn_number
1276 }
1277
1278 fn inspect(repo: &Repository, args: IncrementalArgs) -> CliResult<IncrementalReport> {
1279 resolve_with_session(repo, &args, None)

Calls 11

get_session_ledgerMethod · 0.80
lastMethod · 0.80
previousMethod · 0.80
add_change_explainedMethod · 0.80
plan_idMethod · 0.80
timestampMethod · 0.45
unwrapMethod · 0.45
buildMethod · 0.45
serializeMethod · 0.45
into_iterMethod · 0.45