{"record":{"id":"1e76197d9a14abff","repo":"Hmbown/CodeWhale","slug":"not-one-regular-file","errorCode":null,"errorMessage":"not one regular file","messagePattern":"not one regular file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":8958,"sourceCode":"    {\n        use std::os::windows::fs::OpenOptionsExt as _;\n        use windows_sys::Win32::Storage::FileSystem::FILE_FLAG_OPEN_REPARSE_POINT;\n        options.custom_flags(FILE_FLAG_OPEN_REPARSE_POINT);\n    }\n    let file = options\n        .open(path)\n        .with_context(|| format!(\"Failed to open {purpose} {}\", path.display()))?;\n    runtime_store_file_identity(&file)\n        .with_context(|| format!(\"Invalid {purpose} {}\", path.display()))?;\n    Ok(file)\n}\n\n#[cfg(unix)]\nfn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {\n    use std::os::unix::fs::MetadataExt as _;\n\n    let metadata = file.metadata()?;\n    anyhow::ensure!(\n        metadata.is_file() && metadata.nlink() == 1,\n        \"not one regular file\"\n    );\n    Ok((metadata.dev(), metadata.ino()))\n}\n\n#[cfg(windows)]\nfn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {\n    use std::os::windows::fs::MetadataExt as _;\n    use std::os::windows::io::AsRawHandle as _;\n    use windows_sys::Win32::Storage::FileSystem::{\n        BY_HANDLE_FILE_INFORMATION, FILE_ATTRIBUTE_REPARSE_POINT, GetFileInformationByHandle,\n    };\n\n    let metadata = file.metadata()?;\n    let safe = metadata.is_file() && metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT == 0;\n    anyhow::ensure!(safe, \"not a regular non-reparse file\");\n    let mut info = BY_HANDLE_FILE_INFORMATION::default();","sourceCodeStart":8940,"sourceCodeEnd":8976,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L8940-L8976","documentation":"Unix guard in runtime_store_file_identity: metadata showed the opened Runtime store/event file is either not a regular file or has nlink != 1. It fires when the path is a symlink, device, socket, directory, or a hard-linked file — conditions under which dev/ino identity checking is unsafe — and protects the store against TOCTOU swaps via links.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:8958 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the store/event path with ls -l and stat: remove any symlink or hard link pointing at it","Restore the store file as a single regular inode (copy contents to a fresh file and replace)","Ensure no backup tool or wrapper is hard-linking the runtime store"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}