{"record":{"id":"9f0c0415f67f2ffc","repo":"Hmbown/CodeWhale","slug":"persistent-service-id-disappeared-before-commit","errorCode":null,"errorMessage":"Persistent service {id} disappeared before commit","messagePattern":"Persistent service (.+?) disappeared before commit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/shell.rs","lineNumber":3107,"sourceCode":"\n    /// Transfer every still-running `persist:true` process out of Codewhale's\n    /// ownership. This is called only by the real headless exec host after the\n    /// enclosing turn has completed successfully.\n    #[cfg(unix)]\n    pub fn commit_persistent_services(&mut self) -> Result<Vec<PersistentServiceReceipt>> {\n        let mut ids = self\n            .processes\n            .iter()\n            .filter(|(_, shell)| shell.ownership == ShellOwnership::PersistPending)\n            .map(|(id, _)| id.clone())\n            .collect::<Vec<_>>();\n        ids.sort();\n\n        for id in &ids {\n            let shell = self\n                .processes\n                .get_mut(id)\n                .ok_or_else(|| anyhow!(\"Persistent service {id} disappeared before commit\"))?;\n            shell.poll();\n            if shell.status != ShellStatus::Running {\n                return Err(anyhow!(\n                    \"Persistent service {id} exited before ownership transfer (status {:?}, exit code {:?})\",\n                    shell.status,\n                    shell.exit_code\n                ));\n            }\n            if shell\n                .child\n                .as_ref()\n                .and_then(ShellChild::process_id)\n                .is_none()\n            {\n                return Err(anyhow!(\n                    \"Persistent service {id} has no releasable process id\"\n                ));\n            }","sourceCodeStart":3089,"sourceCodeEnd":3125,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/shell.rs#L3089-L3125","documentation":"commit_persistent_services looked up a PersistPending shell by id and found it gone between collecting the ids and the commit loop — a concurrent mutation of the process map — so the ownership transfer aborts rather than committing a partially known set.","triggerScenarios":"Thrown at crates/tui/src/tools/shell.rs:3107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["This indicates a concurrent removal raced the commit loop; inspect process state and retry the turn's persist-commit.","Avoid draining/closing the shell pool while commit_persistent_services runs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}