{"record":{"id":"bb8945c68f8848ba","repo":"astrid-runtime/astrid","slug":"durable-capsule-id-failed-byte-for-byte-readback","errorCode":null,"errorMessage":"durable capsule {id} failed byte-for-byte readback","messagePattern":"durable capsule (.+?) failed byte-for-byte readback","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/storage/migration.rs","lineNumber":185,"sourceCode":"        verification\n            .content_digest()\n            .clone_into(&mut durable_authority.content_digest);\n        let durable_authority_bytes = serde_json::to_vec_pretty(&durable_authority)\n            .with_context(|| format!(\"serialize durable legacy capsule authority {id}\"))?;\n        let package = CapsulePackage::new(archive, meta_bytes, durable_authority_bytes);\n        let expectation = match registry.get_snapshot(&owner, id)? {\n            None => CapsuleInstallExpectation::Absent,\n            Some(snapshot) if snapshot.package() == &package => {\n                CapsuleInstallExpectation::Generation(snapshot.generation())\n            },\n            Some(_) => bail!(\"durable capsule {id} conflicts with legacy native content\"),\n        };\n        registry.install(&owner, id, &package, expectation)?;\n        let readback = registry\n            .get_snapshot(&owner, id)?\n            .ok_or_else(|| anyhow::anyhow!(\"durable capsule {id} disappeared after publish\"))?;\n        if readback.package() != &package {\n            bail!(\"durable capsule {id} failed byte-for-byte readback\");\n        }\n        read_verified_durable_package_for_owner(store, &owner, id)?.ok_or_else(|| {\n            anyhow::anyhow!(\"durable capsule {id} failed authoritative verification\")\n        })?;\n        astrid_core::platform_fs::verify_no_redirects(&target)\n            .with_context(|| format!(\"verify legacy capsule {id} before retirement\"))?;\n        let final_archive = canonical_legacy_archive(home, &target, &meta, &manifest)?;\n        if final_archive != package.archive {\n            bail!(\"legacy capsule {id} changed before retirement\");\n        }\n        if fs::read(target.join(\"meta.json\"))? != package.metadata {\n            bail!(\"legacy capsule {id} metadata changed before retirement\");\n        }\n        if read_installed_authority_bytes(home, &target)?.as_deref()\n            != Some(source_authority_bytes.as_slice())\n        {\n            bail!(\"legacy capsule {id} authority changed before retirement\");\n        }","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/storage/migration.rs#L167-L203","documentation":"After installing the migrated package into the durable registry, migration reads the snapshot back and compares it byte-for-byte with what was written. A mismatch means the durable store did not faithfully persist the package — an internal consistency failure — so migration aborts.","triggerScenarios":"The durable registry returned a snapshot whose package bytes differ from the installed CapsulePackage; storage corruption or a buggy/concurrent writer modified the stored package between install and readback.","commonSituations":"Corrupted store directory; another process writing the same capsule concurrently; disk/cache issues in the durable store.","solutions":["Re-run migration (the install is transactional and can be retried)","Verify/repair the durable store's integrity (checksums, fsck-like validation)","Ensure no other process writes to the store concurrently during migration","Report as a store bug if it reproduces on a healthy, quiescent store"],"exampleFix":"// before\nmigrate_all_native_capsules(store)  // concurrent writer active\n// after\nstop other astrid processes; then migrate_all_native_capsules(store)","handlingStrategy":"retry","validationCode":"// check store health and quiescence before migrating\nif other_astrid_processes_running() { return Err(\"stop concurrent writers\"); }\n// optionally verify an existing durable capsule's checksums before migration","typeGuard":null,"tryCatchPattern":"match migrate_native_capsules(home, store) {\n    Err(e) if e.to_string().contains(\"failed byte-for-byte readback\") => {\n        eprintln!(\"store write not durable or corrupted; verify store and retry\");\n    }\n    other => other?,\n}","preventionTips":["Run migration with no other astrid processes touching the store","Validate/repair the durable store after crashes or disk issues","Back up the store directory before large migrations","Report reproducible readback failures as store bugs"],"tags":["migration","readback","integrity","registry","capsule"],"backgroundTag":"checksum-mismatch","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}