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

Function enriched_session_turn

libatomic/src/daemon/services_provenance.rs:287–319  ·  view source on GitHub ↗

The wire SessionTurn carries only the identity pair; the domain bind requires the full stored turn shape. Enrich from the prepared checkpoint's frozen source (change hashes, previous provenance, plan, prepared_at as the stable timestamp) so a retried bind reconstructs the IDENTICAL session turn and hits the store's idempotency path — the goal/todos fields remain a wire-contract limitation (the in-

(
    store: &atomic_repository::redb_change_store::RedbChangeStore,
    id: ProvenanceId,
    turn: &crate::atomic::SessionTurn,
    hash: Hash,
    now: i64,
)

Source from the content-addressed store, hash-verified

285/// the goal/todos fields remain a wire-contract limitation (the
286/// in-process dispatch path keeps the full session turn).
287fn enriched_session_turn(
288 store: &atomic_repository::redb_change_store::RedbChangeStore,
289 id: ProvenanceId,
290 turn: &crate::atomic::SessionTurn,
291 hash: Hash,
292 now: i64,
293) -> SessionTurn {
294 let mut enriched = SessionTurn {
295 session_id: turn.session_id.clone(),
296 turn_number: turn.turn_number,
297 goal: None,
298 provenance_hash: hash,
299 change_hashes: Vec::new(),
300 previous_provenance: None,
301 timestamp: now,
302 plan_id: None,
303 todos: Vec::new(),
304 boundary_start: None,
305 boundary_end: None,
306 outcome: None,
307 };
308 if let Ok(Some(stored)) = store.get_provenance_turn(id) {
309 if let Some(attempt) = stored.checkpoint_attempt {
310 enriched.change_hashes = attempt.source.change_hashes;
311 enriched.previous_provenance = attempt.source.previous_provenance;
312 enriched.plan_id = attempt.source.plan_id;
313 // Deterministic across retries (a retry's observed_at differs;
314 // the prepared_at does not) — bind idempotency depends on it.
315 enriched.timestamp = attempt.prepared_at;
316 }
317 }
318 enriched
319}
320
321fn core_status(error: core::JournalError) -> Status {
322 domain_status(error.code, error.message)

Callers 1

Calls 2

get_provenance_turnMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected