{"record":{"id":"a402a654a9668a64","repo":"Hmbown/CodeWhale","slug":"failed-to-start-turn-engine-operation-channel-clo","errorCode":null,"errorMessage":"Failed to start turn: engine operation channel closed","messagePattern":"Failed to start turn: engine operation channel closed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6105,"sourceCode":"            auto_approve,\n            translation_enabled: false,\n            allowed_tools: None,\n            dynamic_tools: req.dynamic_tools,\n            hook_executor: None,\n            approval_mode: policy.permission,\n            verbosity,\n            provenance: input_source.provenance(),\n        };\n\n        // Reserve mailbox capacity before claiming or persisting anything.\n        // If the caller is cancelled while capacity is unavailable, no\n        // durable or in-memory turn state has changed.\n        let permit = engine\n            .tx_op\n            .clone()\n            .reserve_owned()\n            .await\n            .map_err(|_| anyhow!(\"Failed to start turn: engine operation channel closed\"))?;\n\n        let acceptance_rx = {\n            // Lock order is active -> thread_mutation. Neither guard crosses\n            // an await, and spawning the owned lifecycle task is synchronous.\n            let mut active = self.active.lock().await;\n            let Some(state) = active.engines.get_mut(thread_id) else {\n                bail!(\"Thread engine not loaded\");\n            };\n            if state.active_turn.is_some() {\n                bail!(\"Thread already has an active turn\");\n            }\n            let _thread_mutation = self.store.thread_mutation.lock();\n            let mut current_thread = self.store.load_thread(thread_id)?;\n            if !thread_execution_state_matches(&thread, &current_thread) {\n                bail!(\"Thread execution settings changed while preparing the turn; retry\");\n            }\n            let previous_active_route = (state.route_identity.clone(), state.route_model.clone());\n            state.active_turn = Some(ActiveTurnState {","sourceCodeStart":6087,"sourceCodeEnd":6123,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L6087-L6123","documentation":"Reserving capacity on the engine's operation channel failed because the receiver was dropped — the turn loop has shut down, so no further turns can be submitted to this engine. Reservation happens before any durable state is claimed, so nothing is half-committed.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The engine/session has terminated; start a new session or recreate the runtime","Restart the Codewhale process if the engine should still be alive"],"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-14T05:17:10.506Z"}