Repository navigation
fix(pipeline): store the mtime of a file confirmed unchanged by hash - #502
HananKavitzAmat merged 7 commits into
Conversation
…he database from readers Every incremental Rust run handed the database to Rust before Rust's own diff ran: set_rust_pipeline_in_progress(True), close Python's connections, run, reconnect. Every search in that window is refused with DatabaseRustPipelineInProgressError. An MCP server's start-up catch-up does this on every start, and the common start changes nothing -- a fresh worktree seeded from another checkout's index has new mtimes and identical bytes. Measured on a 1174-file index (real `chunkhound mcp`, regex search every 2 s): a start with 0 content changes refused searches for 46 s, and 39 s on the next start. Rust spent ~1.5 s diffing and the rest opening the file and compacting it on a run that wrote nothing. process_directory() now decides on Python's own connection, before any handoff, whether the Rust run has anything to write. The new rust_incremental_precheck reads the same file-state columns as the Rust differ's snapshot and classifies files by its rules (mtime, then xxh3_64 against the stored content_hash, then size), off the event loop: - nothing changed or removed: Rust is not started; HNSW indexes a crashed run left missing are restored through the provider, as Rust's open() would have done; - changes and no removals: Rust gets only the changed files with cleanup off, so its own diff no longer hashes the whole tree while it owns the file; - removals: unchanged, the full list as before. A file is called unchanged only when Rust would call it unchanged; a matching hash means identical bytes. force_reindex is unchanged. An otherwise-empty run no longer gives Rust a chance to compact. Python-side writes are still compacted by the provider's sampled compact_if_needed, and Rust still checks after every run that writes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sh; guard the narrowed run compute_file_hash raises ValueError for a path that stopped being a regular file after stat(); count that file as changed, as Rust does, instead of failing the scan. The docstring now states the unchanged rule exactly. New contract test: editing one file with nothing removed reindexes it and keeps every other file. It guards the cleanup-off requirement of the narrowed Rust run; removing that line deletes the unedited rows and fails the test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A file whose mtime differs from its stored modified_time but whose xxh3_64 equals the stored content_hash was classified unchanged and nothing was written. The stored mtime stayed stale, so every later run hashed the same file again. Measured on a 1200-file index with a fresh checkout of the commit it was built from: every start reported "Diff: 0/1200 changed (1200 unchanged-by-hash)". Both Python classifiers now write the current mtime back: - rust_incremental_precheck (every incremental non-force Rust run): the hash-confirmed files are refreshed on Python's connection, before any handoff to Rust, so the write never races Rust's ownership of the file. Because the precheck runs before every incremental Rust run, the Rust differ then sees the refreshed mtime and takes its mtime fast path too. - indexing_coordinator Phase 2.5 (Python pipeline): the "metadata changed but content didn't" branch is collected and refreshed in one call. New provider method refresh_file_mtimes(entries) (+ async), entries of (stored path, current st_mtime, confirmed content_hash). It sets modified_time only, and only on rows whose content_hash still equals the confirmed hash, so a concurrent writer that stored new content never gets an older mtime. DuckDB does it in one UPDATE ... FROM unnest(...) with to_timestamp(?) like every other files writer; LanceDB with one merge_insert of the matching rows. updated_at and skip_reason are left alone: the content was confirmed, not re-indexed. A failed refresh is logged at warning and never fails the run; its only cost is the next run hashing again, which is today's behaviour. The Diff and Change scan log lines report "N mtimes refreshed". Co-Authored-By: Claude Opus 5.5 <[email protected]>
chunkhound#500 merged upstream as squash 5a01b27, including its review round (rust_mtime_epsilon, plan_rust_run/RustRunPlan, docstrings, two contract tests). This branch still carried chunkhound#500's original commits, so three files conflicted. Each resolution keeps main's code as is and ports this branch's mtime refresh onto it. chunkhound/services/rust_incremental_precheck.py (add/add): Main's version taken whole (RustRunPlan, plan_rust_run, PEP 257 docstrings), with this branch's change re-applied on top: the module docstring paragraph on the mtime refresh; the refresh and mtimes_refreshed fields on RustIncrementalWork; the refresh collection in classify_files; and the refresh_file_mtimes call inside find_rust_incremental_work's worker, on Python's connection, before plan_rust_run returns and so before any handoff to Rust. A failed refresh still logs a warning and never fails the run. The sentence added to the find_rust_incremental_work docstring is re-wrapped into main's reformatted docstring. chunkhound/services/indexing_coordinator.py (content): The import and the Phase 2.6 block take main's side (plan_rust_run via rust_mtime_epsilon); this branch's inline copy of chunkhound#500's original narrowing logic is gone. The skip-branch "Diff: 0/N changed" log line keeps this branch's "N mtimes refreshed" count, read through main's variable as rust_plan.work.mtimes_refreshed instead of rust_work.mtimes_refreshed. The Python-path Phase 2.5 refresh merged without conflict. tests/contracts/test_rust_startup_reader_access.py (add/add): Main's version taken whole (its four tests, including test_precheck_agrees_with_the_rust_differ and test_unchanged_reindex_restores_an_hnsw_index_a_crash_left_missing), plus this branch's _index_then_touch helper and its two tests, unmodified. This branch's one-line imports are covered by main's multi-line import of find_rust_incremental_work; the IndexingCoordinator import is added. The provider files (database_provider, duckdb, lancedb, serial) merged without conflict. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re its refresh test_precheck_agrees_with_the_rust_differ compares the precheck's verdict with the Rust differ's on the same rows. The precheck now stores the new mtime of every file it confirms unchanged by hash, so in the new-mtime-same-bytes case the Rust run that follows took its mtime fast path and never reached its hash path: that case checked only what untouched checks, and a hash disagreement between the two would pass. The test's precheck call now runs with the refresh stubbed out, so Rust's differ sees the rows the precheck classified. Also: - plan_rust_run's docstring says it stores those mtimes. - The Diff log line of a narrowed or full Rust run reports the precheck's refreshed count too, not only the skipped-run line. - ruff format on the new test's signature. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
#500 is merged, so I merged
🤖 Generated with Claude Code |
VakninAriel
left a comment
There was a problem hiding this comment.
Code Review — PR #502
Verdict: 🚫 Request Changes
Summary
Files with changed mtimes but identical content hashes were classified as unchanged without updating stored mtimes, forcing every later scan to hash them again. At the reviewed pinned head, this PR adds batched mtime refreshes to the Rust precheck and Python change scan, layered on #500's precheck work. The goal is to refresh only metadata for hash-confirmed unchanged files, avoiding repeated hashing on later scans.
What's good
- The DuckDB implementation updates only modified_time and checks the confirmed content hash in the same batched SQL statement, leaving unrelated metadata untouched.
- Separate caller-level regression tests cover both the Rust precheck and Python pipeline by touching unchanged files and asserting that the second run no longer hashes them.
Freshness warning: Package freshness checked 2026-11-11T15:38:58.574960+00:00: STALE: included heads/eligibility changed; see overview and freshness audit before posting. This report applies only to its pinned SHA.
| Severity | Count |
|---|---|
| 🔴 Critical | 0 |
| 🟠 High | 0 |
| 🟡 Medium | 1 |
| 🟢 Minor | 0 |
Findings
🟡 [Make LanceDB mtime refresh conditional at write time and metadata-only] (#1 · Medium)
Location: chunkhound/providers/database/lancedb_provider.py — lines 812–821
With a LanceDB-backed direct MCP/HTTP process indexing while a separate CLI index process writes the same database, each process has its own serial executor; CLI startup does not consult the daemon lock unless a database lock exception occurs, and LanceDB connect takes no exclusive writer lock. When that second process updates a file after the refresh query returns but before merge_insert executes, the Python hash comparison sees the old snapshot and the unconditional whole-row merge overwrites the concurrent writer’s newer content_hash, size, indexed_time and skip_reason as well as modified_time. The per-provider serial executor does not serialize other connections. A supposedly metadata-only unchanged-file optimization can therefore roll back indexing metadata and leave the file row inconsistent with current content/chunks. Previously this unchanged-by-hash path performed no write, so the similar preexisting update_file pattern does not make this overwrite preexisting.
Suggested fix:
Enforce the path/hash condition atomically at the LanceDB write and modify only modified_time. Use a conditional partial update or a supported conditional merge with only the intended columns, preserving batched execution where supported. Add an interleaved second-connection regression test that changes content metadata after selection and verifies refresh cannot overwrite it.
Review metadata and audit
Draft review for human approval. Nothing has been posted to GitHub.
Pinned head SHA: 6fcf18d71c3a3226c55dbe13d5a430762217eac5
Package freshness checked 2026-11-11T15:38:58.574960+00:00: STALE: included heads/eligibility changed; see overview and freshness audit before posting. This report applies only to its pinned SHA.
PR: #502
Title: fix(pipeline): store the mtime of a file confirmed unchanged by hash
Author: fstrasz · Branches: fix/precheck-refresh-mtime-upstream → main
Diff merge base: 98be86f
Review scope: Full main...HEAD contribution, merge base 98be86f through pinned head 6fcf18d; all seven changed files and provider/caller contracts. The full diff includes inherited #500 precheck commits 47be431 and a1eff26; final commit 6fcf18d adds mtime refresh. The retained finding is in the final commit, not the inherited precheck.
Eligibility: Bug fix addressing existing behavior; no new feature.
Overall assessment (audit only)
The hash-confirmed mtime optimization is sound on the checked DuckDB path, but LanceDB refresh can replace a concurrent writer’s newer entire file row with stale metadata. One Medium finding retained; speculative batch-size concern discarded.
Strength evidence
- {"strength_index": 0, "path": "chunkhound/providers/database/duckdb_provider.py", "source": "pr-502.pinned.diff", "detail": "_executor_refresh_file_mtimes uses UPDATE ... FROM unnested parameter arrays with files.path = v.path AND files.content_hash = v.h; modified_time is the only SET target. Praise is specific to DuckDB, not the LanceDB merge."}
- {"strength_index": 1, "path": "tests/contracts/test_rust_startup_reader_access.py", "source": "pr-502.pinned.diff", "detail": "test_precheck_refreshes_the_mtime_of_a_hash_confirmed_file checks second.skipped_by_hash == 0; test_python_change_scan_refreshes_the_mtime_of_a_hash_confirmed_file checks hashes_per_run == [3, 0]. Test contents inspected, not a local pass claim."}
Finding #1 evidence
- Final audit verified process-level reachability, not concurrent calls within one executor: run.py:265-271 configures the CLI provider directly and only checks daemon ownership on a DB lock exception; mcp.py:80-95 starts HTTP directly and :117-122 permits direct stdio; LanceDB _create_connection at 252-273 uses ordinary lancedb.connect without cross-process locking. The registry at 546 creates one provider per process, not a global executor across processes.
- Fresh cross-process probe used actual production _executor_update_file in a separate uv subprocess, plus production refresh in the first process and real LanceDB tables. Fresh connection confirmed hash=new,size=99,mtime=999 before refresh; afterward hash=old,size=1,mtime=300. Exit 0. /tmp/chunkhound-final-lance-qupcur8y/probe.py and writer.py. Only the interleaving point is forced; no concurrent use of a single executor was assumed. Native CLI/MCP startup itself was not executed.
- The new provider interface at database_provider.py:207-215 promises only modified_time changes and only while the confirmed hash still matches. LanceDB reads full rows at :805-810, checks their hashes in Python at :814, and unconditionally replaces matched rows at :819-821.
- Provider connection creation uses ordinary lancedb.connect; no cross-connection writer lock protects this sequence. Installed LanceDB 0.25.3 permits the demonstrated second connection update.
- Reconciler reran the inspected production-body probe against fresh temporary real tables. A second connection committed hash=new, size=99, modified_time=999, indexed_time=999, skip_reason=new-state; refresh restored hash=old, size=1, modified_time=300, indexed_time=1, skip_reason=None. Exit 0.
- The same probe passed matching/mismatched-hash and unrelated-column checks in DuckDB 1.4.4 and noninterleaved LanceDB, including 26 rows and quoted paths.
Reviewer keys: sonnet, astra
Verification
- Reconciler: git -C /tmp/chunkhound-pr-reviews-20261111/pr-502 rev-parse HEAD matched manifest; git diff --check 98be86f 6fcf18d and git status --short exited 0 with no output. Both completed reports were read. All assistant-message provider/model/responseModel identities, successful runner statuses, valid provenance, pinned heads and report SHA256 values were checked; two distinct response models confirmed.
- Astra: timeout 120s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 uv run --no-sync mypy chunkhound --cache-dir=/tmp/chunkhound-pr-502-astra-a1-jrlt7ny8/mypy-cache -> exit 1, 993 errors in 89 files (375 checked). Repeated with the six final-commit production files shadowed from HEAD^ in /tmp/chunkhound-pr-502-astra-a1-jrlt7ny8/parent-<basename> and cache mypy-parent-cache -> exit 1, identical line-normalized diagnostics.
- Astra: timeout 90s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 CHUNKHOUND_USE_RUST=0 uv run --no-sync pytest -p no:cacheprovider --basetemp=/tmp/chunkhound-pr-502-astra-a1-jrlt7ny8/pytest-unit --timeout=30 tests/unit/test_skip_unchanged_files.py tests/unit/test_checksum_verify_flow.py -> exit 1, two native-import setup errors, no tests passed.
- Astra: timeout 60s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 uv run --no-sync pytest -p no:cacheprovider --basetemp=/tmp/chunkhound-pr-502-astra-a1-jrlt7ny8/pytest-contract --timeout=30 tests/contracts/test_rust_startup_reader_access.py -> exit 2, one native-import collection error, zero tests collected.
- Astra: timeout 60s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 uv run --no-sync python /tmp/chunkhound-pr-502-astra-a1-jrlt7ny8/provider_probe.py -> final exit 0. Its initial probe query mishandled DuckDB naive timestamps; corrected to production TIMESTAMPTZ cast before final success. Reconciler inspected the script and reran its unchanged method bodies via timeout 60s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 uv run --no-sync python - with only TMP replaced by tempfile.TemporaryDirectory(prefix="reconcile-502-") to avoid reusing the existing table; exit 0 with the same stale-row overwrite.
- Sonnet independently exercised the DuckDB UPDATE with a path index and chunks foreign key: only the matching-hash row updated. Its mypy report contained 993 errors in 89 files; displayed exit 0 belonged to tail, not mypy. Its startup-reader contract selection was blocked at native import.
Limitations
- Native-dependent tests did not execute successfully: the shared environment lacks chunkhound_native.chunkhound_native. No native build, dependency installation, network call, source edit or environment repair was performed. CI is only the captured green snapshot, not a fresh run.
- Supplemental probes extract production definitions and use real external libraries/processes with simplified surrounding state. They are not end-to-end native indexing or MCP verification.
- The concurrency reproduction uses a real second LanceDB connection but not a complete pair of indexing services. The frequency of concurrent writers was not measured.
- CI is a captured snapshot, not a fresh run or a guarantee of current branch status.
- Model identities are verified declarations supplied by the reconciler; the renderer does not inspect raw reports or provenance events.
Disposition of discarded / merged findings
- Final audit keeps the Medium finding after challenging executor reachability. Same-provider concurrent calls serialize and cannot trigger the race, but supported direct MCP/HTTP and CLI index paths can create separate processes/providers against LanceDB without a shared writer lock. The strengthened reproduction commits the second write in another process using the production update method, not a mocked unsupported concurrent provider call. Do not describe ordinary same-executor tasks as vulnerable; whole-row stale snapshots remain vulnerable across processes.
- Merged Sonnet’s low-confidence Minor atomicity concern and Astra’s reproduced Medium finding into one Medium correctness finding. The trigger requires another connection, so High is not justified; actual stale whole-row replacement makes Minor too low.
- Discarded Sonnet’s unbounded IN-list concern: no failing supported repository size, expression limit or measured performance regression was supplied. It was explicitly speculative; refresh failure also degrades to old rehash behavior.
- Do not retain a separate missing-LanceDB-test or documentation-only finding. Regression coverage is part of the suggested correctness fix, not an independently substantiated bug.
Independent reviewer provenance
- sonnet — provider: amat-tfy; requested model: standard-chat-dev/claude-sonnet-5.5; verified response model: aws-aidev-models/us.anthropic.claude-sonnet-5-5. Identity evidence · Raw report
- astra — provider: amat-tfy; requested model: frontier-chat-dev/gpt-6-astra; verified response model: gpt-6-astra. Identity evidence · Raw report
CI snapshot
Captured: 2026-11-11T14:18:23.581921+00:00. Eligibility green: True. Counts: {"SKIPPED": 2, "SUCCESS": 23}
- site-build: SUCCESS (COMPLETED)
- site-build-validation (ubuntu-latest): SUCCESS (COMPLETED)
- site-build-validation (macos-latest): SUCCESS (COMPLETED)
- site-build-validation (windows-latest): SUCCESS (COMPLETED)
- rust-checks (ubuntu-latest): SUCCESS (COMPLETED)
- rust-checks (macos-latest): SUCCESS (COMPLETED)
- rust-checks (windows-latest): SUCCESS (COMPLETED)
- native-wheel-smoke-arm64: SUCCESS (COMPLETED)
- native-dev-macos: SUCCESS (COMPLETED)
- watchman-runtime-validation (ubuntu-latest, 3.14): SUCCESS (COMPLETED)
- watchman-runtime-validation (windows-latest, 3.14): SUCCESS (COMPLETED)
- tests (ubuntu-latest, 3.14, 1): SUCCESS (COMPLETED)
- tests (ubuntu-latest, 3.14, 2): SUCCESS (COMPLETED)
- tests (ubuntu-latest, 3.14, 3): SUCCESS (COMPLETED)
- tests (macos-latest, 3.14, 1): SUCCESS (COMPLETED)
- tests (macos-latest, 3.14, 2): SUCCESS (COMPLETED)
- tests (macos-latest, 3.14, 3): SUCCESS (COMPLETED)
- tests (windows-latest, 3.14, 1): SUCCESS (COMPLETED)
- tests (windows-latest, 3.14, 2): SUCCESS (COMPLETED)
- tests (windows-latest, 3.14, 3): SUCCESS (COMPLETED)
- old-linux-wheel-smoke (Ubuntu 20.04 (glibc 2.31), UBUNTU_20_04_IMAGE, ca-certificates curl, 3.12): SUCCESS (COMPLETED)
- old-linux-wheel-smoke (Ubuntu 22.04 + Python 3.10, UBUNTU_22_04_IMAGE, ca-certificates curl pytho...: SUCCESS (COMPLETED)
- watchman-rollout-gate: SUCCESS (COMPLETED)
- pages-artifact: SKIPPED (COMPLETED)
- deploy: SKIPPED (COMPLETED)
Reviewed by Ariel Vaknin via pi.dev
… row Review of 4027df2 found that the LanceDB refresh read the rows, compared hashes in Python, then merged the whole row back by id. Another process indexing the same database (nothing locks the files table across connections) could rewrite a row in between; the merge then restored the old content_hash, size, indexed_time and skip_reason along with the new modified_time. The write is now a compare-and-swap: one merge keyed on (path, content_hash, indexed_time) as read. Every write of a file's content or skip state stamps a new indexed_time, so the merge matches only a row nobody rewrote since it was read, and stores it with the new modified_time and nothing else changed. Lance 0.39 rejects a per-row value (CASE) in a conditional update and fails a merge whose source has fewer columns than the table, so the merge carries the row as read. One merge per batch, as before; 2,000 of 22,000 rows take 0.14 s either way. The new test has a second connection rewrite one file's content and record another as skipped just before the refresh writes; both keep that writer's values, and the third file gets only its new mtime. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the review. Fixed in 5d2fb27. The LanceDB refresh is now a compare-and-swap: one merge keyed on I tried the two forms you suggested first. Lance 0.39 rejects them:
So the merge carries the whole row as read, and the key makes it conditional. The new test, Serially on Windows: every LanceDB test file, the contracts file and related unit tests, 141 passed; smoke 14 passed. Upstream's CI workflow on our fork at this head is green on every job: https://github.com/fstrasz/chunkhound/actions/runs/43264819556 (after two reruns of macOS test shards that GitHub cancelled on the earlier attempts; one of them could not get a hosted runner). The description is updated to match. 🤖 Generated with Claude Code, reviewed by FStrasz |
Brings in chunkhound#489, chunkhound#474, chunkhound#488, chunkhound#521, chunkhound#510, chunkhound#504 and chunkhound#534. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@VakninAriel, following up on your review. The LanceDB finding was addressed in 5d2fb27 (details):
Does that resolve the finding, or would you still like a narrower write? 🤖 Generated with Claude Code, reviewed by FStrasz |
|
Looks good |
The reported issue is resolved
Brings in chunkhound#526, chunkhound#502 and chunkhound#533. CHANGELOG.md conflicted only because this PR and chunkhound#526 each add a line at the top of [Unreleased] ### Fixed; both entries are kept, this PR's first. No other conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
A file whose mtime differs from its stored
modified_time, but whose xxh3_64 digest equals the storedcontent_hash, is classified as unchanged, and nothing is written. Its stored mtime therefore stays stale, so every later run hashes the same file again.The common case is a fresh git checkout indexed from an existing index: every file has a new mtime and identical bytes. Each start then re-hashes the whole tree, and keeps doing so on every later start. That is the worktree case in #238 and #83: a new worktree seeded from another checkout's index pays this on every start.
Both Python classifiers have the gap:
rust_incremental_precheck.classify_files(from fix(pipeline): an incremental run with nothing to write never takes the database from readers #500), which runs before every incremental, non-force Rust run, counts the file inskipped_by_hashand writes nothing.IndexingCoordinator.process_directoryPhase 2.5, the Python pipeline's change scan, takes its "metadata changed but content didn't" branch and writes nothing.The Rust differ has the same behaviour: it reuses the stored hash for such a file and never writes the new stat back.
Fix
A new provider method,
refresh_file_mtimes(entries), with an async variant. Each entry is(stored path, current st_mtime, confirmed content_hash).modified_timeonly, and only on rows whosecontent_hashstill equals the confirmed hash. A concurrent writer that stored new content therefore never gets an older mtime attached to it.UPDATE files SET modified_time = to_timestamp(v.mtime) FROM (SELECT unnest(?) ...) v WHERE files.path = v.path AND files.content_hash = v.h. That is the sameto_timestamp(?)form every otherfileswriter uses, so both readers (the precheck'sEXTRACT(EPOCH FROM modified_time::TIMESTAMPTZ)and Phase 2.5'sdatetime.timestamp()) read the value back exactly.(path, content_hash, indexed_time)as read. Another process can index the same LanceDB database, because nothing locks the files table across connections. Every write of a file's content or skip state stamps a newindexed_time, so the merge matches only a row nobody has rewritten since it was read. It stores that row with the newmodified_timeand nothing else changed; a row rewritten in between keeps that writer's values. Lance 0.39 rejects a per-row value (CASE) in a conditional update, and fails a merge whose source has fewer columns than the table, so the merge carries the whole row as read.updated_atandskip_reasonare left alone, because the content was confirmed, not re-indexed.Both classifiers call it:
A failed refresh is logged as a warning and never fails the run. Its only cost is that the next run hashes the file again, which is today's behaviour. The
Diff:andChange scanlog lines now reportN mtimes refreshed.Measurement
Windows, a copy of a real 1,200-file DuckDB index, and a fresh checkout of the commit that index was built from (0 content changes). I ran
chunkhound indexthree times in a row on the same copy.The log line goes from
Diff: 0/1200 changed (1200 unchanged-by-hash)on every start toDiff: 0/1200 changed (0 unchanged-by-hash, 0 mtimes refreshed)from the second start on.Tests
Two new tests in
tests/contracts/test_rust_startup_reader_access.py, one per caller:a. It asserts that run 1 confirms N files by hash and run 2 confirms 0.
b. Before the fix it fails with
assert 3 == 0, because run 2 still hashes every file.CHUNKHOUND_USE_RUST=0): the same setup, runningprocess_directorytwice and counting hash computations.a. Run 1 must hash N files. That is a precondition, proving the "metadata changed" branch was reached. Run 2 must hash 0.
b. Before the fix it fails with
assert [3, 3] == [3, 0].Removing either caller's refresh call makes only that caller's test fail.
tests/integration/test_lancedb_refresh_file_mtimes.py. Just before the refresh writes, a second connection rewrites one file's content and records another as skipped. Both rows keep that writer's values, and a third file gets only its new mtime. With the previous LanceDB write it fails: the rewritten content is rolled back.On this branch, run serially on Windows: the contracts file,
test_skip_unchanged_files,test_checksum_verify_flow,test_duckdb_compaction,test_lancedb_checksums,test_lancedb_skip_parity,test_lancedb_provider_helpers,test_rust_pipeline_lancedb_fallbackandtest_chunk_hashing. Result: 167 passed.With the production files reset to #500's head, the two new tests fail as described above, and the two existing tests in the file pass.
After merging
main, serially on Windows:tests/contracts134 passed and 4 skipped (the platform-specific native-install and rpath tests);tests/test_smoke.py14 passed. On the merged code, replacing the precheck's refresh call withrefreshed = 0again fails the precheck test withassert 3 == 0.One test from #500 needed a change after the merge.
test_precheck_agrees_with_the_rust_differcompares the precheck's verdict with the Rust differ's on the same rows. With the refresh, the precheck stores the new mtime first, so in itsnew-mtime-same-bytescase Rust took its mtime fast path and never compared hashes; a hash disagreement between the two would have passed. That test now takes the precheck's verdict with the refresh stubbed out. I checked it with a probe that makes the precheck's hash wrongly agree with a fake stored hash: with the refresh stubbed, the assert fails as it should; with the refresh live, it passed.The tests ran against chunkhound-native 6.1.0, which
mainnow requires (#499). Upstream's CI test matrix (Ubuntu, macOS, Windows) passed on the merged head on my fork before I pushed it here.After the LanceDB fix, serially on Windows: every LanceDB test file, the contracts file,
test_chunk_hashing,test_database_path_consistencyandtest_embedding_model_drift, 141 passed;tests/test_smoke.py14 passed. Upstream's CI workflow on our fork at this head is green on every job: https://github.com/fstrasz/chunkhound/actions/runs/43264819556I also checked the LanceDB method by hand on a scratch table, before the fix:
.limit(len(paths)), because LanceDB returns 10 rows by default.'is handled.modified_timechanges.🤖 Generated with Claude Code, reviewed by FStrasz