{"record":{"id":"022ff872b79f4b56","repo":"Hmbown/CodeWhale","slug":"unknown-legacy-checkpoint-origin","errorCode":null,"errorMessage":"unknown legacy checkpoint origin","messagePattern":"unknown legacy checkpoint origin","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/session_manager.rs","lineNumber":2097,"sourceCode":"    }\n\n    fn legacy_checkpoint_origin(&self) -> io::Result<Option<String>> {\n        use std::io::Read as _;\n\n        let path = self.checkpoints_dir().join(LEGACY_CHECKPOINT_FILE);\n        let file = match open_private_read_file(&path) {\n            Ok(file) => file,\n            Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(None),\n            Err(error) => return Err(error),\n        };\n        // Lifecycle cleanup only needs the leading metadata. Never follow\n        // links or read an unbounded legacy transcript to identify its owner.\n        let mut prefix = Vec::new();\n        file.take(1024 * 1024).read_to_end(&mut prefix)?;\n        extract_top_level_metadata(&prefix)\n            .map(|metadata| Some(metadata.id))\n            .ok_or_else(|| {\n                io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    \"unknown legacy checkpoint origin\",\n                )\n            })\n    }\n\n    /// Clear one session's crash-recovery checkpoint. Scoped: this can never\n    /// remove another session's checkpoint file or the legacy slot.\n    pub fn clear_session_checkpoint(&self, session_id: &str) -> std::io::Result<()> {\n        let path = self.validated_checkpoint_path(session_id)?;\n        if path.exists() {\n            fs::remove_file(path)?;\n        }\n        Ok(())\n    }\n\n    /// Remove the legacy single-slot checkpoint file.\n    pub fn clear_legacy_checkpoint(&self) -> std::io::Result<()> {","sourceCodeStart":2079,"sourceCodeEnd":2115,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/session_manager.rs#L2079-L2115","documentation":"To identify a legacy checkpoint's owning session, the manager reads only the first 1 MB of the file and parses top-level metadata via extract_top_level_metadata. If the session id cannot be extracted from that prefix, it returns InvalidData with \"unknown legacy checkpoint origin\" rather than reading an unbounded legacy transcript or following symlinks.","triggerScenarios":"Calling the legacy-checkpoint ownership probe on a file whose JSON header lacks a parseable top-level metadata block, or whose metadata sits beyond the first 1024*1024 bytes.","commonSituations":"A very old checkpoint format with no id in the header; a corrupted or hand-mangled legacy file; a huge legacy transcript whose metadata block was written after the 1 MB mark.","solutions":["Inspect the first 1 MB of the file for a top-level metadata object containing an id; repair or add it if the file was edited","Restore the legacy checkpoint from backup, or discard it and recreate the session","If the format is genuinely too old, migrate the file to a current checkpoint layout manually or via a migration tool"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let mut prefix = Vec::new();\nfile.take(1024 * 1024).read_to_end(&mut prefix)?;\nif extract_top_level_metadata(&prefix).is_none() {\n    eprintln!(\"file has no recognizable metadata header; not a loadable legacy checkpoint\");\n}","typeGuard":null,"tryCatchPattern":"match legacy_checkpoint_owner(path) {\n    Ok(Some(id)) => adopt(id),\n    Ok(None) | Err(_) => eprintln!(\"cannot determine owner; skipping this legacy checkpoint\"),\n}","preventionTips":["Migrate very old checkpoints to the current format instead of carrying them forward","Don't hand-edit or truncate legacy checkpoint files","Keep the metadata header at the top of any checkpoint JSON you construct"],"tags":["legacy","checkpoint","metadata"],"backgroundTag":"record-not-found","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"}