Skip to content

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

Description

@ajianaz

Problem. 'Which project am I in?' is answered differently by different callers. main.rs repeats the resolve-root → open DB → ensure_project sequence in ~9 arms (700, 851, 924, 1005, 1054, 1113, 1163, 1224, 1630) using resolve_project_root; engine/review.rs (177-190, 242, 297, 784, 927) and engine/index_scanner.rs (118/212/295/482) use raw current_dir(); mcp/tools.rs:440, serve, watch, routes, query and engine/db_writer.rs each have their own open path with different PRAGMAs (6 vs 2). From a subdirectory the review-time scanners can resolve a different/empty project_id than the one indexed; #565 (per-project file keying) made this load-bearing, and project_root_mismatch_hint is a band-aid. IndexBridge is only used by the resolver, so it does not pass the deletion test.

Direction. One module owns resolve root + open DB + project id (tolerant for review, strict for CLI) and the PRAGMAs. All entry points go through it.

Benefit. Locality for the root-resolution bug class; ~10 main.rs arms shrink; scanners (unused-imports, dead-code) become testable against an in-memory index without touching $HOME. Unblocks the other candidates.

From the 2026-10 architecture review (deepening candidates, develop @ 147dd75).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions