{"record":{"id":"9469225b365a790c","repo":"Hmbown/CodeWhale","slug":"thread-engine-not-loaded","errorCode":null,"errorMessage":"Thread engine not loaded","messagePattern":"Thread engine not loaded","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6112,"sourceCode":"            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 {\n                turn_id: turn_id.clone(),\n                interrupt_requested: false,\n                compaction_id: None,\n            });\n            state.route_identity = provider_identity;\n            state.route_model.clone_from(&model);\n","sourceCodeStart":6094,"sourceCodeEnd":6130,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L6094-L6130","documentation":"Inside the start-turn critical section, the thread id had no entry in the active engines map — the engine was expected to be loaded (ensure_engine_loaded ran earlier) but is not registered. Effectively an internal invariant failure, typically triggered by concurrent teardown/eviction of the engine between load and claim.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the turn start so the engine reloads","If persistent, check for concurrent thread teardown or eviction"],"exampleFix":null,"handlingStrategy":"retry","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"}