Skip to content

fix(index): key files by project, exact-match callers, auto-prune, honor skip patterns - #565

Merged
ajianaz merged 1 commit into
developfrom
fix/index-data-correctness
Oct 7, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/index-data-correctness

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

What

Four index data-correctness fixes: files keyed by (project_id, path) (schema v8), exact-match call graph lookups, automatic pruning of stale files on every index run, and skip patterns honored by every index entry point.

Why

  • files.path was a global PRIMARY KEY with ON CONFLICT(path), so two projects with the same relative path overwrote each other's fingerprint/project_id and reindexed forever.
  • find_callers/find_callees/trace_path used LIKE '%name%': removing run flagged callers of rerun, and _/% acted as wildcards. This feeds index-breaking-change (Major), impact_analysis and trace_path.
  • prune_deleted only ran under --prune and did not touch edges.
  • cora serve and cora index --watch called index_project (no skip patterns), undoing ignore.files / index.skip_files.

How

  • Migration v8 rebuilds files in one transaction with PRIMARY KEY (project_id, path); rows with NULL project_id (pre-v2 orphans) are dropped and recreated on next index. Upsert uses ON CONFLICT(project_id, path).
  • Call graph/edge queries use = ?1. Callees are already normalized to bare names at extraction, so exact match is correct; impact_analysis recursion is covered by a test.
  • index_project_with_id records the walked file set and prunes stored files not in it (deleted, gitignored, newly excluded) via a shared prune_paths that clears symbols, call_graph, edges and files. prune_deleted (--prune) uses the same helper.
  • New index::prepare_index_config / skip_patterns_from_config used by index, --watch and serve. index_project is now test-only so production cannot regress to no-skip.

Testing

  • cargo test --features tree-sitter passes
  • cargo fmt --all -- --check passes
  • cargo clippy --all-targets --features tree-sitter -- -D warnings passes
  • cargo build --release --features tree-sitter passes (not run locally)
  • Manual smoke-test (covered by tests only)

New tests: v7 -> v8 migration (data kept, orphan dropped, idempotent, two projects share a path); two real projects with same path both go up to date; run vs rerun/get_users wildcard and %; impact_analysis/trace_path recursion; auto-prune clears symbols/call_graph/edges/files; --prune clears edges; skip pattern resolver + exclusion.

Not in this PR: unused-imports, per-language call nodes, vector lock.

Related Issues

None.

Checklist

  • Branch name follows convention (fix/)
  • Branch is from develop
  • Commit messages follow Conventional Commits
  • No secrets or credentials committed
  • One logical change per PR (index data correctness)

🤖 Generated with Claude Code

…nor skip patterns

- schema v8: files keyed by (project_id, path) so projects sharing a relative
  path no longer overwrite each other's fingerprint (perpetual reindex).
- graph: find_callers/callees/trace use exact match instead of LIKE '%x%'
  (run no longer matches rerun; _ and % are not wildcards).
- index runs auto-prune stale files; pruning also clears edges.
- serve and watch use index_project_with_skip with resolved config patterns.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
@ajianaz
ajianaz merged commit 147dd75 into develop Oct 7, 2026
14 checks passed
ajianaz added a commit that referenced this pull request Oct 8, 2026
)

Covers security hardening (#563, #572, #573), fixes (#553, #561, #562,
#564, #565, #574-#576), and the ignore-pattern semantic changes from
#577 that can alter which files existing configs exclude.

Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
Co-authored-by: ajianaz <ajianaz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.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.

1 participant