{"record":{"id":"37ddaff20104d770","repo":"astrid-runtime/astrid","slug":"quarantine-to-error","errorCode":null,"errorMessage":"quarantine {} to {}: {error}","messagePattern":"quarantine (.+?) to (.+?): (.+?)","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/legacy_migration_barrier/legacy_audit.rs","lineNumber":55,"sourceCode":"    }\n    if !path_exists(&path)? {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\n                \"legacy audit source for {alias} was inventoried but is missing: {}\",\n                path.display()\n            ),\n        ));\n    }\n    quarantine_audit_tree(home, alias, &path)\n}\n\nfn quarantine_audit_tree(home: &AstridHome, alias: &PrincipalId, source: &Path) -> io::Result<()> {\n    let quarantine_root = home.migrations_dir().join(QUARANTINE_DIR);\n    astrid_core::platform_fs::ensure_private_directory(&quarantine_root)?;\n    let destination = unique_destination(&quarantine_root, alias.as_str())?;\n    fs::rename(source, &destination).map_err(|error| {\n        io::Error::new(\n            error.kind(),\n            format!(\n                \"quarantine {} to {}: {error}\",\n                source.display(),\n                destination.display()\n            ),\n        )\n    })?;\n    super::sync_parent(source)?;\n    super::sync_parent(&destination)?;\n    tracing::warn!(\n        principal = %alias,\n        destination = %destination.display(),\n        \"quarantined non-default layout-1 audit tree; bytes preserved\"\n    );\n    Ok(())\n}\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/legacy_migration_barrier/legacy_audit.rs#L37-L73","documentation":"When a legacy audit source cannot be migrated in place, quarantine_audit_tree moves the whole tree into the migrations quarantine directory via fs::rename. If the rename fails for any reason, the original OS error is wrapped with this contextual message showing source and destination.","triggerScenarios":"handle_non_default_audit_source calls quarantine_audit_tree; fs::rename(source, destination) fails — e.g. source and destination on different filesystems (EXDEV), destination collision beyond unique_destination's attempts, or permission problems.","commonSituations":"The legacy audit tree lives on a different mount than the astrid home (rename across devices); read-only filesystem; the migrations directory is not writable; the source was concurrently removed.","solutions":["Ensure the legacy source and the astrid migrations directory are on the same filesystem, or copy-then-delete instead of rename","Fix permissions on the quarantine root (ensure_private_directory should have created it; check ownership)","Check the wrapped underlying error kind in the message and address it directly (e.g. free disk space, remount rw)","Retry after stopping whatever process holds/removes the source tree"],"exampleFix":"// before: rename fails across filesystems\nfs::rename(source, &destination).map_err(...)?;\n// after: fall back to copy+remove on cross-device errors\nif let Err(error) = fs::rename(source, &destination) {\n    if error.kind() == io::ErrorKind::CrossesDevices {\n        copy_tree(source, &destination)?;\n        fs::remove_dir_all(source)?;\n    } else { return Err(wrap(error, source, &destination)); }\n}","handlingStrategy":"try-catch","validationCode":"let quarantine_root = home.migrations_dir().join(QUARANTINE_DIR);\nastrid_core::platform_fs::ensure_private_directory(&quarantine_root)?;\n// same-device check to avoid EXDEV\ndev_of(source)? == dev_of(&quarantine_root)?","typeGuard":null,"tryCatchPattern":"match quarantine_audit_tree(&home, &alias, &source) {\n    Err(e) if e.kind() == std::io::ErrorKind::CrossesDevices => copy_then_remove(&source)?,\n    Err(e) if e.kind() == std::io::ErrorKind::PermissionDenied => fix_perms_and_retry()? ,\n    other => other,\n}","preventionTips":["Keep the legacy audit tree and astrid home on the same filesystem","Ensure the migrations directory is writable by the migration user","Handle EXDEV by copying then removing when rename cannot work"],"tags":["filesystem","quarantine","rename","migration"],"backgroundTag":"file-write-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"}