Repository navigation
fix: recover chained TS decorators and report the lossy parse region (#4711) - #4715
Deepjyoti-Sarmah wants to merge 2 commits into
Conversation
…raphify-Labs#4711) tree-sitter-typescript 0.23.2 cannot parse a member access on a call in decorator position. For `@(Link().toMany())` it wraps `Link().` in an ERROR and parses `toMany()` as a sibling, and `_ts_decorator_name` returned None for any parenthesized expression, so the decorator contributed no edge at all. Read the outermost call of a parenthesized decorator, including one recovered past an ERROR, and leave a genuinely unparseable expression (an invalid `@(A, B)`) without a name. The partial-parse warning also reported the first ERROR line, which is often an earlier single-line recovery that kept its symbols. Report the multiline region the warning gate selects on instead.
|
Thanks for the pull request, @Deepjyoti-Sarmah. 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.10 and 3.13, and that the change keeps extraction deterministic. |
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 3 changed function(s) (1 sampled, not proven, 2 not verified).
Formal verification. PR-changed functions: 1/3 verified (0 proven, 1 may-equivalent, 0 distinguished) · 2 not verified (1 vacuous, 1 unsupported).
Not verified on this run: \_extract\_generic (unsupported), \_ts\_decorator\_name (vacuous: never exercised).
Graphify review — findings
Fixes TypeScript decorators written as call chains, like @(Link().toMany()), which lost their references edge entirely. The new _ts_decorator_target_name unwraps the parenthesized expression and takes the outermost call (toMany) even when tree-sitter-typescript 0.23.2 wraps part of the chain in an ERROR. The parse error itself is still upstream, so the extractor recovers from it rather than fixing the parse. The partial-extraction warning now points at the multiline ERROR region that triggered it, via a new lossy_error_line, instead of an earlier single-line recovery that kept every symbol. It also reads "error region at line N" rather than "first error at line N", and the existing tests are updated to match. If no multiline error exists, it falls back to the first error line as before.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 3647 functions depend on the 773 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1006 callers, 60 callees - worse:
_extract_generic()— 20 callers, 47 callees
Verification — 3647 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: 3401 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
209 of 444 test file(s) selected (47%) via static blast radius.
tests/test_affected_overrides.py— impacttests/test_astro_extraction.py— impacttests/test_astro_import_ids.py— impacttests/test_blade_extractor.py— impacttests/test_build.py— impacttests/test_builtin_global_type_refs.py— impacttests/test_c_include_resolution.py— impacttests/test_cache.py— impacttests/test_case_sensitive_resolution.py— impacttests/test_cjs_module_extension.py— impacttests/test_cobol_extractor.py— impacttests/test_cpp_method_declarations.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_cpp_objc_cross_file_calls.py— impacttests/test_cpp_template_type_params.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_cross_language_call_resolution.py— impacttests/test_cross_repo_external_call_guards.py— impacttests/test_cross_repo_member_calls.py— impacttests/test_csharp_call_site_generic_args.py— impacttests/test_csharp_delegate_declarations.py— impacttests/test_csharp_enum_members.py— impacttests/test_csharp_field_generic_args.py— impacttests/test_csharp_foreach_loop_variable.py— impacttests/test_csharp_generic_callsites.py— impacttests/test_csharp_interface_dispatch.py— impacttests/test_csharp_member_calls.py— impacttests/test_csharp_member_chain_calls.py— impacttests/test_csharp_member_nodes.py— impacttests/test_csharp_object_creation.py— impacttests/test_csharp_partial_classes.py— impacttests/test_csharp_tuple_type_refs.py— impacttests/test_csharp_type_resolution.py— impacttests/test_csharp_underscore_collisions.py— impacttests/test_csharp_var_call_return_type.py— impacttests/test_csharp_verbatim_interpolation.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_dotnet.py— impacttests/test_duplicate_annotation_edges.py— impacttests/test_ejs_extractor.py— impacttests/test_elixir_defdelegate.py— impacttests/test_elixir_import_resolution.py— impacttests/test_elixir_keyword_def_calls.py— impacttests/test_elixir_qualified_calls.py— impacttests/test_elixir_unqualified_call_scope.py— impacttests/test_erlang_extractor.py— impacttests/test_ext_tagged_id_clash.py— impacttests/test_extract.py— impacttests/test_extract_cache_location.py— impact- … and 159 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
No difference found (not proven): No behavior difference found in extract (not a proof).
The verifier ran both versions of extract on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
Could not verify: Could not verify \_extract\_generic.
The verifier did not have enough to check \_extract\_generic, 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: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set
Could not verify: Could not verify \_ts\_decorator\_name.
The verifier did not have enough to check \_ts\_decorator\_name, 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 228 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)
· 2 more finding(s) on lines outside this diff (see the check run).
|
Landed in v0.9.96, now on PyPI (pip install graphifyy==0.9.96). Chained TS decorators are recovered and the lossy parse region is reported. Thanks for the fix, @Deepjyoti-Sarmah. |
What does this PR do?
Fixes #4711. A TypeScript decorator whose expression is a call chain (
@(Link().toMany())) contributed noreferencesedge to the graph, and the partial-parse warning pointed at a line that was not the one costing extraction.tree-sitter-typescript 0.23.2 cannot parse a member access on a call in decorator position.
@Link().toMany()fails on one line, without parentheses, and with the dot moved to the next line, so no formatting change avoids it. The parser recovers by wrappingLink().in an ERROR and parsingtoMany()as a sibling inside the parentheses._ts_decorator_namereturnedNonefor everyparenthesized_expression, so the whole decorator was skipped.The warning also reported the first ERROR in document order. In
continent.entity.tsthat is line 14, a single-line recovery that keeps every symbol; the multiline region at line 33 is the one that lost edges.Before (v8,
continent.entity.tsfrom the issue):After:
The two new edges add their stub targets, which is where the two extra nodes come from.
The 7-line
x.tsfrom the issue goes from no decorator edge to:Type of change
Verification & Invariants
A decorator's
referencesedge targets the outermost call of its expression, whether or not the expression is parenthesized. A recovered expression that is not a call (an invalid@(A, B)) gets no name rather than a guessed one. The warning line names the region the warning gate selects on: the earliest multiline ERROR, or the first error when the file yielded nothing but its file node.Merge Danger
Door: two-way. No cache schema change. Cached per-file results without
lossy_error_linekeep the old first-error line until they are re-extracted; the graph itself is unchanged by that key.Blast Radius: TS/JS decorator edges and the partial-parse warning text.
Parenthesized decorators in every language now resolve a name where they previously resolved none. Plain decorators (
@Component,@ng.Component(),@Injectable) take the same path as before, and the 320 TS/JS tests pass. The warning wording changed fromfirst error at line Ntoerror region at line N, which is user-visible; four existing expectations were updated with it. The full-suite failure set is identical to v8.Limitations
@Link().toMany()still attributes onlyLink, because the parser ends the decorator at@Link()and parses the rest as a separate expression.Linkgets no edge from@(Link().toMany()).How was this tested?
New tests in
tests/test_ts_decorator_chains.pyrunextract()on small TS files: the two recovered shapes, the clean identifier-receiver shape, the invalid-sequence guard, and the warning line for a file with an earlier single-line error.Verified on the issue's files with
graphify update --force:x.tsx_c -> tomanycontinent.entity.tsGraphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no skill fragments touched.)