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,
)
| 362 | /// generation, so the request's expected_generation is shape discipline |
| 363 | /// only (it must be present and nonzero). |
| 364 | pub 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. |
| 391 | pub fn resume_turn( |
no test coverage detected