Repository navigation
MAINT: Make ScorerEvaluator registry update dispatch exhaustive (P311-03) - #4045
Merged
Roman Lutz (romanlutz) merged 3 commits intoNov 8, 2026
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the registry-update dispatch change.
No open issues 🎉
What changed in this PR
Makes registry-update dispatch in ScorerEvaluator.run_evaluation_async explicit and statically exhaustive for P311-03, following the existing from_scorer pattern while preserving runtime behavior.
Changes:
- Handles all three
RegistryUpdateBehaviormembers explicitly, with a type-checking-onlyassert_neverguard and the existing out-of-enum fallback. - Adds parametrized coverage for existing-metrics checks and registry writes across all supported modes and the fallback.
| File | Description |
|---|---|
tests/unit/score/test_scorer_evaluator.py |
Adds registry-update behavior regression coverage. |
pyrit/score/scorer_evaluation/scorer_evaluator.py |
Replaces implicit dispatch with exhaustive matching and explicit behavior flags. |
Review effort: Balanced
Roman Lutz (romanlutz)
self-requested a review
November 7, 2026 19:14
10 of 25 tasks
Roman Lutz (romanlutz)
approved these changes
Nov 8, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.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.
Description
Implements the P311-03 case for
RegistryUpdateBehaviordispatch inScorerEvaluator.run_evaluation_async, claimed and assigned in #3166.The method checked
SKIP_IF_EXISTSandNEVER_UPDATEwith==and!=, soALWAYS_UPDATEand any future member fell through implicitly. It now matches each member explicitly and adds aTYPE_CHECKING-onlyassert_neverguard, following the existing pattern inScorerEvaluator.from_scorer(#3924).Behavior is unchanged, including the runtime fallback for values outside the enum (run the evaluation and write to the registry).
Tests and Documentation
Added a parametrized test in
tests/unit/score/test_scorer_evaluator.pycovering all three members and the out-of-enum fallback: whether existing metrics are checked and whether the registry is written. It passes on both the old and new code, confirming no behavior change.No docs or notebooks changed, so JupyText was not needed.