fix: Scope boundaries for JS/TS entity extraction#35
Open
c22 wants to merge 1 commit intoAtaraxy-Labs:mainfrom
Open
fix: Scope boundaries for JS/TS entity extraction#35c22 wants to merge 1 commit intoAtaraxy-Labs:mainfrom
c22 wants to merge 1 commit intoAtaraxy-Labs:mainfrom
Conversation
The entity extractor recursed into JS/TS function expression bodies (arrow functions, function expressions, generator functions) and extracted local variables (const, let, var) as top-level entities. These spurious entities are unstable and small structural changes to surrounding code could cause different locals to be extracted, producing different entity sets from logically equivalent code. Downstream consumers such as weave interpret the instability as intentional additions or deletions, which could cause code to be silently dropped or mangled during merge conflict resolution. Scope boundaries are now selectively transparent: local variable declarations inside function expression bodies are suppressed, but inner class and function declarations are still extracted as entities. This keeps entity extraction stable across versions while preserving granularity for real semantic units. Implementation uses two mechanisms configured through LanguageConfig: 1. scope_boundary_types When the general recursion in visit_node encounters one of these node types, it propagates the boundary as the suppression_context rather than skipping the subtree entirely. 2. suppressed_nested_entities Rules keyed on suppression_context filter out lexical_declaration and variable_declaration inside scope boundary types and named function/method bodies. Both are configured through LanguageConfig fields and currently only apply to JavaScript/TypeScript.
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.
The entity extractor recursed into JS/TS function expression bodies (arrow functions, function expressions, generator functions) and extracted local variables (const, let, var) as top-level entities. These spurious entities are unstable and small structural changes to surrounding code could cause different locals to be extracted, producing different entity sets from logically equivalent code.
Downstream consumers such as weave would interpret the instability as intentional additions or deletions, which could cause code to be silently dropped or mangled during merge conflict resolution.
Scope boundaries are now selectively transparent: local variable declarations inside function expression bodies are suppressed, but inner class and function declarations are still extracted as entities.
This keeps entity extraction stable across versions while preserving granularity for real semantic units.
Implementation uses two mechanisms configured through LanguageConfig:
scope_boundary_types When the general recursion in visit_node encounters one of these node types, it propagates the boundary as the suppression_context rather than skipping the subtree entirely.
suppressed_nested_entities Rules keyed on suppression_context filter out lexical_declaration and variable_declaration inside scope boundary types and named function/method bodies.
Both are configured through LanguageConfig fields and currently only apply to JavaScript/TypeScript.