{"record":{"id":"9a6619194e92bba5","repo":"Hmbown/CodeWhale","slug":"invalid-coordination-ledger-error","errorCode":null,"errorMessage":"Invalid coordination ledger: {error}","messagePattern":"Invalid coordination ledger: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":4343,"sourceCode":"                legacy\n            } else {\n                return Ok(());\n            }\n        };\n\n        let raw = read_subagent_state_file(&self.state_root, &path)?;\n        let state = serde_json::from_str::<PersistedSubAgentState>(&raw)?;\n        if state.schema_version != SUBAGENT_STATE_SCHEMA_VERSION {\n            return Err(anyhow!(\n                \"Unsupported sub-agent state schema {}\",\n                state.schema_version\n            ));\n        }\n\n        let mut coordination = state.coordination;\n        coordination\n            .validate_replay()\n            .map_err(|error| anyhow!(\"Invalid coordination ledger: {error}\"))?;\n        self.agents.clear();\n        self.worker_records.clear();\n        self.persist_sequence.store(\n            state.snapshot_sequence,\n            std::sync::atomic::Ordering::Relaxed,\n        );\n        self.coordination = coordination;\n        for persisted in state.agents {\n            let nickname = persisted\n                .nickname\n                .filter(|name| generated_whale_name_base(&persisted.id, name).is_none());\n            let mut status = persisted.status;\n            if matches!(status, SubAgentStatus::Running) {\n                status = SubAgentStatus::Interrupted(SUBAGENT_RESTART_REASON.to_string());\n            }\n\n            let started_at = instant_from_duration(Duration::from_millis(persisted.duration_ms));\n            // Empty vec on disk → None (full inheritance, v0.6.6 default).","sourceCodeStart":4325,"sourceCodeEnd":4361,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tools/subagent/mod.rs#L4325-L4361","documentation":"Integrity guard after loading sub-agent state: the persisted coordination ledger failed validate_replay(), meaning the recorded coordination events cannot be consistently replayed (gaps, out-of-order entries, or corrupted history). The state file passed schema and JSON checks but its event ledger is not internally consistent.","triggerScenarios":"Thrown at crates/tui/src/tools/subagent/mod.rs:4343 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the persisted sub-agent state file and let coordination rebuild from scratch","Check the inner {error} for which replay invariant failed","Avoid killing the process mid-coordination-write, which truncates the ledger"],"exampleFix":null,"handlingStrategy":"validation","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"}