{"record":{"id":"b83b9003983f5800","repo":"astrid-runtime/astrid","slug":"stable-private-file-identity-is-unavailable","errorCode":null,"errorMessage":"stable private file identity is unavailable","messagePattern":"stable private file identity is unavailable","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/astrid-storage/src/engine/durable/representations/contiguous/namespace.rs","lineNumber":193,"sourceCode":"    use windows_sys::Win32::Storage::FileSystem::{\n        BY_HANDLE_FILE_INFORMATION, GetFileInformationByHandle,\n    };\n\n    let mut info = BY_HANDLE_FILE_INFORMATION::default();\n    // SAFETY: `file` owns a live Windows handle and `info` is writable.\n    #[allow(unsafe_code)]\n    if unsafe { GetFileInformationByHandle(file.as_raw_handle().cast(), &raw mut info) } == 0 {\n        return Err(io::Error::last_os_error());\n    }\n    Ok(FileIdentity {\n        volume: VolumeId(u64::from(info.dwVolumeSerialNumber)),\n        file: FileId((u64::from(info.nFileIndexHigh) << 32) | u64::from(info.nFileIndexLow)),\n    })\n}\n\n#[cfg(not(any(unix, windows)))]\nfn opened_file_identity(_file: &File) -> io::Result<FileIdentity> {\n    Err(io::Error::new(\n        io::ErrorKind::Unsupported,\n        \"stable private file identity is unavailable\",\n    ))\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn directory_sync_portability_contract_accepts_a_directory_capability() {\n        let temporary = tempfile::tempdir().unwrap();\n        let directory =\n            Dir::open_ambient_dir(temporary.path(), cap_std::ambient_authority()).unwrap();\n\n        sync_directory(&directory).unwrap();\n    }\n}","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage/src/engine/durable/representations/contiguous/namespace.rs#L175-L211","documentation":"opened_file_identity builds a FileIdentity from the OS file index; on targets that are neither Unix nor Windows there is no stable identity API, so it returns ErrorKind::Unsupported with this message. The capability requires comparing file identities, which the platform cannot provide.","triggerScenarios":"Any representation open path that compares opened file identities (open_file / open_component flow) compiled for a non-unix/non-windows target such as wasm32-unknown-unknown or a custom RTOS.","commonSituations":"Running the durable representation engine in wasm/browser or embedded sandboxes; cross-compilation for exotic targets during testing.","solutions":["Run on a supported platform (Unix or Windows target triple)","Implement opened_file_identity for your target OS and gate it with the appropriate cfg","Fall back to a storage engine that does not require identity checks on this platform","Skip identity verification only if you fully control the threat model — not recommended"],"exampleFix":"// before\n#[cfg(not(any(unix, windows)))]\nfn opened_file_identity(_file: &File) -> io::Result<FileIdentity> { Err(...) }\n// after\n#[cfg(target_family = \"wasm\")]\nfn opened_file_identity(_file: &File) -> io::Result<FileIdentity> {\n    Ok(FileIdentity { device: 0, index: wasm_fd_index(_file) })\n}","handlingStrategy":"fallback","validationCode":"if !cfg!(any(unix, windows)) {\n    // select backend that does not require file-identity checks\n    use_memory_backend();\n}","typeGuard":"const OPENED_IDENTITY_SUPPORTED: bool = cfg!(any(unix, windows));","tryCatchPattern":"match open_file_result {\n    Err(e) if e.kind() == io::ErrorKind::Unsupported => use_non_identity_backend(),\n    r => r,\n}","preventionTips":["Compile the representation engine only for unix/windows targets","Verify target support in CI for all deployment triples","Pick identity-free backends for wasm/embedded targets up front"],"tags":["platform","unsupported","io"],"backgroundTag":"unsupported-platform","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"}