fix: implement __eq__ and __ne__ for CopyOnWriteDict#55
Merged
Conversation
7 tasks
vishu-bh
approved these changes
May 28, 2026
Contributor
vishu-bh
left a comment
There was a problem hiding this comment.
Thanks @prakhar-singh1928!
Fixes CopyOnWriteDict equality to compare the materialized mapping instead of the empty underlying dict storage. That preserves valid plugin payload modifications, including the WXO case where wxo_* args are stripped and the resulting args become {}.
The added regression tests cover direct equality, policy application, and the tool_pre_invoke executor path.
LGTM ☘️
2fee074 to
94f736a
Compare
Fixes equality comparison bug where CopyOnWriteDict compared equal to {}
even when containing data. This caused apply_policy() to incorrectly drop
valid payload modifications when plugins removed all arguments.
Changes:
- Add __eq__ and __ne__ methods to CopyOnWriteDict
- Add 13 comprehensive equality unit tests
- Add policy regression tests for empty args scenario
- Add end-to-end integration tests
Signed-off-by: prakhar-singh1928 <prakhar.singh1928@ibm.com>
Signed-off-by: prakhar-singh1928 <prakhar.singh1928@ibm.com>
- Restored missing 'assert a not in keys' in test_iteration_order_with_deletions - Added fast-path length check in CopyOnWriteDict.__eq__() for better performance - Performance optimization is safe: if lengths differ, mappings cannot be equal Signed-off-by: prakhar-singh1928 <prakhar.singh1928@ibm.com>
94f736a to
307b1e8
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.
fix: implement eq and ne for CopyOnWriteDict
Fixes equality comparison bug where CopyOnWriteDict compared equal to {} even when containing data from its wrapped original mapping. This caused apply_policy() to incorrectly drop valid payload modifications when plugins removed all arguments.
Summary
CopyOnWriteDict now compares equality using its materialized logical mapping instead of the empty backing dict storage. This preserves valid hook payload updates when a plugin transforms populated args into an empty {} payload.
Closes: #54
Changes
Checks
Notes (optional)