{"record":{"id":"552ebcf30de0d03c","repo":"Hmbown/CodeWhale","slug":"runtime-event-file-changed","errorCode":null,"errorMessage":"Runtime event file changed: {}","messagePattern":"Runtime event file changed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":12863,"sourceCode":"        u64::from(info.dwVolumeSerialNumber),\n        (u64::from(info.nFileIndexHigh) << 32) | u64::from(info.nFileIndexLow),\n    ))\n}\n\n#[cfg(all(not(unix), not(windows)))]\nfn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {\n    anyhow::ensure!(file.metadata()?.is_file(), \"must be a regular file\");\n    Ok((0, 0))\n}\n\nfn validate_same_runtime_store_file_handles(\n    first: &File,\n    second: &File,\n    path: &Path,\n) -> Result<()> {\n    let first = runtime_store_file_identity(first)?;\n    let second = runtime_store_file_identity(second)?;\n    anyhow::ensure!(\n        first == second,\n        \"Runtime event file changed: {}\",\n        path.display()\n    );\n    Ok(())\n}\n\nfn wait_for_event_lock(started: Instant, timeout: Duration) -> Result<()> {\n    let elapsed = started.elapsed();\n    if elapsed >= timeout {\n        return Err(anyhow!(RuntimeEventLockTimeout(timeout)));\n    }\n    std::thread::sleep(EVENT_TRANSACTION_LOCK_POLL.min(timeout - elapsed));\n    Ok(())\n}\n\nfn rollback_failed_event_append_handle(rollback_file: &File, original_len: u64) -> Result<()> {\n    rollback_file","sourceCodeStart":12845,"sourceCodeEnd":12881,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/runtime_threads.rs#L12845-L12881","documentation":"The runtime verifies that a runtime event file has not been swapped underneath it by comparing stable file identities (device/inode via runtime_store_file_identity) between two file handles. If the identities differ, `ensure!` throws this error naming the path. It protects against reading a rewritten/replaced file mid-operation, which would yield inconsistent event data.","triggerScenarios":"Comparing first/second file handles for a runtime event store path where the file was replaced (deleted and recreated, renamed over, or recreated after rotation) between the two opens.","commonSituations":"Another process or an external log rotation replaced the runtime event file; a cleanup script truncated/recreated the store; two runtime instances writing the same path; filesystem copy that changed the inode.","solutions":["Reopen the event file and retry the read against the current file","Ensure no other process is rotating or replacing the runtime event store while the app runs","Run only one Codewhale runtime instance against the same data directory"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// detect a replaced event file before reading\nlet id_before = file_identity(path)?;\n// ... use file ...\nif file_identity(path)? != id_before { reopen_and_retry(path)?; }","typeGuard":null,"tryCatchPattern":"match read_runtime_events(path).await {\n    Err(e) if e.to_string().starts_with(\"Runtime event file changed\") => {\n        let f = reopen(path)?; // re-read against the current file\n        read_runtime_events_from(f).await\n    }\n    other => other,\n}","preventionTips":["Run only one runtime instance per data directory","Do not rotate/truncate runtime event files while the app is running","Exclude the runtime store directory from external cleanup jobs"],"tags":["file","integrity","events","concurrency"],"backgroundTag":"checksum-mismatch","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}