{"record":{"id":"70be7366cf1a6512","repo":"zeroclaw-labs/zeroclaw","slug":"refusing-to-replace-jsonl-session-created-while","errorCode":null,"errorMessage":"Refusing to replace JSONL session created while {} was staged","messagePattern":"Refusing to replace JSONL session created while (.+?) was staged","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-infra/src/session_sqlite.rs","lineNumber":323,"sourceCode":"        let _ = path;\n        Ok(())\n    }\n\n    fn sync_staged_jsonl(path: &Path, name: &str) -> Result<()> {\n        let mut options = std::fs::OpenOptions::new();\n        options.read(true);\n        #[cfg(windows)]\n        options.write(true);\n        options\n            .open(path)\n            .with_context(|| format!(\"Failed to open staged JSONL session {name} for sync\"))?\n            .sync_all()\n            .with_context(|| format!(\"Failed to sync staged JSONL session {name}\"))\n    }\n\n    fn restore_uncommitted_jsonl(staged_path: &Path, live_path: &Path) -> Result<()> {\n        if live_path.exists() {\n            bail!(\n                \"Refusing to replace JSONL session created while {} was staged\",\n                live_path.display()\n            );\n        }\n        std::fs::rename(staged_path, live_path).with_context(|| {\n            format!(\n                \"Failed to restore empty JSONL session {}\",\n                live_path.display()\n            )\n        })\n    }\n\n    fn import_receipt(\n        conn: &Connection,\n        source_name: &str,\n    ) -> Result<Option<(String, String, i64)>> {\n        conn.query_row(\n            \"SELECT session_key, source_hash, source_len FROM jsonl_import_receipts \\","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-infra/src/session_sqlite.rs#L305-L341","documentation":"Error \"Refusing to replace JSONL session created while {} was staged\" thrown in zeroclaw-labs/zeroclaw.","triggerScenarios":"Thrown at crates/zeroclaw-infra/src/session_sqlite.rs:323 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Resolve the staged SQLite state first (complete or roll back the migration), then recreate the JSONL session."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}