Skip to content

fix: implement __eq__ and __ne__ for CopyOnWriteList - #136

Merged
araujof merged 2 commits into
contextforge-org:0.1.xfrom
metju-ac:fix/copyonwritelist-equality-bug
Aug 4, 2026
Merged

fix: implement __eq__ and __ne__ for CopyOnWriteList#136
araujof merged 2 commits into
contextforge-org:0.1.xfrom
metju-ac:fix/copyonwritelist-equality-bug

Conversation

@metju-ac

Copy link
Copy Markdown

Summary

Fixes equality comparison bug where CopyOnWriteList compared equal to [] even when containing data from its wrapped original list. This caused apply_policy() to incorrectly drop valid payload modifications when a plugin filtered a list down to empty (e.g. an authorization plugin denying every item in a listing), so the gateway would silently fall back to serving the original, unfiltered list.

Closes: #135

Changes

  • Add eq() to CopyOnWriteList so equality compares materialized
    sequence contents rather than the empty backing list storage
  • Add ne() for consistent inequality behavior
  • Mark CopyOnWriteList as unhashable with hash = None
  • Add equality/hash regression coverage in test_memory.py
  • Add apply_policy() regression coverage for the tool_post_list
    all-denied-listing flow in test_policies.py

Checks

  • make lint passes
  • make test passes
  • CHANGELOG updated (if user-facing)

Notes (optional)

Design sketch, screenshots, or extra context.

@araujof araujof self-assigned this Aug 4, 2026
@araujof araujof added bug Something isn't working 0.1.x labels Aug 4, 2026
@araujof araujof added this to CPEX Aug 4, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in CPEX Aug 4, 2026
@araujof araujof moved this from Backlog to In review in CPEX Aug 4, 2026
@araujof araujof added this to the 0.1.3 milestone Aug 4, 2026
metju-ac and others added 2 commits August 4, 2026 16:36
Signed-off-by: Matej Klima <matej.klima5@gmail.com>
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
@araujof
araujof force-pushed the fix/copyonwritelist-equality-bug branch from e8a3226 to 389a04a Compare August 4, 2026 20:47

@araujof araujof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

I confirmed the bug, and pushed a few nits directly to the PR branch.

Thanks for this PR!

@araujof
araujof merged commit c45bf4b into contextforge-org:0.1.x Aug 4, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in CPEX Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.1.x bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG]: CopyOnWriteList compares equal to [], silently discarding empty-list hook payload modifications

2 participants