fix(strategies): remove IRON_BUTTERFLY enum alias that shadowed BUTTERFLY (#4)#26
Open
bradsmithmba wants to merge 1 commit into
Open
Conversation
…RFLY StrategyType defined both BUTTERFLY = "butterfly" and IRON_BUTTERFLY = "butterfly". Identical values make IRON_BUTTERFLY a silent alias of BUTTERFLY (StrategyType.IRON_BUTTERFLY is StrategyType.BUTTERFLY), so the two collapse to one dict key — using both in a probabilities/metrics dict silently drops one entry. The codebase canonically identifies the iron butterfly as BUTTERFLY (IronButterflyStrategy.get_strategy_type returns it; the factory registry, regime mappings, recommendation engine, and API all key on BUTTERFLY). IRON_BUTTERFLY was referenced only in tests/models/test_scoring_engine.py. Remove the redundant alias and point that test at the canonical BUTTERFLY. Enum member count is unchanged (16) since the alias was never a distinct member. A separate, larger cleanup could rename BUTTERFLY -> IRON_BUTTERFLY to better reflect the implementation, but that is out of scope here. Closes cloudtrainerwork#4 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
StrategyTypedefined two members with the same value:In Python, identical enum values make the second member a silent alias of the first:
Any code that used both as distinct dictionary keys (probabilities, risk metrics, score maps) would silently lose one entry.
Closes #4.
Why remove rather than make distinct
The codebase canonically identifies the iron butterfly as
BUTTERFLY:IronButterflyStrategy.get_strategy_type()returnsStrategyType.BUTTERFLYStrategyType.BUTTERFLY -> IronButterflyStrategyrecommendation_engine, the API layer, and the curriculum all key onBUTTERFLYIRON_BUTTERFLYwas referenced in exactly one place:tests/models/test_scoring_engine.py. Making it a distinct value would create an orphan enum member with no implementation and no factory mapping. Removing the redundant alias and pointing that test at the canonicalBUTTERFLYis the minimal correct fix.Changes
src/strategies/base.py: removeIRON_BUTTERFLY = "butterfly"; add a comment explainingBUTTERFLYis the canonical iron-butterfly member.tests/models/test_scoring_engine.py:StrategyType.IRON_BUTTERFLY->StrategyType.BUTTERFLY(3 references).Verification
Note
The naming is still imperfect —
BUTTERFLYrepresents an iron butterfly. RenamingBUTTERFLY -> IRON_BUTTERFLYacross the ~30 references in 10+ files would better reflect the implementation, but that is a larger refactor and out of scope for this fix.🤖 Generated with Claude Code