{"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":"anyhow::Error","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/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/skills/mutation.rs#L759-L795","documentation":"Raised during import finalization: after copying the staged package into the destination, the freshly written content's digest does not match the expected digest that was verified before the copy. This indicates the on-disk result diverged from the audited source (concurrent modification, filesystem issue, or a non-deterministic copy), and the import is aborted rather than finalized with unverified content.","triggerScenarios":"Thrown at crates/tui/src/skills/mutation.rs:777 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-scan the external skill source to obtain a fresh digest and retry the import","Check whether the source package was modified concurrently during the import","If a backup of the previous owned skill was kept, it is restored; verify the destination state after the failure"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}