Skip to content

Shared code-intelligence index per repo, injected into every thread #377

Closed

Description

@currentbits

From the code-intelligence research (Sourcegraph CodeScaleBench, 1,281 agent runs): agents overwhelmingly prefer the simplest tool (7,993 keyword searches vs 57 deep-search calls across 602 MCP runs) — powerful tools are NOT invoked organically; the harness must steer. Indexed agents were 30% cheaper and 38% faster, and ~400K LOC is the crossover below which indexing adds overhead.

Maintain one local-first symbol index per repo (CodeGraph pattern: tree-sitter into SQLite, file-watcher incremental), shared across all worktrees instead of each thread re-deriving context via grep. Inject it into every thread with explicit when-to-use-which-tool instructions, gated on repo size. Extends #274 (repo-map) and feeds #249 (blast radius via find-references).

Activity

  1. added
    enhancement
    plan:todo
    plan:doing
    and removed
    plan:todo
    on Aug 17, 2026
  2. currentbits commented on Aug 17, 2026

    @currentbits
    OwnerAuthor

    Contract landed on main (electron/codeindex.js, commit 051535d): JSON index per repo keyed on the project's main checkout, line-based symbol extraction, incremental refresh off the dispatch path.

    Two grok workers forked against it:

    • A — implements the indexer (scan/extract/rank/persist/incremental) + tests.
    • B — services.codeIndexNoteFor + runner dispatch wiring + tests: the injected code map with explicit when-to-use-which-tool steering.

    Deliberate deviations from the issue text, to be revisited if they bite:

    • JSON, not SQLite — the index is read whole to build one note, so there is no query to optimise yet. Move to node:sqlite when find-references (Conflict forecast: predict merge conflicts between parallel worktrees before they happen #249 blast radius) actually needs per-symbol queries.
    • Line-based extractor, not tree-sitter — the app ships zero native deps today; tree-sitter bindings would be a packaging/signing cost for a map that only needs top-level definition names.
    • Debounced refresh from the dispatch path, not a file watcher — staleness ceiling is one refresh interval.
    • No new MCP tool — the research finding (7,993 keyword searches vs 57 deep-search calls) says a tool nobody invokes is worthless; the steering lives in the injected note.
    • Repo-size gate is the note's char cap, not an LOC threshold: a 400K-LOC repo yields the same ~3.5KB note as a small one, and repos under 20 indexed files get no note at all.
  3. currentbits commented on Aug 17, 2026

    @currentbits
    OwnerAuthor

    Both workers landed and are merged into coder/shared-code-intelligence-index-per-repo--73cf1e.

    Measured on this repo (398 indexed source files, 1,680 symbols, 134K LOC): full build 170ms, incremental refresh 40ms, readIndex on the dispatch path 1ms, index file 69KB, injected note 3.4KB.

    Tests: 1076 pass / 1 fail — the fail is the pre-existing web-integration reconnect flake that is baseline on main.

    Two defects found in review and fixed on top:

    • churn rank was systematically wrong — git log --format=%h --name-only puts a hash and a blank line before each file list, and the parser's off-by-one read the first file of every commit as a hash, so alphabetically-first paths never scored. Empty --format= makes every non-blank line a path. Regression test added.
    • symbol-less files ate the note budget — test fixtures and config files were listed with no symbols after them, which tells an agent nothing.

    Still open, deliberately: the map is orientation-only (no find-references query surface), it maps the main checkout so branch-new files are missing, and refresh is debounced off the dispatch path rather than watched.

  4. added
    plan:done
    and removed
    plan:doing
    on Sep 8, 2026
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

    enhancementplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions