Accept an IndependenceBasis member as itself in _basis_of - #108
Merged
Conversation
`_basis_of` resolved the basis with `IndependenceBasis(str(raw))`. `IndependenceBasis` mixes in `str`, but `Enum.__str__` wins, so `str()` on a member returns "IndependenceBasis.ATTESTED" rather than "attested". Lookup then raised ValueError and the basis fell through to UNKNOWN. The effect: a caller passing the vocabulary's own members -- the natural, type-correct call -- had every basis silently downgraded. It failed in the conservative direction, so no verdict was ever more confident than the evidence allowed, and nothing recorded is affected: every caller in this repository annotates the field `str | None` and passes strings. It still mattered. `attested_margin` and the ATTESTED path in `asymmetric_verdict` key off this value, so a downgrade does not merely lose a label -- it removes a root from the attested count, which is an input to a decision. An attested counterexample handed in as an enum member could read as INDETERMINATE where REFUTED was correct. One branch: a member is returned as itself. The string path is unchanged and remains the normal one. Unrecognised values -- wrong case, near misses, empty, non-strings -- still read as UNKNOWN. Four new tests, all of which fail without the branch. One pins `str(IndependenceBasis.ATTESTED) != "attested"`, so the branch is not later deleted as redundant by someone who assumes a str-mixin stringifies to its value. full suite 247 tests, OK Co-Authored-By: Claude Opus 5 (1M context) <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.
One branch plus four regression tests.
The bug
_basis_ofresolved the basis withIndependenceBasis(str(raw)).IndependenceBasismixes instr— butEnum.__str__wins, sostr()on a member returns"IndependenceBasis.ATTESTED", not"attested". Lookup raisedValueErrorand the basis fell through toUNKNOWN.So a caller passing the vocabulary's own members — the natural, type-correct call — had every basis silently downgraded.
What it did and didn't affect
It failed in the conservative direction: no verdict was ever more confident than the evidence allowed. And nothing recorded is affected — every caller in this repo annotates the field
str | Noneand passes strings.It still mattered.
attested_marginand the ATTESTED path inasymmetric_verdictkey off this value. A downgrade doesn't merely lose a label — it removes a root from the attested count, which is an input to a decision, not a description of one. An attested counterexample handed in as an enum member could readINDETERMINATEwhereREFUTEDwas correct.The fix
A member is returned as itself. The string path is unchanged and remains the normal one. Unrecognised values — wrong case, near misses, empty string, non-strings — still read as
UNKNOWN.Tests
Four new, all of which fail without the branch (verified by removing it and re-running: 4 failures). One pins
str(IndependenceBasis.ATTESTED) != "attested"so the branch isn't later deleted as redundant by someone who reasonably assumes a str-mixin stringifies to its value.Found while building the NIST independence fixture (#107), where passing the enum produced
weakest basis: unknownfor claims explicitly markeddeclared.🤖 Generated with Claude Code