MAINT: Strongly Typed Identifiers#2007
Open
rlundeen2 wants to merge 5 commits into
Open
Conversation
Introduce typed identifiers as subclasses of ComponentIdentifier in pyrit/models/identifiers/ (TargetIdentifier, ScorerIdentifier, ConverterIdentifier, AttackIdentifier, AttackTechniqueIdentifier, SeedIdentifier, AtomicAttackIdentifier). Each promotes its identity-defining params/children into typed fields while mirroring them back so hashes stay stable with plain ComponentIdentifiers. Key changes: - ComponentIdentifier: tighten params to JSON-scalar/list/dict values and children to ComponentIdentifier instances, validated/coerced via a model_validator(mode="before") plus the .of(...) factory; rename .promote() to .from_component_identifier(). - Identifiable._create_identifier subclasses build the correct typed identifier with strongly-typed named params (targets, scorers, converters, attacks, attack techniques). - Move TargetCapabilities to a pydantic model in pyrit/models; capabilities are no longer part of target identity. - Fold free builders into classmethods: build_seed_identifier -> SeedIdentifier.from_seed and build_atomic_attack_identifier -> AtomicAttackIdentifier.build; remove the free functions, their exports, and the stale pyrit/identifiers/atomic_attack_identifier.py shim. - Narrow ComponentIdentifier usages to specific typed identifiers where appropriate; promote score_aggregator and seed data_type into identity. - Documentation and docstrings converted to MyST double-backtick style. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
romanlutz
approved these changes
Jun 15, 2026
- Export get_known_capabilities from pyrit.prompt_target; update target docs to use it - Use pyrit.backend.models / pyrit.models roots in converter and target mappers Co-authored-by: Copilot <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.
A
ComponentIdentifieralready carries everything that identifies a target / converter / scorer / attack:class_name,class_module, behavioral params, and child identifiers. But every consumer read that data by poking identifier.params["temperature"] by string key, and the backend re-derived the same shapes by hand into loosely-typed per-kind dicts inside mappers. These are really strongly-typed identifiers and now live inpyrit.models.identifiersas such, so any consumer can read (and construct) them with types.Phase 19 of pyrit.models refactor: https://gist.github.com/rlundeen2/3e8daa8e12a11b4b6e52587b3c9b1dca