{"record":{"id":"52a3c39d96f49c9b","repo":"Hmbown/CodeWhale","slug":"imported-content-digest-mismatch-after-copy-abort","errorCode":null,"errorMessage":"imported content digest mismatch after copy; aborted","messagePattern":"imported content digest mismatch after copy; aborted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/skills/mutation.rs","lineNumber":777,"sourceCode":"            return Err(err).context(\"failed to replace destination with imported skill\");\n        }\n        backup_path = Some(backup);\n    } else if let Err(err) = fs::rename(&staging, &dest) {\n        let _ = fs::remove_dir_all(&staging);\n        return Err(err).context(\"failed to install imported skill\");\n    }\n    validate_owned_target_chain(anchor, &skills_dir, true)?;\n    validate_owned_child(&skills_dir, &dest, true)?;\n\n    // Keep backup until digest + marker finalize succeed so a failed import\n    // can restore the previous owned skill.\n    let finalize = (|| -> Result<String> {\n        let _ = verify_expected_digest(&source_path, Some(&expected_digest))?;\n        validate_owned_target_chain(anchor, &skills_dir, true)?;\n        validate_owned_child(&skills_dir, &dest, true)?;\n        let after = package_digest::compute_package_digest(&dest)?;\n        if after != expected_digest {\n            bail!(\"imported content digest mismatch after copy; aborted\");\n        }\n        write_installed_from_v2(\n            &dest,\n            &format!(\"import:{}\", source_skill.safe_display_path),\n            None,\n            &expected_digest,\n            &after,\n            &source_id.canonical_name,\n        )?;\n        Ok(after)\n    })();\n\n    let after = match finalize {\n        Ok(after) => {\n            if let Some(backup) = backup_path.take() {\n                fs::remove_dir_all(&backup).ok();\n            }\n            after","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/skills/mutation.rs#L759-L795","documentation":"After copying, `import_external` recomputes the package digest of the destination and compares it to the pre-copy source digest. A mismatch means the copied content on disk does not match what was audited before the copy, so the import aborts rather than installing unverified content.","triggerScenarios":"`package_digest::compute_package_digest(&dest)` differs from `expected_digest` after `copy_skill_package` completes — e.g. the source changed mid-copy, a marker file was skipped, or a partial copy left the destination incomplete.","commonSituations":"Another process (editor sync, git checkout, another agent) modified the external source between the pre-copy and post-copy digest checks; a partial/failed copy; platform quirks turning symlinks into real files and shifting the tree.","solutions":["Re-run the import; transient concurrent modification is the most common cause.","Quiesce concurrent writers (close editors, stop sync tools) so the external source is stable during import.","Remove the partially copied destination directory and import again from a clean state.","Verify the source package contains no files the copier skips (symlinks, marker files) that shift the digest."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"let before = verify_expected_digest(&source_path, Some(&expected_digest))?; // re-verify source stability immediately before import","typeGuard":null,"tryCatchPattern":"if err.to_string().contains(\"digest mismatch after copy\") {\n    // remove partial dest and retry once with no concurrent writers\n}","preventionTips":["Do not edit external skill sources while an import is running.","Pause file-sync/editor tools during skill imports.","Clean up partially copied destinations before retrying."],"tags":["skills","integrity","checksum"],"backgroundTag":"checksum-mismatch","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"}