{"record":{"id":"3b0113d8a4d8c9b3","repo":"Hmbown/CodeWhale","slug":"failed-to-persist-steer-error-cleanup-also-fai","errorCode":null,"errorMessage":"Failed to persist steer: {error}; cleanup also failed: {cleanup_error}","messagePattern":"Failed to persist steer: (.+?); cleanup also failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6305,"sourceCode":"                let mut turn = self.store.load_turn(turn_id)?;\n                if turn.status != RuntimeTurnStatus::InProgress {\n                    bail!(\"Turn {turn_id} is no longer in progress and cannot be steered\");\n                }\n                self.store.save_item(&item)?;\n                turn.steer_count = turn.steer_count.saturating_add(1);\n                if !turn.item_ids.iter().any(|id| id == &item.id) {\n                    turn.item_ids.push(item.id.clone());\n                }\n                self.store.save_turn(&turn)?;\n                Ok(turn)\n            })();\n            let turn = match persistence {\n                Ok(turn) => turn,\n                Err(error) => {\n                    let cleanup = self.store.remove_item(&item.id);\n                    return match cleanup {\n                        Ok(()) => Err(error),\n                        Err(cleanup_error) => Err(anyhow!(\n                            \"Failed to persist steer: {error}; cleanup also failed: {cleanup_error}\"\n                        )),\n                    };\n                }\n            };\n            // The reserved send has no await/failure point. From here the\n            // engine and durable record agree even if the API caller drops.\n            let _sender = permit.send(prompt.clone());\n            touch_lru(&mut active.lru, thread_id);\n            self.spawn_steer_receipts(turn, item, prompt)\n        };\n        receipt_rx\n            .await\n            .map_err(|_| anyhow!(\"Steer receipt task ended before acknowledgement\"))\n    }\n\n    pub async fn compact_thread(\n        &self,","sourceCodeStart":6287,"sourceCodeEnd":6323,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L6287-L6323","documentation":"Compound sentinel from steer persistence: the closure that loads the turn, verifies it is still InProgress, saves the steer item and updated turn record failed (persistence_error), and the compensating remove_item rollback in the Err arm also failed (cleanup_error). The store may now contain a steer item whose turn record was not updated.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6305 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the underlying store error (turn no longer InProgress is a benign race; treat as a lost steer and re-send the message)","If cleanup failed, inspect the store for the orphaned item id and remove it before steering again","Ensure only one process is steering the same turn concurrently"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}