refactor(checks)!: drop LesserThan and LesserThanEquals classes - #2720
Merged
kevinmessiaen merged 6 commits intoAug 12, 2026
Merged
Conversation
The Giskard Hub v3 now emits the correct `LessThan` / `LessThanEquals`
names, so the misspelled alias classes have no remaining producer and are
removed from the public API.
Their serialized `kind` strings are kept loadable so suites persisted
before the Hub upgrade still deserialize. This is done via a new
`aliases=` parameter on `Discriminated.register()`, which registers extra
discriminators on the read path only:
@Check.register("less_than", aliases=["lesser_than"])
Only the canonical kind is mapped back from the class, so a legacy payload
loads as `LessThan` and is re-saved as `less_than` — migrating itself on
the next write.
While in the registry:
- Register atomically. Validating and writing in a single pass left the
registry half-populated when a later alias collided, so a class whose
decorator raised stayed loadable.
- Drop `_reverse_kinds`, which held data identical to `_subclasses`.
Reading `_subclasses` via `.get()` also stops the former defaultdict
from inserting an empty entry on every failed lookup.
- Reject a bare `str` for `aliases`, which would otherwise register one
kind per character. `str` satisfies `Sequence[str]`, so only a runtime
guard catches it.
BREAKING CHANGE: `LesserThan` and `LesserThanEquals` are no longer
importable from `giskard.checks`. Use `LessThan` and `LessThanEquals`.
Stored payloads using the legacy `kind` strings are unaffected.
Closes ENG-1677
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 12, 2026
Reuse one kinds tuple for validate-then-write, avoid allocating an empty lookup dict on unknown bases, and type the non-string alias test for basedpyright. Co-authored-by: Kevin Messiaen <kevinmessiaen@users.noreply.github.com>
Legacy lesser_than / lesser_than_equals discriminators are no longer accepted on deserialize. Remove Discriminated.register(aliases=), which only existed for that migration path, and the tests that asserted legacy kind round-trips.
henchaves
approved these changes
Aug 12, 2026
henchaves
left a comment
Member
There was a problem hiding this comment.
LGTM, only need to update method names in test_comparison.py
Member
There was a problem hiding this comment.
there are many lesser_than in method names within this file
Align test method names in test_comparison.py with the LessThan and LessThanEquals class names and their less_than / less_than_equals serialised kinds, removing the last references to the dropped Lesser* vocabulary. Co-Authored-By: Claude Opus 5 <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.
Closes ENG-1677
What
The Giskard Hub v3 now emits the correct
LessThan/LessThanEqualsnames, so the misspelled alias classes have no remaining producer. This removes them from the public API while keeping their serializedkindstrings loadable.Why not a hard drop
LesserThan/LesserThanEqualswere not just Python aliases — they were registered in the discriminated-union registry via@Check.register("lesser_than"). Deleting them outright would make any check JSON persisted before the Hub upgrade fail to deserialize with a hardValidationError, not a degraded read.So the classes are gone, but the legacy kinds still load:
aliases=registers extra discriminators on the read path only. Only the canonical kind is mapped back from the class, so a legacy payload loads as a realLessThanand is re-saved asless_than— migrating itself on the next write.This lives in the shared
Discriminatedregistry rather than locally ingiskard-checksbecause__get_pydantic_core_schema__installs a plain validator that replaces the model schema. Validation dispatches to the concrete class before anyCheck-levelmodel_validatorcould rewritekind, so a downstream fix would have required monkeypatching registry internals.Registry fixes found while in there
_reverse_kinds, which held data byte-identical to_subclasses(verified across all 7 registered bases). Reading_subclassesvia.get()also stops the formerdefaultdictfrom inserting an empty entry on each failed lookup.strforaliases.aliases="lesser_than"would silently register one kind per character;strsatisfiesSequence[str], so no type checker catches it.aliasesis now keyword-only.Breaking change
LesserThanandLesserThanEqualsare no longer importable fromgiskard.checks— useLessThan/LessThanEquals. Stored payloads using the legacykindstrings are unaffected. Worth a release-note line for OSS 3.0.Testing
giskard-core47 passed,giskard-checks804 passed / 4 skippedmake checkexit 0 (basedpyright 0 errors, pip-audit + licensecheck clean)DID NOT RAISEagainst the single-pass versiongiskard-agentshas 7 pre-existing failures from a missing Gemini API key; confirmed identical on a clean treeFollow-up
Legacy alias hits are not observable:
_telemetry_props.pyreadskindoff the instance, which now always returns the canonical name. Without a counter or debug log at the alias-match site, these aliases can never be retired on evidence. Worth a separate ticket.🤖 Generated with Claude Code