Skip to content

refactor(index): single seam for resolving project root and opening the index - #574

Merged
ajianaz merged 1 commit into
developfrom
refactor/project-index-seam
Oct 7, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/project-index-seam

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

What

Evolves IndexBridge into the single seam for "resolve project root + open the index + ensure project id", and migrates all call sites to it.

Why

Closes #566. Callers answered "which project am I in?" differently: review-time scanners used raw current_dir() while cora index used resolve_project_root, so a review from a subdirectory or workspace member could resolve a different/empty project_id than the one indexed. PRAGMAs also differed per open path (6 vs 2).

How

  • IndexBridge always normalises its start path with resolve_project_root. Modes: tolerant open (review; never creates the DB, never fails), strict open_strict (CLI/MCP; NoIndexError when absent), open_or_create (index/serve/watch/dead-code/routes/query), from_connection (tests).
  • index::open_index_at + apply_pragmas are the only place PRAGMAs/migrations are applied; open_global_index and db_writer::open_db delegate to it. resolve_project_id removed.
  • scan_unused_imports, scan_dead_code_in_review, scan_breaking_changes, scan_project_index, build_brain_context, build_scan_brain_context take &IndexBridge (the old scan_breaking_changes_with pattern, generalised) instead of opening their own connection.
  • main.rs arms, mcp open_index_db, serve/watch/routes/query, review.rs and scan.rs go through the bridge.
  • Behavior notes: the review path no longer creates an empty cora.db when none exists; the MCP/CLI "no index" message is unchanged for users.

Not included: index-session/config (#567), affected-tests (#568). Read-only db_writer::open_db_for_read (no PRAGMAs/migrations by design) and the context resolver's own IndexBridge::open(project_root) are left as is.

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 not run locally (disk)
  • New tests: tolerant open with absent index (no DB created), strict open errors with NoIndexError, subdirectory/workspace-member resolves same project_id as root, scanner run from a subdirectory finds callers indexed from root, PRAGMAs applied by the shared opener.

Closes #566

🤖 Generated with Claude Code

…he index

Evolve IndexBridge into the one module that resolves the project root
(via resolve_project_root), opens the index with shared PRAGMAs, and
ensures the project id. Tolerant mode for review, strict mode for CLI/MCP.
Index scanners and brain context take the bridge, so a review run from a
subdirectory resolves the same project_id as indexing from the root.

Closes #566

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
@ajianaz
ajianaz merged commit 66eb8bf 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.

refactor(index): single seam for resolving the project root and opening the index

1 participant