{"record":{"id":"9d1a303b9593c596","repo":"astrid-runtime/astrid","slug":"temporary-home","errorCode":null,"errorMessage":"temporary home","messagePattern":"temporary home","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/audit_retirement_tests.rs","lineNumber":8,"sourceCode":"use super::{preflight_legacy_audit_sources, require_audit_integrity, retire_legacy_audit_dir};\nuse astrid_audit::ChainVerificationResult;\nuse astrid_core::SessionId;\nuse astrid_core::dirs::AstridHome;\n\n#[test]\nfn audit_retirement_validates_tree_and_removes_only_verified_source() {\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 principal_home = home.principal_home(&astrid_core::PrincipalId::default());\n    principal_home.ensure().expect(\"legacy principal layout\");\n    std::fs::write(principal_home.audit_dir().join(\"entry\"), b\"audit\").expect(\"audit fixture\");\n\n    retire_legacy_audit_dir(&home, &principal_home.audit_dir()).expect(\"retire audit source\");\n    assert!(!principal_home.audit_dir().exists());\n    assert!(\n        !home\n            .migrations_dir()\n            .join(\"audit-principal-home.retired\")\n            .exists()\n    );\n}\n\n#[cfg(unix)]\n#[test]","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/audit_retirement_tests.rs#L1-L26","documentation":"Test setup assertion in `audit_retirement_validates_tree_and_removes_only_verified_source`: `tempfile::tempdir()` must yield a scratch home directory for constructing an `AstridHome`. The `expect(\"temporary home\")` fires when the OS cannot create the temporary directory (permissions or path issues), so the retirement test cannot run.","triggerScenarios":"Calling `tempfile::tempdir()` when creating a directory under `$TMPDIR` fails — read-only /tmp, full filesystem, restricted permissions, or TMPDIR pointing at a non-writable path.","commonSituations":"CI runners with read-only or quota-exhausted temp dirs, sandboxed test environments blocking tmp creation, or a bad `TMPDIR` env var in the developer's shell.","solutions":["Free space / fix permissions on the temp filesystem used by the test runner.","Set `TMPDIR` to a writable location before running the tests.","If sandbox rules block tempfile, allow writes to the system temp dir in the sandbox config.","Retry the test once if the failure was transient (e.g. concurrent cleanup)."],"exampleFix":"// before\nlet directory = tempfile::tempdir().expect(\"temporary home\");\n// after\nlet directory = tempfile::tempdir()\n    .unwrap_or_else(|e| panic!(\"tempdir creation failed (check TMPDIR/permissions): {e}\"));","handlingStrategy":"try-catch","validationCode":"// Rust (test/CI): verify temp dir writability before running\nlet probe = std::env::temp_dir().join(\".write_probe\");\nstd::fs::write(&probe, b\"x\").expect(\"TMPDIR not writable\");\nlet _ = std::fs::remove_file(&probe);","typeGuard":null,"tryCatchPattern":"// Rust: report environment context on tempdir failure\nlet directory = tempfile::tempdir()\n    .unwrap_or_else(|e| panic!(\"tempdir failed (TMPDIR={:?}): {e}\", std::env::var(\"TMPDIR\").ok()));","preventionTips":["Keep CI temp filesystems writable with adequate free space.","Set an explicit TMPDIR in test runners and sandboxes.","Clean up stale temp dirs periodically to avoid inode/space exhaustion.","Avoid running test suites under read-only root filesystems without a writable tmp mount."],"tags":["rust","test-setup","tempdir","filesystem"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}