Repository navigation
fix(watch): re-extract unchanged importers waiting on an added file - #5651
Open
0xkaushik-ai wants to merge 2 commits into
Open
0xkaushik-ai wants to merge 2 commits into
0xkaushik-ai wants to merge 2 commits into
Conversation
An importer extracted before the file it imports existed holds an unresolved-import placeholder. Adding the file re-extracted only the new file, so the importer kept the placeholder and never gained the import/call edges a full build draws. _added_import_partners follows the importers of a placeholder whose id ends with the added file's stem, or its directory for a directory module (index/__init__/mod, or any Go file); a directory name elsewhere in an id matches nothing. Chained into _incremental_partners, so both update and the extract incremental block use it. 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 
No issues reported · High impact
The incremental watcher now identifies unchanged importers whose unresolved-import placeholders may match a newly added file and includes them in the re-extraction set.
Code graph · 855 functions depend on this change
- 1 function became more coupled.
_incremental_partners()(3 callers). - 56 of 666 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed d1afbdb · 1 of 1 earlier findings resolved
`./api` resolves to an added `api.d.ts`, but the matcher took its stem as `api.d`, so the `ref_api` placeholder never matched and the importer kept it. Drop the `.d` of a .d.ts/.d.mts/.d.cts stem (so `types/index.d.ts` is a directory module too). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5631. Resubmits the add-a-file half of #5635, tightened as asked in #5635 (comment) (the deleted-file half landed via #5638).
An importer extracted before the file it imports existed holds an unresolved-import placeholder (
a,ref_m,pkg_sub_a,go_pkg_ex_p). When the file is then added, an incremental run re-extracted only the new file, so the importer kept the placeholder a full build no longer mints and never gained theimports/callsedges into the new file.Fix:
graphify/watch.py,_added_import_partners, chained into_incremental_partners, so it runs on both incremental paths:_rebuild_code(update / hook / watch) and thegraphify extractincremental block incli.py.Matching (the tightening): a placeholder names the import, so its id ends with the module the import resolves to. A placeholder is followed only when its id equals, or ends with
_+ one of:a.py→a,ref_m,pkg_sub_a), with the.dof a TypeScript declaration file dropped (api.d.ts→ref_api);index/__init__/modfile, or any Go file, since Go imports a package directory (p/p.go→go_pkg_ex_p).A directory name anywhere else in an id no longer matches: adding
src/zeta.pyorlib/zeta.pywidens nothing, where the old matcher took every parent-directory component as a key. A same-named external package can still widen the run (placeholders don't record which they are), which costs a re-extraction, never a wrong edge.Tests:
tests/test_incremental_added_import_target.pyupdateandextract× Python, TypeScript, TypeScript directory import (./lib→lib/index.ts), TypeScript declaration files (api.d.ts,types/index.d.ts) and Go: each incremental graph is compared with a full build. On v8 all 12 fail; with the fix all pass (20 tests in the file).src/zeta.py,lib/zeta.py,src/lib/zeta.pyorother/lib.pywidens nothing;lib/helpers.py,src/core.py,tools/util.pyandsrc/core/__init__.pywiden only the importer whose placeholder ends with that name.ruff checkclean.Not covered: a Python package import (
from pkg.mod import f→ addedpkg/mod/__init__.py). The importer is now picked for re-extraction, but its AST cache entry is keyed on its own unchanged content, so the cached result with the placeholder comes back. That is the extraction cache, not the widening, so I've left it out of this PR.🤖 Generated with Claude Code