Skip to content

fix(compare): correct drift classification and improve object comparison stability#141

Merged
AmiteK23 merged 3 commits intomainfrom
fix/compare-drift-detection
Mar 9, 2026
Merged

fix(compare): correct drift classification and improve object comparison stability#141
AmiteK23 merged 3 commits intomainfrom
fix/compare-drift-detection

Conversation

@AmiteK23
Copy link
Member

@AmiteK23 AmiteK23 commented Mar 9, 2026

Description

This PR improves the robustness and correctness of the compare command.

Drift classification fix

Updates drift detection logic so that added folders are treated as growth rather than drift.

  • Only orphaned folders and changed folders are classified as DRIFT
  • Added folders now result in PASS
  • Aligns compare behavior with the intended architectural drift semantics

Comparison robustness improvements

Improves object comparison and contract display logic to avoid false positives caused by key ordering and invalid entries.

Changes include:

  • Introduced normalizeObject and objectsEqual utilities to ensure stable comparison of objects with different key orders
  • Improved handling of props and emits arrays by filtering invalid entries and ensuring identifier validity
  • Improved display logic for prop and emit changes, including order-independent comparisons
  • Refactored multi-file and single-file comparison logic for improved consistency and edge-case handling

Tests were updated to reflect the new drift classification and improved comparison behavior.


Type of Change

  • Bug fix
  • Feature
  • Breaking change
  • Docs
  • Refactor
  • CI / Tests
  • Performance
  • Other (please describe):

Architectural Impact

  • No contract/output changes
  • Contract/output changed (describe below)

Testing

  • Tested locally
  • Tests added/updated
  • All tests pass

Related Issues

None.


Checklist

  • Target branch is main
  • Self-reviewed
  • Docs updated (if needed)
  • Changelog updated (if needed)

Additional Notes

These improvements reduce false positives in comparison results and make drift detection more aligned with real-world development workflows.

- Modify comparison logic to classify only orphaned and drift folders as 'DRIFT'; added folders are now considered growth and result in a 'PASS'.
- Update related tests to reflect the new logic, ensuring accurate detection of drift and growth scenarios.
- Introduce `normalizeObject` and `objectsEqual` functions to ensure stable comparison of objects with varying key orders.
- Update comparison logic to handle props and emits as arrays, ensuring valid identifiers are used and filtering out invalid entries.
- Improve display functions to accurately reflect changes in props and emits, including handling order changes.
- Refactor multiFile and singleFile comparison logic for consistency and robustness against edge cases.
@AmiteK23 AmiteK23 changed the title fix(compare): update drift detection logic to exclude added folders fix(compare): correct drift classification and improve object comparison stability Mar 9, 2026
@AmiteK23 AmiteK23 merged commit b6636e8 into main Mar 9, 2026
13 of 14 checks passed
@AmiteK23 AmiteK23 deleted the fix/compare-drift-detection branch March 11, 2026 17:12
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