{"record":{"id":"66434df3603c13ef","repo":"Hmbown/CodeWhale","slug":"fleet-worker-worker-id-persisted-launch-generati","errorCode":null,"errorMessage":"Fleet worker {worker_id} persisted launch generation {generation} does not match ledger attempt {current_generation} or its prepared retry {next_generation}","messagePattern":"Fleet worker (.+?) persisted launch generation (.+?) does not match ledger attempt (.+?) or its prepared retry (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/manager.rs","lineNumber":1177,"sourceCode":"                validate_registered_launch_spec(&record.spec, &expected_current)?;\n                coordination\n                    .advance_registered_worker_generation(bind_fleet_launch_attempt(\n                        record.spec,\n                        next_generation,\n                    ))\n                    .map_err(anyhow::Error::msg)?;\n            }\n            generation if generation == next_generation => {\n                let mut normalized = record.spec;\n                normalized\n                    .launch_manifest\n                    .as_mut()\n                    .expect(\"prepared launch manifest checked above\")\n                    .generation = current_generation;\n                validate_registered_launch_spec(&normalized, &expected_current)?;\n            }\n            generation => {\n                bail!(\n                    \"Fleet worker {worker_id} persisted launch generation {generation} does not match ledger attempt {current_generation} or its prepared retry {next_generation}\"\n                );\n            }\n        }\n        Ok(())\n    }\n\n    pub fn stop_all(&self) -> Result<usize> {\n        let state = self.ledger.rebuild_state()?;\n        let now = timestamp();\n        let mut affected_runs = BTreeSet::new();\n        let mut stopped = 0usize;\n        for task in state.tasks.values() {\n            if !matches!(\n                task.status,\n                FleetTaskLedgerStatus::Enqueued | FleetTaskLedgerStatus::Leased\n            ) {\n                continue;","sourceCodeStart":1159,"sourceCodeEnd":1195,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/fleet/manager.rs#L1159-L1195","documentation":"Fleet persists a one-generation-ahead 'prepared retry' record whose generation must equal either the ledger's current attempt or the prepared next attempt. The durable record's generation matched neither, so the persisted launch state and the event ledger have diverged. This is a consistency tripwire, not an expected runtime state.","triggerScenarios":"A crash between preparing and consuming a retry generation; ledger events partially applied; the coordination store and the ledger updated out of order; state files copied/merged from another run.","commonSituations":"Hard-killing Codewhale during a worker restart; restoring a run directory from backup where coordination records and ledger events are from different points in time; hand-editing state files.","solutions":["Let stale reconciliation run to completion, then retry the restart to see if generations re-align","Clear the stale prepared-retry record for that worker so a fresh generation can be prepared","If the run's durable state is inconsistent, finish/cancel the run and start a new one rather than forcing the old one","Report it as a bug if reproducible without a crash or manual state editing"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match manager.restart_worker(&worker_id) {\n    Ok(report) => Ok(report),\n    Err(err) if err.to_string().contains(\"does not match ledger attempt\") => {\n        // durable state diverged: retire the run and start fresh rather than forcing it\n        let _ = manager.stop_run(&run_id);\n        Err(err)\n    }\n    Err(err) => Err(err),\n}","preventionTips":["Never hand-edit ledger or coordination state files","Restore ledger and coordination state only as a matched pair","Avoid hard-killing Codewhale mid-restart; use stop paths"],"tags":["fleet","state-corruption","generation-mismatch","rust","codewhale"],"backgroundTag":"persisted-state-divergence","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}