{"record":{"id":"c7e20f88c07062f7","repo":"Hmbown/CodeWhale","slug":"tracked-ssh-fleet-worker-worker-id-has-no-host-a","errorCode":null,"errorMessage":"tracked SSH Fleet worker {worker_id} has no host adapter","messagePattern":"tracked SSH Fleet worker (.+?) has no host adapter","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/executor.rs","lineNumber":873,"sourceCode":"            .map(|stream| stream.started_at.elapsed())\n    }\n\n    /// Stop a tracked worker at the host boundary.\n    ///\n    /// Operator controls run in a separate process from the foreground Fleet\n    /// manager, so they communicate cancellation through the durable ledger.\n    /// The manager calls this method after observing that terminal state; the\n    /// executor is the only owner that can reliably reach the live local/SSH\n    /// adapter handle.\n    pub fn stop_worker(&mut self, worker_id: &str) -> Result<()> {\n        let ssh_key = match self.streams.get(worker_id).map(|stream| &stream.host) {\n            Some(WorkerStreamHost::Local) => None,\n            Some(WorkerStreamHost::Ssh(key)) => Some(key.clone()),\n            None => return Ok(()),\n        };\n        if let Some(key) = ssh_key {\n            let adapter = self.ssh_adapters.get_mut(&key).ok_or_else(|| {\n                anyhow::anyhow!(\"tracked SSH Fleet worker {worker_id} has no host adapter\")\n            })?;\n            adapter.stop_worker(worker_id)?;\n        } else {\n            self.adapter.stop_worker(worker_id)?;\n        }\n        Ok(())\n    }\n\n    /// Stop tracking a terminal worker so the scheduler can reuse the same\n    /// logical worker id for the next queued task.\n    pub fn forget_worker(&mut self, worker_id: &str) {\n        let Some(stream) = self.streams.remove(worker_id) else {\n            return;\n        };\n        match stream.host {\n            WorkerStreamHost::Local => {\n                let _ = self.adapter.cleanup_worker(worker_id);\n            }","sourceCodeStart":855,"sourceCodeEnd":891,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/executor.rs#L855-L891","documentation":"stop_worker looks up which host (local or SSH) a worker streams through; SSH-hosted workers must still be tracked in the matching SshHostAdapter in self.ssh_adapters. If the worker records an SSH key but no adapter is registered under that key, state is inconsistent and the stop request fails rather than leaking a running remote worker.","triggerScenarios":"Calling `stop_worker(worker_id)` for a tracked worker whose WorkerStreamHost is Ssh(key) but where `self.ssh_adapters.get_mut(&key)` finds no adapter (adapter dropped, key renamed, or worker registered before its adapter).","commonSituations":"SSH adapter disconnected/reconnected under a different key while workers stayed tracked; a worker was registered with an ssh key never added to ssh_adapters; stale ledger state referencing a removed host adapter.","solutions":["Re-register the SSH adapter under the key the worker is tracked with before stopping it.","Inspect worker metadata to confirm the ssh key; if it is stale, clean up the worker record instead of calling stop_worker.","Ensure worker registration always happens after its host adapter is added to ssh_adapters."],"exampleFix":"// before: stop with missing adapter\nmanager.stop_worker(\"worker-7\")?; // panics into error\n// after: ensure adapter exists first\nif !manager.has_ssh_adapter(&key) { manager.add_ssh_adapter(key.clone(), adapter)?; }\nmanager.stop_worker(\"worker-7\")?;","handlingStrategy":"validation","validationCode":"fn ssh_adapter_tracked(manager: &FleetManager, worker_id: &str) -> bool {\n    manager\n        .worker_ssh_key(worker_id)\n        .map(|key| manager.has_ssh_adapter(&key))\n        .unwrap_or(true) // local-hosted workers are fine\n}","typeGuard":null,"tryCatchPattern":"match manager.stop_worker(worker_id) {\n    Err(e) if e.to_string().contains(\"no host adapter\") => {\n        log::warn!(\"SSH adapter for {worker_id} is gone; marking worker lost\");\n        manager.mark_worker_lost(worker_id)?;\n    }\n    other => other?,\n}","preventionTips":["Register a worker's SSH host adapter before (or atomically with) the worker itself.","Tear down tracked workers when an SSH adapter disconnects, so state stays consistent.","Clean up stale worker records pointing at removed adapters."],"tags":["fleet","ssh","workers","state-management"],"backgroundTag":"internal-invariant-violation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}