Skip to content

fix(test): isolate tests from real data dir and bound vector index lock wait - #589

Merged
ajianaz merged 1 commit into
developfrom
fix/test-isolation-vector-lock
Oct 8, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/test-isolation-vector-lock

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • Unit tests no longer touch the developer's real ~/.codecora: without an explicit CODECORA_HOME, data_dir::codecora_home() (under cfg(test) only) resolves to one process-wide scratch tempdir. The resolution rule is split into a pure resolve_home fn.
  • vector::acquire_file_lock now polls try_lock_exclusive for up to 15s, then fails with timed out ... waiting for the vector index lock at <path>; another cora process may be holding it instead of blocking forever.
  • data_dir tests no longer mutate CODECORA_HOME (removed the env-mutating tests and their racy ENV_LOCK).

Why

Index/watch tests reach embed_project -> load_or_create_usearch -> flock on the real global vector index, so any running cora process (e.g. a long cora scan) hung them forever, and they polluted the real data dir. A per-process scratch dir needs no env mutation (safe under parallel tests) and matches the process-global VECTOR_CACHE. Existing callers already degrade on the new error: index_project_with_id treats embedding failure as non-fatal and ensure_vector_cache falls back to FTS-only search. User-visible change: a contended index lock now errors after 15s rather than hanging.

Testing

  • New index::vector::tests::locked_index_errors_instead_of_blocking (holds the lock, asserts a timeout error naming the path, then re-acquires after release).
  • New data_dir tests assert resolved dirs are under the scratch home, never the real one.
  • cargo test --features tree-sitter --bin cora -- index:: commands::watch passes while a stray cora scan holds the real lock; full cargo test --features tree-sitter passes; fmt and clippy -D warnings clean.

Closes #587

🤖 Generated with Claude Code

…dex lock wait (#587)

Unit tests now resolve the CodeCora data root to a process-wide scratch
dir unless CODECORA_HOME is set, so index/watch tests no longer open the
developer's real global vector index or hang behind another cora process.
acquire_file_lock polls try_lock for 15s then errors naming the lock path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
@ajianaz
ajianaz merged commit f69fc28 into develop Oct 8, 2026
16 of 17 checks passed
ajianaz added a commit that referenced this pull request Oct 8, 2026
#580) (#590)

Co-authored-by: ajianaz <ajianaz@users.noreply.github.com>
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.

test: index/watch tests use the real global vector index and block on its file lock

1 participant