Repository navigation
fix(python): count a subscript annotation's value once, not as its own generic arg - #5113
rohit-jsfreaky wants to merge 1 commit into
Conversation
…n generic arg `_python_collect_type_refs` walks a `subscript` annotation's value, then skips it among the children with `c is value`. py-tree-sitter returns a new Node object on every access, so `is` never matched and the value was walked a second time as a generic argument. `def f(x: mod.MyBox[Foo])` collected `MyBox` as both `type` and `generic_arg`, adding a false `references` edge with `context: generic_arg` next to the real `parameter_type` / `return_type` one. Compare with `==`, which py-tree-sitter defines on node identity in the tree. Bump _AST_CACHE_SCHEMA to 43 so cached Python extractions re-run. Co-Authored-By: Claude <[email protected]>
|
Note: my open #5052 also bumps |
|
The red |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).
Not verified on this run: \_python\_collect\_type\_refs (vacuous: never exercised).
Graphify review — findings
Bumps _AST_CACHE_SCHEMA so cached extractions re-run under revised extractor semantics, and adjusts how the engine resolves receiver types across languages. Python and JS now check whether a locally bound or parameter name shadows a receiver, and Java, TS, Kotlin, Swift, Ruby and C# receiver typing and argument counting are updated. On the cache side, the semantic cache normalizes paths, checks stat-signature freshness, and handles edges that would dangle when saving.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 4346 functions depend on the 509 functions this change touches.
Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
extract()— 1174 callers, 71 callees (high)_rebuild_code()— 268 callers, 74 callees (high)detect()— 154 callers, 19 callees (high)dispatch_command()— 8 callers, 148 callees (high)_extract_generic()— 20 callers, 54 callees (high)extract_js()— 101 callers, 8 callees (high)load_cached()— 72 callers, 10 callees (high)save_semantic_cache()— 67 callers, 9 callees (high)- …and 2 more
Verification — 4346 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: 2871 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
93 of 542 test file(s) selected (17%) via static blast radius.
tests/test_4992_ts_import_types.py— impacttests/test_astro_extraction.py— impacttests/test_binary_media_words.py— impacttests/test_build.py— impacttests/test_cache.py— impacttests/test_cache_long_paths.py— impacttests/test_cache_stale_import_target.py— impacttests/test_cache_windows_case_4925.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_code_only_scope_4923.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_csharp_extension_calls.py— impacttests/test_csharp_extension_metadata.py— impacttests/test_csharp_extension_resolution.py— impacttests/test_csharp_partial_classes.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_dotnet.py— impacttests/test_ejs_extractor.py— impacttests/test_ext_tagged_id_clash.py— impacttests/test_extract.py— impacttests/test_extract_cache_location.py— impacttests/test_extract_cli.py— impacttests/test_extract_php_closures.py— impacttests/test_grammar_cache_key.py— impacttests/test_hook_content_freshness.py— impacttests/test_ignore_file_encoding.py— impacttests/test_import_extension_resolution.py— impacttests/test_incremental_mtime_collision.py— impacttests/test_indirect_call_block_scoped_shadow.py— impacttests/test_indirect_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_java_member_calls.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_js_member_collisions.py— impacttests/test_language_override_lifecycle.py— impacttests/test_language_overrides.py— impacttests/test_languages.py— impacttests/test_linked_worktree_reconcile.py— impacttests/test_llm_backends.py— impacttests/test_manifest_ingest.py— impacttests/test_msbuild_dir_evidence.py— impacttests/test_multilang.py— impacttests/test_objc_field_table_remap.py— impacttests/test_out_dir_evidence.py— impacttests/test_partial_cache.py— impacttests/test_php_unparsed_casts.py— impact- … and 43 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
Could not verify: Could not verify \_python\_collect\_type\_refs.
The verifier did not have enough to check \_python\_collect\_type\_refs, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 234 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)
… trio #5113 (Python subscript generic-arg count) and #5117/#5118/#5115 (C++ decl/def reconcile, scoped aliases + inherited receivers, template ownership + guarded initializers) all change per-file extractor output and land in one window, so they share a single bump to 43 chained over prior (42). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed on |
_php_get_route_name reads a route's path (or a group's prefix) from the
string arguments before the closure, and stops at the closure's argument
with `sibling is curr`. py-tree-sitter hands back a new Node object on every
access, so `is` never matched: the scan ran past the closure and took a
string argument after it. `$app->get(function () {...}, '/late')` became a
`GET /late` route, and `$app->group(function ($g) { $g->get('/users', ...); },
'/late')` labelled the inner route `GET /late/users`. Compare with `==`,
which py-tree-sitter defines on the node's identity in the tree. Same class
of bug as #5113.
Bump _AST_CACHE_SCHEMA to 44 so cached PHP extractions re-run.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit c3cf5d3)
Closes #5110
What does this PR do?
In
_python_collect_type_refs, the subscript branch compared tree-sitter nodes withis. py-tree-sitter returns a newNodeobject on every access, soc is valuenever matched and the value was walked a second time as one of its own generic arguments. Now it uses==.graph.json keeps one edge per node pair, so on v8 the false
generic_argreference replaced the correct one. With the fix the right context comes back:The edge count doesn't change; only the
contextof these edges does._AST_CACHE_SCHEMAgoes 42 -> 43 so cached Python extractions re-run.Diff:
engine.py+4/-1,cache.py+1/-1, one test file.Other
iscomparisons between tree-sitter nodesI checked every
isbetween nodes ingraphify/:engine.py, the PHP route-prefix loop (sibling is curr).currcomes from.parentandsiblingfrom.children, so it never matches, and the loop can pick a path string from after the closure. That's a different language, so it should be a separate PR.engine.py4 places,objc.py2,solidity.py1.Type of change
Verification & Invariants
Invariant: a Python annotation's references are each emitted once with the right context. Persisted state: the AST cache is bumped (42 -> 43), so cached Python extractions re-run.
How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.