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

Function stop_turn

libatomic/src/daemon/provenance_core.rs:364–388  ·  view source on GitHub ↗

Stop a running turn. Like the legacy owner, the looked-up turn's own current generation performs the transition — a lookup never grants a generation, so the request's expected_generation is shape discipline only (it must be present and nonzero).

(
    store: &RedbChangeStore,
    session_id: &str,
    turn_number: u32,
    cause: StopCause,
    resumable: bool,
    observed_at: i64,
)

Source from the content-addressed store, hash-verified

362/// generation, so the request's expected_generation is shape discipline
363/// only (it must be present and nonzero).
364pub fn stop_turn(
365 store: &RedbChangeStore,
366 session_id: &str,
367 turn_number: u32,
368 cause: StopCause,
369 resumable: bool,
370 observed_at: i64,
371) -> Result<Option<StoredProvenanceTurn>, JournalError> {
372 let Some(turn) = lifecycle_lookup(store, session_id, turn_number)? else {
373 return Ok(None);
374 };
375 let stopped = store
376 .stop_provenance_turn(
377 turn.provenance_id,
378 turn.generation,
379 StopState {
380 cause,
381 observed_at,
382 last_event_seq: None,
383 resumable,
384 },
385 )
386 .map_err(|error| JournalError::store(ErrorCode::ProvenanceLifecycle, error))?;
387 Ok(Some(stopped))
388}
389
390/// Resume a stopped turn with a new fencing generation and the same ID.
391pub fn resume_turn(

Callers 1

update_turn_implFunction · 0.85

Calls 3

lifecycle_lookupFunction · 0.85
storeFunction · 0.85
stop_provenance_turnMethod · 0.80

Tested by

no test coverage detected