Skip to content

Phase 3: Brain search enrichment for review & scan — inject semantic context into LLM prompt #458

Closed

Description

@ajianaz

Goal

Inject brain search results (FTS5 + vector + graph RRF fusion) as context enrichment into both cora review and cora scan LLM prompts.

Context

  • cora scan currently has ZERO context enrichment — only sends raw file content to LLM
  • cora review has context chain (regex-based) but no brain/semantic context
  • brain_search() in src/index/brain.rs provides hybrid search (FTS5 + usearch vector + graph BFS → RRF fusion) — only used in CLI and MCP, never in review/scan

Scope

  1. Add enrich_with_brain_search() in new file src/engine/brain_enrichment.rs
  2. Extract key symbols from diff (review) or file batch (scan)
  3. Query brain_search for each symbol, deduplicate, format under token budget
  4. Inject as "## Code Intelligence (brain search)" section in LLM prompt
  5. Config: brain_search.enabled, max_results_per_symbol, max_tokens

Files

  • NEW: src/engine/brain_enrichment.rs
  • src/engine/review.rs — inject brain context before LLM call
  • src/commands/scan.rs — inject brain context before LLM call

Benefits

  • Review gets semantic context (not just syntactic)
  • Scan gets context it never had before
  • LLM can assess risk more accurately with related code visibility

Dependencies

Effort: 4-5 days

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions