Repository navigation
typing: preserve GCG config subclasses - #4064
Merged
Roman Lutz (romanlutz) merged 2 commits intoNov 9, 2026
Merged
Roman Lutz (romanlutz) merged 2 commits into
Roman Lutz (romanlutz) merged 2 commits into
Conversation
Signed-off-by: Slai.life <huong8373tt@gmail.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the concrete-type preservation changes.
No open issues 🎉
What changed in this PR
This PR strengthens concrete-type preservation in PyRIT’s GCG configuration factories and scenario technique resolution, extending the typing work tracked in #3166.
Changes:
- Annotates GCG JSON factories with
Self, preserving existing construction and validation behavior. - Makes technique-token resolution generic over the supplied technique class.
- Adds runtime and
assert_typeregression coverage for both paths.
| File | Description |
|---|---|
tests/unit/scenario/core/test_technique_tokens.py |
Tests concrete technique types, modifier ordering, and invalid-token reporting. |
tests/unit/executor/promptgen/gcg/test_config.py |
Adds subclass runtime and type assertions for JSON and file factories. |
pyrit/scenario/core/technique_tokens.py |
Adds generic technique typing and a typed converter registry reference. |
pyrit/executor/promptgen/gcg/config.py |
Uses Self for JSON factories and the internal dictionary constructor. |
Review effort: Balanced
Roman Lutz (romanlutz)
approved these changes
Nov 9, 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.
Summary
typing.Selffor the GCG JSON and JSON-file classmethod factoriesGCGDataConfigandGCGConfigdeserializationassert_typeregression coverageScope
Part of #3166 (P311-01). This focused change preserves the existing JSON parsing, validation, defaults, nested config construction, and file behavior.
Validation
pytest tests/unit/executor/promptgen/gcg/test_config.py -q(32 passed)ruff check(passed)ruff format --check(passed)ty check(passed)Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for the submission.