#3416·GitNexus

augment: widely-used symbols return no context because the name fallback only runs when FTS is unavailable

Author: NFSCOFFICECreated Sep 29, 2026Updated Sep 29, 2026

Summary

gitnexus augment (and therefore the Claude Code PreToolUse hook) returns an empty result for the symbols agents search for most: widely-referenced classes/functions. The graph contains them; augment just never looks at the file that defines them.

Version

gitnexus 1.6.12, LadybugDB 0.18.3, macOS arm64, Node 25. Mixed Python + TypeScript monorepo (~116k nodes).

Root cause

In core/augmentation/engine.js, augment():

  1. searchFTSFromLbug(pattern, 10, repoId) ranks files by BM25. The top hits are the files that mention the term most often — callers, tests, migrations, docs.
  2. Step 2 only accepts symbols defined in those top-5 files whose name CONTAINS the pattern.
  3. The definition file of a heavily-used symbol almost never makes the top 5, so symbolMatches is empty.
  4. The name-based fallback is guarded by if (symbolMatches.length === 0 && !ftsAvailable), so with a healthy FTS index it never runs and augment returns ''.

The more widely a symbol is used, the less likely augment finds it.

Repro

For three central symbols in our repo (a Django manager class, a service function, a service class):

pattern top-5 BM25 files symbol hits in top 5 exact-name node exists
SomeManager a view, a mixin, a serializer, a migration, … 0 yes (core/managers.py)
create_order 3 test files, a .ts types file, a TS test 0 yes (services/orders.py)
SomeService tests, 2 unrelated services 0 yes

gitnexus augment -- SomeManager prints only the banner.

Suggested fix

Run the name fallback whenever step 2 found nothing, and rank exact matches first:

diff
-        if (symbolMatches.length === 0 && !ftsAvailable) {
+        if (symbolMatches.length === 0) {
             const fallbackRows = await executeQuery(repoId, `
         MATCH (n)
         WHERE n.name CONTAINS '${patternFirstWord}'
-        RETURN n.id AS id, n.name AS name, labels(n)[0] AS type, n.filePath AS filePath
-        ORDER BY id
+        RETURN n.id AS id, n.name AS name, labels(n)[0] AS type, n.filePath AS filePath,
+          CASE WHEN n.name = '${patternFirstWord}' THEN 0 ELSE 1 END AS exactRank
+        ORDER BY exactRank, id
         LIMIT 5
       `).catch(() => []);

Measured on the repo above: 13–361 ms per fallback query, well inside the hook's 7 s budget, and the defining symbol comes back first in all three cases (previously nothing). A further improvement would be to query exact-name definitions before (or alongside) BM25, since an identifier-shaped pattern is usually a lookup for its definition.

Related

Separate from #2396 (lock contention): this reproduces with no MCP server running and a freshly analyze --force-built index.

Source: abhigyanpatwari/GitNexus