Skip to content

feat(engine): add order-insensitive container node matching - #90

Merged
HarshK97 merged 3 commits into
mainfrom
feat/unordered-node-matching
Aug 14, 2026
Merged

feat(engine): add order-insensitive container node matching#90
HarshK97 merged 3 commits into
mainfrom
feat/unordered-node-matching

Conversation

@HarshK97

Copy link
Copy Markdown
Owner

Problem

  1. Structural AST matching was treating all container children as ordered sequences during Chawathe LCS alignment and Bottom-Up candidate matching.
  2. So reordering keys in data structures like JSON objects, Python dicts, JS/TS objects, Ruby hashes, Go interfaces, or Rust use blocks generated spurious Move actions, even though key order in those containers doesn't matter.

What Changed

  • Added an IsUnordered flag to ASTNode and hooked up an unordered list to rules.yml so languages can mark order-insensitive containers.
  • Updated Chawathe alignment in internal/actions/chawathe.go to skip sequence LCS alignment for unordered containers, matching mapped children directly so reordered keys don't trigger fake Move actions.
  • Updated BottomUp candidate matching in internal/engine/bottom-up.go using getKeyLabel to pair unordered container children by key name instead of line position.
  • Registered order-insensitive container node types across rules files for Go, Java, JS, TS, TSX, PHP, Python, Ruby, and Rust.
  • Added unit tests in internal/actions/chawathe_test.go and updated baseline integration test fixtures in tests/testdata/.

Visual Comparison

  • Example: tests/testdata/py_requests_environment_bundle/

Before

  • Move of 'verify': verify, cause of reordering in the return order.
image

After

  • No move, due to reordering of the return order.
image

@HarshK97
HarshK97 merged commit 2e1a353 into main Aug 14, 2026
13 checks passed
@HarshK97
HarshK97 deleted the feat/unordered-node-matching branch August 14, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant