FEAT: Extract attack factory constructor compatibility rules (#2764) - #2795
Merged
Roman Lutz (romanlutz) merged 8 commits intoSep 28, 2026
Merged
Roman Lutz (romanlutz) merged 8 commits into
Roman Lutz (romanlutz) merged 8 commits into
Conversation
6 tasks
Contributor
Author
|
Thanks for catching this! I have updated Added unit and regression tests:
|
Preserve the benchmark prompt-prefix copy helper and use the extracted constructor contract for its capability check. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ack-factory-rules-2764 # Conflicts: # pyrit/scenario/core/attack_technique_factory.py
Declare deliberately late-bound configuration names only for static analysis, preserving the runtime forward-reference regression coverage without suppressing type errors. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Roman Lutz (romanlutz)
enabled auto-merge
September 25, 2026 14:33
3 tasks
Contributor
Author
|
Hi Roman Lutz (@romanlutz), I updated the branch with the latest |
Roman Lutz (romanlutz)
approved these changes
Sep 28, 2026
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
This PR extracts constructor-contract inspection and scoring configuration compatibility logic out of
AttackTechniqueFactoryinto a dedicated, private helper class_ConstructorCompatibilityHelperlocated inpyrit.scenario.core._attack_constructor_compatibility.Key changes:
accepted_params) and scoring config type requirements (scoring_config_type) once at helper instantiation time._get_accepted_params,_should_apply_scoring_config,_apply_scorer_policy,_get_scoring_config_type,_unwrap_optional) into_ConstructorCompatibilityHelper.ScorerOverridePolicyfromattack_technique_factory.pyto maintain 100% public API backwards compatibility.Closes #2764
Tests and Documentation
tests/unit/scenario/core/test_attack_constructor_compatibility.pyexercising_ConstructorCompatibilityHelperdirectly across parameter discovery, optional type unwrapping, andScorerOverridePolicybehaviors (SKIP, WARN, RAISE).tests/unit/scenario/core/test_attack_technique_factory.py.uv run pre-commit run --all-files), all 17 hooks passed.uv run -m ty check pyrit/ tests/unit/scenario/core/), 0 errors.uv run -m pytest tests/unit/scenario/), all 1,142 tests passed._attack_constructor_compatibility.py.