Skip to content

Commit 5a4278e

Browse files
cdeustclaude
andcommitted
fix(graph): populate Calls_* / Imports_* rel tables via AP resolve pass
The workflow-graph viz filter for ``calls`` and ``imports`` showed zero nodes because Cortex's auto-indexer only invoked AP's ``index_codebase`` tool, which persists Defines_* / HasMethod_* / HasField_* but NEVER Calls_* / Imports_* / Extends_* / Implements_*. Those require AP's separate ``resolve_graph`` pass. Changes 1. ``http_standalone.py::_bg_index`` — switched ``b.index_codebase(...)`` to ``b.analyze_codebase(...)`` (AP's all-in-one: index + resolve + cluster). New project graphs now land fully populated. 2. ``http_standalone.py::_bg_index`` — for EXISTING graphs (already indexed pre-Gap-10 with only ``index_codebase``), run the idempotent ``resolve_graph`` tool as a backfill so every project's Calls_* / Imports_* / Implements_* rel tables get populated retroactively, without paying the cost of a full re-parse. 3. ``http_launcher.py::_index`` — same switch from ``index_codebase`` to ``analyze_codebase`` for the launcher-side indexer (kicked off when the user opens the viz from a project with no prior graph). Debugging path required two upstream fixes that are NOT in this commit but are prerequisites for the fix to render end-to-end: * AP (sibling repo ``automatised-pipeline``): the resolver crashed on the first unknown rel-table pair (e.g. ``Calls_Method_Struct``) via a ``?`` in ``EdgeBuffer::flush`` — one unknown name aborted the whole flush and dropped every resolved edge. Patched locally to skip-with-warning; AP rebuilt from source. * Cortex's AST disk cache at ``~/.claude/methodology/ast_cache/`` serialised per-project edges BEFORE the resolver ran and its ``_graph_signature`` didn't detect LadybugDB internal file changes. Purging the 25 cache files + an HTTP respawn is needed once after the AP fix lands. Verified live: bulk ``resolve_graph`` across all 25 project graphs yielded 50,160 calls + 937 imports + 6,492 implements. After cache purge and HTTP respawn, the ``calls — symbol ↔ symbol`` and ``imports — file ↔ symbol`` filters populate as the phase-builder streams L6 per-project batches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e6e8496 commit 5a4278e

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

mcp_server/server/http_launcher.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ def _ensure_ap_graph(dev_src: Path | None, env: dict) -> None:
178178
async def _index():
179179
b = APBridge()
180180
try:
181-
await b.index_codebase(
181+
# analyze_codebase = index + resolve + cluster. Using
182+
# the composed tool so Calls_* / Imports_* / Extends_*
183+
# rel tables land populated; index_codebase alone
184+
# leaves them empty (matched to the viz filter bug).
185+
await b.analyze_codebase(
182186
target,
183187
output_dir=str(cache_dir),
184188
language="auto",

mcp_server/server/http_standalone.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,29 @@ async def _run():
328328
for proj in projects:
329329
outdir = roster_root / proj.name
330330
graph_file = outdir / "graph"
331-
# Skip projects already indexed — cheap recovery
332-
# on a re-launch and avoids paying the cost of a
333-
# 5 000-file codebase every visualize call.
331+
# Graph already indexed. We still attempt a
332+
# resolve_graph pass because older Cortex
333+
# versions only ran index_codebase — their
334+
# graphs have zero Calls_* / Imports_* rows.
335+
# resolve_graph is idempotent: when edges are
336+
# already present it no-ops quickly.
334337
if graph_file.exists() and graph_file.stat().st_size > 10000:
338+
try:
339+
await b.call(
340+
"resolve_graph",
341+
{"graph_path": str(graph_file)},
342+
)
343+
except Exception:
344+
pass
335345
continue
336346
outdir.mkdir(parents=True, exist_ok=True)
337347
try:
338-
await b.index_codebase(
348+
# analyze_codebase runs index + resolve + cluster
349+
# in one pass so Calls_* / Imports_* / Extends_*
350+
# / Implements_* rel tables get populated. Using
351+
# index_codebase alone leaves those tables empty
352+
# and the viz filter has nothing to match.
353+
await b.analyze_codebase(
339354
str(proj),
340355
output_dir=str(outdir),
341356
language="auto",

0 commit comments

Comments
 (0)