Repository navigation
fix(extract): extract Kotlin annotations and primary constructor properties - #3848
nikhilsaxena04 wants to merge 2 commits into
Conversation
…erties Resolves Graphify-Labs#3842. - Adds `_kotlin_annotation_names` helper to correctly extract annotations for Kotlin. - Emits references edges with context='attribute' for class, function, and property annotations. - Correctly skips use-site targets like `@field:` when extracting annotation names. - Correctly parses bracketed annotations with multiple targets (e.g. `@[Inject VisibleForTesting]`). - Traverses `primary_constructor` to extract `val`/`var` property dependencies as field edges. - Resolves annotations using simple names to prevent dangling fully-qualified nodes. Co-Authored-By: Antigravity <[email protected]>
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.
Formal verification. No changes could be formally verified in this run.
Graphify review — findings
Adds Kotlin annotation extraction so classes, functions, and properties emit references edges with attribute context for each annotation, via the new _kotlin_annotation_names helper that handles use-site targets, parameterized invocations, and bracketed lists like @[Inject VisibleForTesting]. Also resolves primary-constructor val/var parameter types into field (or generic_arg) reference edges and emits attribute edges for their annotations. Covers the behaviour with new tests spanning class/function/property annotations, parameterized and use-site-targeted forms, and constructor field/generic type resolution.
Worth a look
- Top-level Kotlin property annotations create dangling edges —
graphify/extractors/engine.py:4858· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Bracketed annotation list not handled by _kotlin_annotation_names —
graphify/extractors/engine.py:752· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1062 functions depend on the 809 functions this change touches.
Health — this change adds coupling hotspots:
- new:
_extract_generic()— 18 callers, 29 callees - new:
extract_js()— 87 callers, 4 callees - new:
extract_xaml()— 19 callers, 17 callees - new:
extract_objc()— 27 callers, 9 callees - new:
extract_julia()— 17 callers, 7 callees - new:
extract_cpp()— 29 callers, 3 callees - new:
extract_vue()— 10 callers, 7 callees - new:
walk()— 1 callers, 64 callees - …and 9 more — each is listed as a finding
Verification — 1062 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: 1016 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
25 of 301 test file(s) selected (8%) via static blast radius.
tests/test_astro_extraction.py— impacttests/test_build.py— impacttests/test_cjs_module_extension.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_dotnet.py— impacttests/test_extract.py— impacttests/test_extract_php_closures.py— impacttests/test_import_extension_resolution.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_js_exported_scalar_bindings.py— impacttests/test_languages.py— impact, changed-testtests/test_multilang.py— impacttests/test_python_underscore_resolution.py— impacttests/test_rationale.py— impacttests/test_ruby_resolution.py— impacttests/test_scala_self_type.py— impacttests/test_swift_computed_properties.py— impacttests/test_swift_protocol_requirements.py— impacttests/test_trailing_newline_not_a_syntax_error.py— impacttests/test_ts_new_expression_calls.py— impacttests/test_typescript_module_extensions.py— impacttests/test_vue_extraction.py— impact
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 \_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
· 17 more finding(s) on lines outside this diff (see the check run).
There was a problem hiding this comment.
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
Adds Kotlin annotation extraction so @Entity, parameterized (@Table(...)), use-site-targeted (@field:NotNull), and bracketed-list (@[Inject VisibleForTesting]) annotations on classes, functions, and constructor parameters now emit references edges with attribute context, via the new _kotlin_annotation_names helper. Also emits type-reference edges for primary-constructor val/var properties, tagging them field for plain types and generic_arg for type arguments (List<Order>). Covers each case with new tests.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1062 functions depend on the 809 functions this change touches.
Health — this change adds coupling hotspots:
- new:
_extract_generic()— 18 callers, 29 callees - new:
extract_js()— 87 callers, 4 callees - new:
extract_xaml()— 19 callers, 17 callees - new:
extract_objc()— 27 callers, 9 callees - new:
extract_julia()— 17 callers, 7 callees - new:
extract_cpp()— 29 callers, 3 callees - new:
extract_vue()— 10 callers, 7 callees - new:
walk()— 1 callers, 64 callees - …and 9 more — each is listed as a finding
Verification — 1062 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: 1016 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
25 of 301 test file(s) selected (8%) via static blast radius.
tests/test_astro_extraction.py— impacttests/test_build.py— impacttests/test_cjs_module_extension.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_dotnet.py— impacttests/test_extract.py— impacttests/test_extract_php_closures.py— impacttests/test_import_extension_resolution.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_js_exported_scalar_bindings.py— impacttests/test_languages.py— impact, changed-testtests/test_multilang.py— impacttests/test_python_underscore_resolution.py— impacttests/test_rationale.py— impacttests/test_ruby_resolution.py— impacttests/test_scala_self_type.py— impacttests/test_swift_computed_properties.py— impacttests/test_swift_protocol_requirements.py— impacttests/test_trailing_newline_not_a_syntax_error.py— impacttests/test_ts_new_expression_calls.py— impacttests/test_typescript_module_extensions.py— impacttests/test_vue_extraction.py— impact
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.
· 17 more finding(s) on lines outside this diff (see the check run).
… test Polish on #3848: remove the unused mid-file tree_sitter imports (F401) and add a negative test asserting a bare constructor param without val/var is not emitted as a field property. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Shipped in v0.9.69 (now on PyPI) via an authorship-preserving cherry-pick, so your commit keeps contributor-graph credit. Thanks @nikhilsaxena04! Landed with two small polish edits: dropped the unused test imports and added a negative test (a bare ctor param without val/var is not a field). |
Problem
Resolves #3842.
The Kotlin AST for annotations nests the annotation name inside
user_typeorconstructor_invocation -> user_type(unlike Java'smarker_annotation). As a result, the Kotlin extractor was completely blind to class and function annotations. Additionally, primary constructor parameters containingval/varproperties (e.g.,class User(val id: Long)) were explicitly skipped, missing field dependencies.Implementation
_kotlin_annotation_nameshelper to correctly extract annotation names for Kotlin, handling raw text resolution correctly (using simple names instead of fully-qualified names to prevent dangling nodes).use_site_targetprefixes like@field:when extracting names.@[Inject VisibleForTesting]).referencesedges withcontext='attribute'for annotations.primary_constructor -> class_parametersto extractval/varproperty dependencies ascontext='field'edges, along with their associated annotations.Verification
test_languages.pycovering all the above scenarios (regular annotations, parameterized annotations, use-site targets, multiple bracketed annotations, and primary constructor fields/annotations).uv run ruff check .anduv run pyrightcleanly.Co-Authored-By: Antigravity [email protected]