{"record":{"id":"df38fdc189ab408e","repo":"astrid-runtime/astrid","slug":"legacy-log-receipt-identity-mismatch","errorCode":null,"errorMessage":"legacy log receipt identity mismatch: {}","messagePattern":"legacy log receipt identity mismatch: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/principal_log_migration.rs","lineNumber":89,"sourceCode":"/// The migration verifies every destination byte before publishing this\n/// receipt. Runtime logs are appendable operational state, so later proof\n/// checks bind the immutable receipt rather than re-hashing the live log tree.\n///\n/// # Errors\n///\n/// Returns an error when the receipt exists but is malformed or belongs to a\n/// different UID.\npub(crate) fn legacy_log_destination_proof(\n    home: &AstridHome,\n    uid: PrincipalUid,\n) -> io::Result<String> {\n    let path = receipt_path(home, uid);\n    let Some(bytes) = read_receipt_bytes(&path)? else {\n        return Ok(\"absent\".to_owned());\n    };\n    let receipt: LogReceipt = decode_receipt(&bytes, &path)?;\n    if receipt.schema != RECEIPT_SCHEMA || receipt.uid != uid {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\"legacy log receipt identity mismatch: {}\", path.display()),\n        ));\n    }\n    Ok(format!(\"blake3:{}\", blake3::hash(&bytes).to_hex()))\n}\n\nfn migrate_one(\n    home: &AstridHome,\n    alias: &PrincipalId,\n    uid: PrincipalUid,\n    source: &Path,\n) -> io::Result<()> {\n    let receipt_path = receipt_path(home, uid);\n    if let Some(bytes) = read_receipt_bytes(&receipt_path)? {\n        let receipt: LogReceipt = decode_receipt(&bytes, &receipt_path)?;\n        if receipt.schema != RECEIPT_SCHEMA || receipt.uid != uid || receipt.alias != *alias {\n            return Err(conflict(","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/principal_log_migration.rs#L71-L107","documentation":"The legacy log import receipt on disk does not match the expected schema version or does not belong to the requested uid. The kernel requires every receipt to carry the current RECEIPT_SCHEMA and the same uid it was written for before it can be used as a destination proof. This prevents an old-format or misfiled receipt from being trusted during migration verification.","triggerScenarios":"`legacy_log_destination_proof` reads the receipt at `receipt_path(home, uid)` and finds `receipt.schema != RECEIPT_SCHEMA` or `receipt.uid != uid`. Triggered by receipts written by an older kernel version, a receipt copied/renamed to another uid's path, or a hand-edited receipt.","commonSituations":"Upgrading the app across a schema-version bump while old receipts remain on disk; manually copying home directories between accounts/uids; restoring a partial backup where receipts and logs diverged.","solutions":["Delete or move aside the stale receipt so it is regenerated (an absent receipt is handled as \"absent\")","Re-run the legacy log migration so a fresh receipt with the current schema and uid is written","If upgrading, run any provided migration/upgrade command that rewrites receipts before verification","Do not hand-edit or copy receipt files between uid paths"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before relying on a receipt, check its schema/uid yourself\nlet receipt: serde_json::Value = serde_json::from_slice(&bytes)?;\nif receipt[\"schema\"] != EXPECTED_SCHEMA || receipt[\"uid\"] != uid {\n    // stale or foreign receipt: treat as absent and let it regenerate\n    std::fs::remove_file(&path)?;\n}","typeGuard":"fn is_current_receipt(r: &LogReceipt, uid: &str) -> bool {\n    r.schema == RECEIPT_SCHEMA && r.uid == uid\n}","tryCatchPattern":null,"preventionTips":["Never copy receipt files between uid paths or homes","Run the app's upgrade/migration command after version bumps before verification","Treat receipts as opaque kernel-managed files"],"tags":["migration","receipt","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}