Repository navigation
fix(watch): preserve direct calls to unchanged files during incremental updates - #2439
aryanbonigala wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
This PR adds a new optional direct_call_resolution_context_nodes parameter to graphify.extract.extract(), which supplies read-only AST nodes from files not being re-extracted so the shared direct cross-file call resolution pass can extend its label/file indexes without parsing, mutating, or emitting those nodes. In graphify/watch.py, _rebuild_code is updated to build this context list from the persisted graph during incremental rebuilds (filtering to AST-tier nodes from unchanged, non-deleted, still-present source files) and pass it into extract(). The test file adds coverage for incremental rebuild scenarios around cross-file call edges, plus a number of related watch/rationale test cases. The stated intent is to prevent changed→unchanged direct calls edges from being dropped during incremental rebuilds, with member calls and indirect calls explicitly left out of scope.
No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1443 functions depend on the 456 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_rebuild_code()— 78 callers, 49 callees
Verification — 1443 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1316 function(s) in the blast radius were not formally verified this run
· 1 more finding(s) on lines outside this diff (see the check run).
… preservation, extract crash recovery; bump to 0.9.33 #2411 (thanks @JensD-git): key the C# partial-class merge on assembly (nearest ancestor .csproj/.fsproj/.vbproj) in addition to namespace and name, so same-name partial classes in different assemblies stay distinct while genuine partial halves within one project still merge. Fixes a 0.9.32 regression from #2332. #2437/#2438 (thanks @aryanbonigala, builds on PR #2439): incremental rebuilds no longer drop member-call and indirect_call edges from a changed file into an unchanged target. Re-resolution now sees the unchanged corpus (nodes, contains/method edges, and _callable markers, which now persist to graph.json like _origin); edges to a genuinely removed target are still evicted. #2444/#2445 (thanks @Baziar, builds on PRs #2461/#2458): a BrokenProcessPool triggers the sequential fallback instead of being swallowed per future, a failed worker file is retried sequentially rather than merged as empty, and a whole-pass AST failure on a fresh build exits non-zero instead of writing a zero-node graph (--allow-partial opts into a best-effort partial graph). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Shipped in v0.9.33 ( |
… preservation, extract crash recovery; bump to 0.9.33 Graphify-Labs#2411 (thanks @JensD-git): key the C# partial-class merge on assembly (nearest ancestor .csproj/.fsproj/.vbproj) in addition to namespace and name, so same-name partial classes in different assemblies stay distinct while genuine partial halves within one project still merge. Fixes a 0.9.32 regression from Graphify-Labs#2332. Graphify-Labs#2437/Graphify-Labs#2438 (thanks @aryanbonigala, builds on PR Graphify-Labs#2439): incremental rebuilds no longer drop member-call and indirect_call edges from a changed file into an unchanged target. Re-resolution now sees the unchanged corpus (nodes, contains/method edges, and _callable markers, which now persist to graph.json like _origin); edges to a genuinely removed target are still evicted. Graphify-Labs#2444/Graphify-Labs#2445 (thanks @Baziar, builds on PRs Graphify-Labs#2461/Graphify-Labs#2458): a BrokenProcessPool triggers the sequential fallback instead of being swallowed per future, a failed worker file is retried sequentially rather than merged as empty, and a whole-pass AST failure on a fresh build exits non-zero instead of writing a zero-node graph (--allow-partial opts into a best-effort partial graph). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Incremental rebuilds previously re-extracted only the changed files. The shared direct-call resolver therefore lacked the unchanged target nodes it needed to bind a plain
foo()to its definition in another file.Reconciliation correctly removed the changed source's old AST edges — that part was never wrong — but with the callee absent from the extraction batch, the missing direct call could not be regenerated. The result: a cross-file
callsedge that a full build resolves silently disappears after an incremental update, and only returns on the next full rebuild. (The file-levelimportsedge survived, because the JS/Python symbol-resolution pass reads the import target off disk rather than off the node list — which is why the loss was easy to miss.)This patch supplies a read-only AST context containing unchanged, live, in-corpus nodes exclusively to the shared direct-call resolver:
all_nodesis untouched andraw_callsstill come solely from the re-extractedpaths.Scope
This is intentionally a narrow fix.
obj.method()) andindirect_calledges. Both require resolver metadata thatgraph.jsondoes not persist — per-file type tables plus the callee'scontains/methodedges for member calls, and the_callable/_callable_classmarkers (stripped before write) for indirect calls. Inferring either from persisted labels would reintroduce the same-named data-symbol false positives that Extend indirect_call to remaining dispatch patterns (dict tables, assignments, other languages) #1566 and indirect_call callable guard admits classes → false edges for select(Model), except tuples, and getattr literals #2137 removed. These remain tracked in the two follow-up issues below.Addresses #2406
Related to #2437
Related to #2438
Testing
All runs on
uv run --frozen, with the OpenAI extra synced viauv sync --frozen --group dev --extra openai.uv.lockis unchanged.pytest tests/test_watch.py -q97 passed, 2 skipped, 2 xfailedpytest tests/test_js_import_resolution.py tests/test_extract.py -q222 passed, 1 skippedpytest tests/test_ollama_retry_cap.py -q4 passedpytest -q(full suite)3915 passed, 35 skipped, 2 xfailedruff check graphify testsAll checks passed!git diff --checkThe two
xfail(strict=True)tests are the admitted scope gaps above, and each corresponds to one of the newly filed follow-up issues:test_incremental_rebuild_drops_member_call_to_unchanged_target→ Incremental update drops member-call edges to unchanged files #2437test_incremental_rebuild_drops_indirect_call_to_unchanged_target→ Incremental update drops indirect_call edges to unchanged callable targets #2438They are strict on purpose: whoever closes either issue will be told to delete the marker rather than leave it silently stale.
New passing coverage added alongside them: