Skip to content

Disallow adding Implementation objects from a different Alternatives set#9

Merged
Code0x58 merged 2 commits into
masterfrom
codex/validate-implementation-in-alternatives.add
May 9, 2026
Merged

Disallow adding Implementation objects from a different Alternatives set#9
Code0x58 merged 2 commits into
masterfrom
codex/validate-implementation-in-alternatives.add

Conversation

@Code0x58
Copy link
Copy Markdown
Owner

@Code0x58 Code0x58 commented May 9, 2026

Motivation

  • Prevent accidental mixing of Implementation instances between different Alternatives sets by surfacing an explicit error instead of silently accepting or incorrectly cloning them.

Description

  • Add a new exception class CrossAlternativesImplementation for this specific error case.
  • In Alternatives.add, raise CrossAlternativesImplementation when an Implementation being added belongs to a different Alternatives instance.
  • Update tests to expect the new error when attempting to add an Implementation from another alternatives set and add a dedicated test_cross_owner_add_error that asserts the exception and its message.

Testing

  • Ran the updated unit tests with pytest test_alternative.py::test_add_from_other_alternatives and pytest test_alternative.py::test_cross_owner_add_error, and both tests passed.
  • Ran the test file test_alternative.py with pytest and observed the updated tests succeeded.

Codex Task

@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (379a5d2) to head (620b06b).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##            master        #9   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          199       202    +3     
=========================================
+ Hits           199       202    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Code0x58
Copy link
Copy Markdown
Owner Author

Code0x58 commented May 9, 2026

This is a bit pedantic, probably based on the idea that alternatives are functionally identical, and do different Alternative collections are naturally not identical. If this case is encountered then hopefully it is an error, or an indication that two sets of alternatives are the same and so would be good to unify. If not, well, hello - there should be some workarounds but feel free to drop a comment here.

@Code0x58 Code0x58 merged commit 1f7f06d into master May 9, 2026
5 checks passed
@Code0x58 Code0x58 deleted the codex/validate-implementation-in-alternatives.add branch May 9, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant