{"record":{"id":"b69736f9faaee5d6","repo":"astrid-runtime/astrid","slug":"preserved","errorCode":null,"errorMessage":"preserved","messagePattern":"preserved","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/audit_retirement_tests.rs","lineNumber":87,"sourceCode":"    home.ensure().expect(\"home layout\");\n    let other = astrid_core::PrincipalId::new(\"other\".to_owned()).expect(\"principal id\");\n    let other_home = home.principal_home(&other);\n    other_home.ensure().expect(\"legacy principal layout\");\n    std::fs::write(other_home.audit_dir().join(\"entry\"), b\"audit\").expect(\"non-empty audit\");\n    let default_source = home\n        .principal_home(&astrid_core::PrincipalId::default())\n        .audit_dir();\n\n    let error = preflight_legacy_audit_sources(&home, &default_source)\n        .expect_err(\"unhandled non-empty source must block boot\");\n    assert!(\n        error\n            .to_string()\n            .contains(\"only the default principal source\")\n    );\n    assert!(other_home.audit_dir().exists());\n    assert_eq!(\n        std::fs::read(other_home.audit_dir().join(\"entry\")).expect(\"preserved\"),\n        b\"audit\"\n    );\n}\n\n#[test]\nfn audit_boot_allows_empty_non_default_audit_directory() {\n    let directory = tempfile::tempdir().expect(\"temporary home\");\n    let home = AstridHome::from_path(directory.path().join(\".astrid\"));\n    home.ensure().expect(\"home layout\");\n    let other = astrid_core::PrincipalId::new(\"other\".to_owned()).expect(\"principal id\");\n    let other_home = home.principal_home(&other);\n    other_home.ensure().expect(\"legacy principal layout\");\n    let default_source = home\n        .principal_home(&astrid_core::PrincipalId::default())\n        .audit_dir();\n    preflight_legacy_audit_sources(&home, &default_source)\n        .expect(\"empty non-default audit must not refuse cutover\");\n    assert!(other_home.audit_dir().exists());","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/audit_retirement_tests.rs#L69-L105","documentation":"Panic from `std::fs::read(other_home.audit_dir().join(\"entry\")).expect(\"preserved\")` in the assertion phase of the same test, verifying the legacy audit entry survived the failed boot untouched. The expect fires when the entry file cannot be read back.","triggerScenarios":"Reading `audit_dir/entry` after preflight when a prior assertion step deleted or moved the audit directory, or when the file was never written (earlier expect would have fired) and the path is wrong/removed by the code under test.","commonSituations":"A regression where the audit-retirement code deletes or rewrites non-default audit sources during preflight instead of leaving them preserved; path changes to `audit_dir()` between write and read.","solutions":["Check whether preflight_legacy_audit_sources (or boot) mutates/deletes the non-default audit directory — preservation is the contract under test.","Confirm the same path is used for write and read (no rename of audit_dir).","Re-run the test in isolation to rule out cross-test interference on shared temp state.","Inspect the io::Error: NotFound means the code under test removed the file."],"exampleFix":"// before\nstd::fs::read(other_home.audit_dir().join(\"entry\")).expect(\"preserved\")\n// after\nlet bytes = std::fs::read(other_home.audit_dir().join(\"entry\"))\n    .unwrap_or_else(|e| panic!(\"preserved audit entry unreadable: {e}\"));","handlingStrategy":"validation","validationCode":"let entry = other_home.audit_dir().join(\"entry\");\nassert!(entry.exists(), \"audit entry was not preserved\");","typeGuard":null,"tryCatchPattern":"let bytes = std::fs::read(&entry)\n    .unwrap_or_else(|e| panic!(\"preserved entry unreadable ({e}) — was it deleted by preflight?\"));","preventionTips":["Assert file existence before content comparison for clearer failures.","Treat NotFound here as a preservation-contract regression in boot/preflight code.","Run tests in isolation to rule out shared-state interference."],"tags":["filesystem","test","panic","file-read"],"backgroundTag":"file-read-failed","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"}