{"record":{"id":"143e976aee4057cf","repo":"Hmbown/CodeWhale","slug":"failed-to-persist-compaction-persistence-error","errorCode":null,"errorMessage":"Failed to persist compaction: {persistence_error}","messagePattern":"Failed to persist compaction: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6454,"sourceCode":"                interrupt_requested: false,\n                compaction_id: Some(compaction_id),\n            });\n            state.route_identity = route_identity;\n            state.route_model = route_model;\n\n            let persistence_result = (|| -> Result<()> {\n                self.store.save_turn(&turn)?;\n                current_thread.latest_turn_id = Some(turn_id.clone());\n                current_thread.updated_at = now;\n                self.store.save_thread(&current_thread)\n            })();\n            if let Err(persistence_error) = persistence_result {\n                let cleanup_error = self.cleanup_unaccepted_turn_records(&turn_id, None).err();\n                state.active_turn = None;\n                state.route_identity = previous_active_route.0;\n                state.route_model = previous_active_route.1;\n                return match cleanup_error {\n                    None => Err(anyhow!(\"Failed to persist compaction: {persistence_error}\")),\n                    Some(cleanup_error) => Err(anyhow!(\n                        \"Failed to persist compaction: {persistence_error}; cleanup also failed: {cleanup_error}\"\n                    )),\n                };\n            }\n\n            self.register_runtime_usage_sink(&turn_id);\n            let policy = RuntimePolicyProjection::from_persisted(\n                &current_thread.mode,\n                current_thread.permission_posture.as_deref(),\n                current_thread.auto_approve,\n            );\n            engine.publish_turn_authority(\n                policy.mode,\n                current_thread.allow_shell,\n                current_thread.trust_mode,\n                policy.auto_approve(),\n                policy.permission,","sourceCodeStart":6436,"sourceCodeEnd":6472,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L6436-L6472","documentation":"From trigger_compaction: the persistence closure (save_turn for the new compaction turn, then save_thread updating latest_turn_id/updated_at) returned Err. The in-memory engine state was already mutated (active_turn pushed, route_identity/route_model set), so memory and the durable store now disagree; the companion cleanup path attempts to remove the unaccepted records.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6454 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Diagnose persistence_error (disk full, store lock, IO failure) and fix it before retrying compaction","Retry compaction after recovery; the cleanup path should have removed the unaccepted turn record","If cleanup also reported errors, check for an orphaned compaction turn in the store"],"exampleFix":null,"handlingStrategy":"try-catch","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-14T00:17:10.932Z"}