refactor(actions): emit inherent subtree moves and suppress redundant scaffolding - #119
Merged
Conversation
… scaffolding - actions: emit Subtree flags directly on parent Move actions and remove redundant descendant walks - postprocess: drop bottom-up move tree reconstruction loop in Collapse - postprocess: suppress redundant scaffolding Delete and Move actions under active parent containers - postprocess: walk single-line ancestor chains in suppressInlineParentRedundancy to prune wrapper expressions - postprocess: remove dead contentMoveSuppressed map and deduplicate scaffolding suppression passes - tests: add unit tests for scaffolding suppression and update golden fixtures across test corpus
…atching When multiple identical isomorphic subtrees are candidates in TopDown matching, break score ties using 2-level parent AST type equality and ancestor pair keys so cohesive calls and data scopes match within context without stealing peers across distant sections. - engine: add parentLineageSimilarity to scoredPair in TopDown - engine: collect getKeyLabel from ancestor pairs and scaffolding in AncestorNameSimilarity - engine: add unit test for pair key ancestor similarity - tests: update golden fixtures for cohesive call and manifest matching
HarshK97
force-pushed
the
fix/ast-action-collapsing
branch
from
August 19, 2026 14:40
f407339 to
c74b1bd
Compare
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.
Problem
chawathe.go, we were walking all its descendants and creating individualMoveactions for every single child and grandchild in that subtree. Then incollapsing.go, we tried to reconstruct whether all those children moved together to collapse them back into a single subtree move. This was fragile and broke anytime a child inside a moved block was deleted or modified, which caused the parent move to get killed and left a bunch of messy orphan moves behind.statement_list,declaration_list, andblockwere emitting separateDeleteandMoveactions even when their parent container was already deleted or moved.expression_statementwere emitting redundant actions alongside inner child expressions (likeselector_expressionorcall_expression) because we were only checking one level up instead of checking the whole single-line parent chain.What Changed
addDescendantMovesinchawathe.goso parentMoveactions are marked withSubtree: len(children) > 0directly, instead of spamming individual child moves and trying to stitch them back together later.collapsing.gosince moves are now inherently subtree-scoped from the generator.suppressRedundantScaffolding) to drop redundant scaffoldingInsert,Delete, andMoveactions when their parent container is already doing the work.suppressInlineParentRedundancyto walk up single-line ancestors so wrapper expressions on the same line get pruned cleanly.collapsing.goby removing the unusedcontentMoveSuppressedmap and deduplicating the scaffolding suppression passes.parentLineageSimilarityto TopDown matching to score immediate parent and grandparent node type equality as a tie-breaker, keeping identical subtrees matched to their local peers.AncestorNameSimilarityto collect pair keys from ancestor pairs and scaffolding containers, improving contextual matching in structured data (JSON, YAML, and map literals).collapsing_test.goandutils_test.gocovering scaffolding suppression, multi-level inline pruning, and pair key similarity, and updated golden test fixtures across languages.Visual Comparison:
c_redis_quadratic_searchBefore
After