Skip to content

Phase 1: Wire symbol index to context chain — replace regex-based resolution with SQLite queries #456

Description

@ajianaz

Goal

Replace regex-based symbol resolution in build_context_chain() with SQLite symbol index lookups for higher accuracy and speed.

Context

  • Current: engine/context/resolver.rs uses regex to extract imports, fn calls, type refs from diff, then resolves via file-system scan (std::fs::read_dir + grep-style matching)
  • cora index builds a complete symbol index in SQLite (tree-sitter parsed) that is never queried by review/scan pipeline
  • This means cora index data goes unused — symbol resolution is re-done ad-hoc every review

Scope

  1. Add resolve_via_index() in engine/context/resolver.rs — query SQLite symbols table instead of regex+fs
  2. Add IndexBridge abstraction (engine/index_bridge.rs) — open cora.db if available, graceful degradation if not
  3. Add prefer_index: bool to ContextConfig (default: true if index available)
  4. Fallback to regex-based resolution when index unavailable

Files

  • src/engine/context/resolver.rs — add index-based resolution
  • src/engine/context/mod.rs — IndexBridge integration
  • src/engine/context/types.rs — prefer_index config
  • NEW: src/engine/index_bridge.rs — index availability abstraction

Benefits

  • More accurate resolution (tree-sitter parsed vs regex)
  • Faster for large repos (SQLite query < file walk)
  • No more 400-file scan limit for blast radius

Effort: 3-4 days

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions