indexer: Windows live Modify dedup ignores ctime, missing same-length overwrites until reconcile #16

Closed
opened 2026-07-07 13:19:31 +02:00 by buildagent · 1 comment
Member

Severity: Medium · Category: Correctness (staleness window)

The Windows Modify(Any) fast-path is_metadata_only_modify (crates/daemon/src/watcher.rs:766-778) compares only (mtime_ns, size) and drops the event when they match — but classify_stat (crates/indexer/src/reconcile.rs:46-51) additionally requires ctime_ns equality. A content overwrite that preserves mtime+size (e.g. cp -p, a restore, an in-place same-length rewrite) bumps NTFS ChangeTime but is skipped live.

Not permanent — the 30-min periodic reconcile checks ctime and heals it — but it is a real staleness window that the tier-1 rule was meant to close.

Fix

  • Read ChangeTime here too (same FILE_BASIC_INFO path meta_ctime_ns_for_path already uses) and compare it; or accept-and-document that live Windows dedup is mtime+size only and correctness rests on the periodic reconcile.

Filed from a deep multi-agent code review of the workspace (v0.5.7). Severity/category per the review; file:line refs were accurate at review time — verify against current master.

**Severity:** Medium · **Category:** Correctness (staleness window) The Windows `Modify(Any)` fast-path `is_metadata_only_modify` (`crates/daemon/src/watcher.rs:766-778`) compares only `(mtime_ns, size)` and drops the event when they match — but `classify_stat` (`crates/indexer/src/reconcile.rs:46-51`) additionally requires `ctime_ns` equality. A content overwrite that preserves mtime+size (e.g. `cp -p`, a restore, an in-place same-length rewrite) bumps NTFS ChangeTime but is **skipped live**. Not permanent — the 30-min periodic reconcile checks ctime and heals it — but it is a real staleness window that the tier-1 rule was meant to close. ### Fix - Read ChangeTime here too (same `FILE_BASIC_INFO` path `meta_ctime_ns_for_path` already uses) and compare it; **or** accept-and-document that live Windows dedup is mtime+size only and correctness rests on the periodic reconcile. --- _Filed from a deep multi-agent code review of the workspace (v0.5.7). Severity/category per the review; file:line refs were accurate at review time — verify against current `master`._
Author
Member

Closing as WONTFIX (accept-and-document) — documented in 49953d5.

Reassessed on current master: the divergence is real and unchanged — is_metadata_only_modify (watcher.rs) compares only (mtime, size) while reconcile::classify_stat additionally requires ctime_ns, so a same-length content overwrite preserving mtime+size is skipped live. But the only fix is to read ctime here via meta_ctime_ns_for_path, which is exactly the CreateFileW + GetFileInformationByHandleEx + CloseHandle round-trip this fast-path was created to eliminate (it was the dominant Windows idle-CPU sink). Reintroducing it to close a narrow, self-healing window is a bad trade.

The window is bounded and healed by the periodic reconcile (default 30 min), which does compare ctime. Added an explicit doc note at the comparison site recording this as a deliberate, accepted tradeoff (Windows-only; correctness rests on the reconcile safety-net). No behavior change, so no test.

Closing as **WONTFIX (accept-and-document)** — documented in `49953d5`. Reassessed on current master: the divergence is real and unchanged — `is_metadata_only_modify` (`watcher.rs`) compares only `(mtime, size)` while `reconcile::classify_stat` additionally requires `ctime_ns`, so a same-length content overwrite preserving mtime+size is skipped live. But the only fix is to read ctime here via `meta_ctime_ns_for_path`, which is exactly the `CreateFileW` + `GetFileInformationByHandleEx` + `CloseHandle` round-trip this fast-path was created to eliminate (it was the dominant Windows idle-CPU sink). Reintroducing it to close a narrow, self-healing window is a bad trade. The window is bounded and healed by the periodic reconcile (default 30 min), which does compare ctime. Added an explicit doc note at the comparison site recording this as a deliberate, accepted tradeoff (Windows-only; correctness rests on the reconcile safety-net). No behavior change, so no test.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
h-dv/code-index#16
No description provided.