Repository navigation
fix(extract): keep an importer's include on the salted id of an out-of-batch file - #5634
0xkaushik-ai wants to merge 1 commit into
Conversation
…f-batch file foo.c and foo.h both yield the file id `foo`, so a full build salts them to foo_c_foo and foo_h_foo and points main.c's `#include "foo.h"` at foo_h_foo. An update that re-extracted only main.c had neither colliding file in its batch: _disambiguate_colliding_node_ids found no collision, dropped the importer's target_file stamp and left the include on the bare `foo`. The graph gained a sourceless `foo` node a full build never has and lost the edge to the real header. The same happened to `import ... from './index'` next to index.ts/index.js, and to C++ (w.cpp/w.hpp). Hand the read-only resolution context nodes to the disambiguation. A file-level import edge whose stamped target file is not in the batch, and has exactly one persisted file node, takes that node's id. Symbol imports carry the same stamp but do not target the bare file id, so they are left alone. The regression test runs `graphify update` and `graphify extract` on C, C++ and TS trees, touches only the importer, and compares with a full build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the pull request, @0xkaushik-ai. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
5 possible issues to check · High impact
The incremental CLI passes persisted nodes from unchanged files into extraction.
5 possible issues we couldn't confirm
- Out-of-batch file keys resolve against the current directory, so retargeting silently does nothing when the run starts below the repo root ·
graphify/extractors/resolution.py:1157 - Retargeting also rewrites
referencesedges, although the function and PR are about imports ·graphify/extractors/resolution.py:1166 - The
target_filestamp is read here but never cleared, so it may be written into the saved graph ·graphify/extractors/resolution.py:1165 - +2 more in Graphify
They don't change the score.
Code graph · 5774 functions depend on this change
- 1 function became more coupled.
_disambiguate_colliding_node_ids()(4 callers). - 393 of 659 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed a1bad4d
Extractor accuracy (Swift #5641, Apex #5627, Python #5647, TypeScript #5604/#5614/#5612, Bash caller-var #5602), GitHub Actions run-step extraction (#5603), incremental correctness (#5634/#5638/#5636), symlink and semantic-cache fixes (#5617/#5618), export/report hardening and perf (#5643/#5644/#5645/#5646/#5619/#5620/#5621), and CLI/docs/skill/install work (#5629/#5628/#5626/#5624/#5623/#5625/#5642/#5583). AST cache schema 59 to 60; Swift/Apex/Python/Bash/GHA inputs re-extract on first build. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.124 (just released to PyPI), cherry-picked with your authorship preserved so it shows under your name in the history. Thanks @0xkaushik-ai for keeping an importer's include on the salted id of an out-of-batch file — verified green in the full suite and, where applicable, smoke-tested against the published package. 🙏 |
Fixes #5630.
When an update re-extracts only a file that imports one half of a same-stem pair (
foo.c/foo.h,w.cpp/w.hpp,index.ts/index.js), neither colliding file is in the batch._disambiguate_colliding_node_idsfinds no collision, takes its early exit, drops the importer'starget_filestamp and leaves the import on the bare id. The update then mints a sourceless node (foo) a full build never has and loses the edge to the real file.Change
graphify/extract.py: passresolution_context_nodesinto_disambiguate_colliding_node_ids.graphify/extractors/resolution.py: new_retarget_imports_to_context_file_nodes, run first. A file-level import edge (imports,imports_from,re_exports,references) whose stamped target file is not in the batch, and has exactly one persisted file node, takes that node's id. Symbol imports carry the same stamp but don't target the bare file id, so they are left alone.Invariant: an incremental update gives the same nodes and edges as a full build of the same tree.
Tests
tests/test_incremental_import_salted_target.pyrunsgraphify updateandgraphify extracton C, C++ and TS trees, touches only the importer, and compares with a full build.only in update: ['foo'],['w'],['src_index']).test_hooks_rewrite.py::test_revert_range_rebuilds_once_and_removes_the_functions, under-n auto; it passes alone and on reruns, on this branch and on v8.ruff checkclean;pyrightonresolution.pyreports the same 32 errors as v8, none in the new code.Found with a differential check that compares incremental rebuilds against full builds. The other cases it turned up are filed as #5631, #5632 and #5633, and fixes for those will follow as separate PRs.
🤖 Generated with Claude Code