{"record":{"id":"9303cc94d5298384","repo":"Hmbown/CodeWhale","slug":"error-additionally-failed-to-persist-contention","errorCode":null,"errorMessage":"{error}; additionally failed to persist contention receipt: {persist_error}","messagePattern":"(.+?); additionally failed to persist contention receipt: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":6393,"sourceCode":"                    let active_owners = self.active_coordination_owners();\n                    self.coordination\n                        .register_claim(claim, options.isolated_worktree, |owner| {\n                            active_owners.contains(owner)\n                        })\n                })\n                .transpose()\n        } else {\n            Ok(None)\n        };\n        let persisted_claim = match persisted_claim {\n            Ok(claim) => claim,\n            Err(error) => {\n                if let Err(persist_error) = self.persist_state_synchronously() {\n                    if let Some((worker_records, coordination)) = durable_launch_snapshot.as_ref() {\n                        self.worker_records = worker_records.clone();\n                        self.coordination = coordination.clone();\n                    }\n                    return Err(anyhow!(\n                        \"{error}; additionally failed to persist contention receipt: {persist_error}\"\n                    ));\n                }\n                return Err(anyhow!(error));\n            }\n        };\n        let mut projection_capabilities = tools.clone().unwrap_or_else(|| {\n            [\"Bash\", \"File\", \"Git\", \"Run\", \"Web\"]\n                .into_iter()\n                .map(str::to_string)\n                .collect()\n        });\n        projection_capabilities.push(agent_type.as_str().to_string());\n        if let Some(role) = assignment.role.as_ref()\n            && !projection_capabilities.contains(role)\n        {\n            projection_capabilities.push(role.clone());\n        }","sourceCodeStart":6375,"sourceCodeEnd":6411,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tools/subagent/mod.rs#L6375-L6411","documentation":"While durably registering a write-capable launch, persisting the write claim failed; the manager then tried to synchronously persist a contention receipt recording the refused launch, and that also failed. This is a compound error: the in-memory worker/coordination snapshot is restored (rolled back) and both the original error and the receipt-persist error are reported together. It signals the durable state store itself is unhealthy.","triggerScenarios":"Filesystem failures on the coordination state path during claim persistence — disk full, permission denied, read-only mount; a corrupted or locked state file that fails both the claim write and the synchronous persist; concurrent managers contending over a damaged shared state file.","commonSituations":"Disk-full incidents on long-running sessions; state directory ownership changed under a running process (container restart with different uid); NFS or exotic filesystems breaking atomic writes of the state file.","solutions":["Fix the underlying IO problem first: free disk space, correct permissions/ownership on the state path, remount read-write","Verify the state store is writable (a trivial write to the state directory) before retrying the launch","Retry the spawn only after the state store is healthy — never retry blindly, since each attempt may leave contention records half-written","If the state file is corrupted, restore from backup or remove it and let agents respawn (accepting the loss of prior coordination records)"],"exampleFix":"// before\nlet agent = manager.spawn_subagent_from_input(&request).await?;\n\n// after\nmatch manager.spawn_subagent_from_input(&request).await {\n    Err(e) if e.to_string().contains(\"failed to persist contention receipt\") => {\n        alert_state_store_unhealthy(&e); // surface both errors; do not retry\n        return Err(e);\n    }\n    other => other,\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight the state store before write-capable fan-out.\nfn state_store_healthy(state_path: &Path) -> bool {\n    let probe = state_path.join(\".write-probe\");\n    std::fs::write(&probe, b\"1\").is_ok() && std::fs::remove_file(&probe).is_ok()\n}","typeGuard":null,"tryCatchPattern":"On the compound 'additionally failed to persist contention receipt' error, halt spawning immediately and page/alert on state-store health; the message carries both errors — log them as a pair and never auto-retry until the IO root cause is fixed.","preventionTips":["Monitor free space and writability of the coordination state directory as a first-class health signal","Keep the state file on a local filesystem with atomic rename support; avoid NFS for coordination state","Back up the coordination state file so corruption can be recovered without losing the whole session"],"tags":["subagent","rust","persistence","io-error","compound-error","disk-full","coordination"],"backgroundTag":"state-persistence-failure","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}