{"record":{"id":"883eccacf4db0e12","repo":"zeroclaw-labs/zeroclaw","slug":"jsonl-archive-changed-during-filesystem-handoff","errorCode":null,"errorMessage":"JSONL archive changed during filesystem handoff","messagePattern":"JSONL archive changed during filesystem handoff","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-infra/src/session_sqlite.rs","lineNumber":270,"sourceCode":"    fn archive_staged_jsonl(\n        staged_path: &Path,\n        migrated_path: &Path,\n        expected: &(String, i64),\n    ) -> Result<()> {\n        std::fs::hard_link(staged_path, migrated_path).with_context(|| {\n            format!(\n                \"Failed to create no-clobber JSONL archive {}\",\n                migrated_path.display()\n            )\n        })?;\n        Self::sync_parent_directory(migrated_path)?;\n        let archive_name = migrated_path\n            .file_name()\n            .and_then(|name| name.to_str())\n            .unwrap_or(\"archive\");\n        if &Self::source_fingerprint(migrated_path, archive_name)? != expected {\n            let _ = std::fs::remove_file(migrated_path);\n            bail!(\"JSONL archive changed during filesystem handoff\");\n        }\n        std::fs::remove_file(staged_path).with_context(|| {\n            format!(\n                \"Failed to remove staged JSONL source {}\",\n                staged_path.display()\n            )\n        })?;\n        Self::sync_parent_directory(staged_path)?;\n        Ok(())\n    }\n\n    fn sync_parent_directory(path: &Path) -> Result<()> {\n        #[cfg(unix)]\n        {\n            let parent = path\n                .parent()\n                .filter(|parent| !parent.as_os_str().is_empty())\n                .unwrap_or_else(|| Path::new(\".\"));","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-infra/src/session_sqlite.rs#L252-L288","documentation":"Consistency guard in archive_staged_jsonl during the JSONL-to-SQLite migration handoff: after hard-linking the staged file to its .migrated archive name, the archive's source fingerprint no longer matches the expected (hash, length) pair captured when the file was staged. Something modified the file across the filesystem handoff, so the no-clobber archive is treated as corrupted and the migration aborts rather than trusting it.","triggerScenarios":"Thrown at crates/zeroclaw-infra/src/session_sqlite.rs:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not modify the JSONL session file while migration is running; stop writers and retry the handoff."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","contentChangedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}