{"record":{"id":"e8226c4e83f662fa","repo":"zeroclaw-labs/zeroclaw","slug":"validation-failed-after-write-e","errorCode":null,"errorMessage":"Validation failed after write: {e}","messagePattern":"Validation failed after write: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-runtime/src/skills/improver.rs","lineNumber":108,"sourceCode":"        // Preserve any existing audit trail from the original file.\n        let audit_trail = extract_audit_trail(&existing);\n        let final_content = if audit_trail.is_empty() {\n            format!(\"{updated}{audit_entry}\")\n        } else {\n            format!(\"{updated}\\n{audit_trail}{audit_entry}\")\n        };\n\n        // Atomic write: temp file → validate → rename.\n        let temp_path = skill_dir.join(\".SKILL.md.tmp\");\n        tokio::fs::write(&temp_path, final_content.as_bytes())\n            .await\n            .with_context(|| format!(\"Failed to write temp file: {}\", temp_path.display()))?;\n\n        // Validate the temp file is readable and valid.\n        let written = tokio::fs::read_to_string(&temp_path).await?;\n        if let Err(e) = validate_skill_content(&written) {\n            let _ = tokio::fs::remove_file(&temp_path).await;\n            bail!(\"Validation failed after write: {e}\");\n        }\n\n        // Rename atomically (same filesystem).\n        tokio::fs::rename(&temp_path, &md_path)\n            .await\n            .with_context(|| {\n                format!(\n                    \"Failed to rename {} to {}\",\n                    temp_path.display(),\n                    md_path.display()\n                )\n            })?;\n\n        self.cooldowns.insert(slug.to_string(), Instant::now());\n\n        Ok(Some(slug.to_string()))\n    }\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/skills/improver.rs#L90-L126","documentation":"Error \"Validation failed after write: {e}\" thrown in zeroclaw-labs/zeroclaw.","triggerScenarios":"Thrown at crates/zeroclaw-runtime/src/skills/improver.rs:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the validation error reported after write and re-run the improver."],"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"}