Skip to content

test(ck-engine): guard empty-corpus lexical rebuild - #185

Open
ak2k wants to merge 1 commit into
BeaconBay:mainfrom
ak2k:test/lexical-empty-stub-rebuild
Open

test(ck-engine): guard empty-corpus lexical rebuild#185
ak2k wants to merge 1 commit into
BeaconBay:mainfrom
ak2k:test/lexical-empty-stub-rebuild

Conversation

@ak2k

@ak2k ak2k commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Test-only, no production change.

A --lex search over a directory with no indexable files builds an empty tantivy index. When real files appear later the corpus fingerprint changes, so the next search must rebuild rather than trust the empty stub — otherwise that directory reports no matches indefinitely. The rebuild logic is already in lexical_search; this pins the empty-corpus corner of it, which is the case I actually hit.

Verified non-vacuous: dropping the fingerprint comparison from the freshness check (let is_fresh = tantivy_index_path.exists();) fails the test with empty tantivy stub was trusted; expected a rebuild to find the new file.

Uses a unique TempDir, which keys its own index, so it needs no serial_test or env manipulation to stay isolated. cargo test -p ck-engine (41), clippy, fmt clean.

Add a regression test covering the transition from an empty corpus (which
builds an empty tantivy index) to a populated one: the corpus fingerprint
changes, so the next lexical search must rebuild and surface the new files
rather than trusting the empty index.

The test uses a plain #[tokio::test] with a TempDir-scoped .ck, matching the
other lexical-search tests: the unique temp path keys its own index (in-tree,
or a path-hashed subdir when CK_INDEX_DIR relocates it), so it stays isolated
without serial_test or removing the CK_INDEX_DIR env var.
@ak2k

ak2k commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

CI is red here, but the two failures are in ck-cli/tests/integration_tests.rstest_add_single_file_to_index ("Failed to create initial index") and test_add_file_with_relative_path — and this PR only adds a test to ck-engine/src/lib.rs. No production code, nothing in ck-cli.

What I checked locally, on Linux and macOS, using CI's exact invocation (cargo test --manifest-path ck-cli/Cargo.toml --all-features):

  • pristine main (f4caaf5): both pass
  • this branch: both pass

So I can't reproduce it, and I don't think it's caused by this change. Both tests are #[serial] and shell out to the ck binary to build an index, which is the usual shape for load-dependent CI flakiness — but that's a guess, not something I've confirmed.

I don't have rerun rights on this repo. If you re-run the job and it's still red, tell me and I'll dig in properly rather than assume it's environmental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant