Skip to content

Commit 2ae2986

Browse files
authored
Merge branch 'main' into refcheck-citations
2 parents 6998ebf + aaff32c commit 2ae2986

279 files changed

Lines changed: 2380 additions & 7164 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/instructions/attacks.instructions.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ Requirements:
3737
raise `TypeError` at import time.
3838
- ``super().__init__(...)`` must be invoked with at minimum
3939
``objective_target`` and ``context_type``.
40-
- Existing subclasses that cannot adopt the contract immediately may set
41-
the class attribute ``_brick_legacy_init = True`` to opt into a
42-
one-release grace period that downgrades the error to a
43-
``DeprecationWarning(removed_in="0.16.0")``. The opt-out is removed in
44-
0.16.0; classes that still violate the contract at that point will hard
45-
fail.
4640
- ``AttackTechniqueFactory`` already rejects ``**kwargs`` in attack
4741
``__init__`` at factory-registration time
4842
(`pyrit/scenario/core/attack_technique_factory.py`); the new

.github/instructions/converters.instructions.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,6 @@ It rejects:
106106
def __init__(self, foo: str, bar: int = 0) -> None: ... # missing *
107107
```
108108

109-
### Temporary opt-out: ``_brick_legacy_init``
110-
111-
A handful of legacy converters whose positional ``__init__`` is part of the
112-
public API are grandfathered with ``_brick_legacy_init = True``. They
113-
emit a ``DeprecationWarning`` at import time and the opt-out is scheduled
114-
for removal in **0.16.0**. Do not set this flag on new converters; new
115-
converters MUST follow the keyword-only contract.
116-
117-
Currently grandfathered (slated for cleanup in 0.16.0):
118-
``AddImageVideoConverter``, ``AnsiAttackConverter``, ``AsciiArtConverter``,
119-
``AskToDecodeConverter``, ``DiacriticConverter``, ``InsertPunctuationConverter``,
120-
``PDFConverter``, ``QRCodeConverter``, ``RandomCapitalLettersConverter``,
121-
``SearchReplaceConverter``, ``SmugglerConverter`` (and its three subclasses).
122-
123109
## Exports and External Updates
124110

125111
- New converters MUST be added to `pyrit/prompt_converter/__init__.py` — both the import and the `__all__` list.

.github/instructions/datasets.instructions.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ Style rules from `style-guide.instructions.md` (async `_async` suffix, keyword-o
1414
The keyword-only `__init__` rule is **enforced at class-definition time** by
1515
`SeedDatasetProvider.__init_subclass__` calling `enforce_keyword_only_init` (see
1616
`pyrit/common/brick_contract.py`). Loaders with positional `__init__` params raise
17-
`TypeError` at import time; existing offenders may set `_brick_legacy_init = True`
18-
to opt into a one-release grace period that downgrades the error to a
19-
`DeprecationWarning(removed_in="0.16.0")`.
17+
`TypeError` at import time.
2018

2119
## Use SeedObjective for behavior/goal rows; SeedPrompt for literal messages
2220

.github/instructions/scenarios.instructions.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ Requirements:
7676
- All parameters keyword-only via `*`**enforced at class-definition time** by
7777
`Scenario.__init_subclass__` calling `enforce_keyword_only_init` (see
7878
`pyrit/common/brick_contract.py`). Violators raise `TypeError` at
79-
import time. Existing classes that cannot adopt the contract immediately
80-
may opt into a one-release grace period via the class attribute
81-
`_brick_legacy_init = True`, which downgrades the error to a
82-
`DeprecationWarning(removed_in="0.16.0")`. The opt-out is removed in 0.16.0.
79+
import time.
8380
- **All constructor parameters must be optional** (default to `None`) so the registry can instantiate the scenario with no arguments for metadata introspection. Defer required-input validation to `initialize_async()` or `_build_atomic_attacks_async()`. `ScenarioRegistry._build_metadata` raises `TypeError` if `scenario_class()` cannot be called with no arguments.
8481
- `super().__init__()` called with `version`, `strategy_class`, `default_strategy`, `default_dataset_config`, `objective_scorer`
8582
- complex objects like `adversarial_chat` or `objective_scorer` should be passed into the constructor.
@@ -256,8 +253,8 @@ under `max_dataset_size`.
256253

257254
```python
258255
AtomicAttack(
259-
atomic_attack_name=strategy_name, # must be unique per AtomicAttack
260-
attack=attack_instance, # AttackStrategy implementation
256+
atomic_attack_name=strategy_name, # groups related attacks
257+
attack_technique=AttackTechnique(attack=attack_instance), # bundles the AttackStrategy
261258
seed_groups=list(seed_groups), # must be non-empty
262259
memory_labels=context.memory_labels, # from the context snapshot
263260
)

.github/instructions/scorers.instructions.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,6 @@ Requirements:
3737
- ``super().__init__(validator=..., chat_target=...)`` is required so the
3838
base class wires the validator and validates ``TARGET_REQUIREMENTS``
3939
against any provided ``chat_target``.
40-
- Existing subclasses that cannot adopt the contract immediately may set
41-
the class attribute ``_brick_legacy_init = True`` to opt into a
42-
one-release grace period that downgrades the error to a
43-
``DeprecationWarning(removed_in="0.16.0")``. The opt-out is removed in
44-
0.16.0; classes that still violate the contract at that point will hard
45-
fail.
46-
47-
### Currently grandfathered
48-
49-
- ``PlagiarismScorer`` (``pyrit/score/float_scale/plagiarism_scorer.py``) —
50-
accepts ``reference_text`` positionally as part of its public API. The
51-
positional shape is preserved through one release cycle via
52-
``_brick_legacy_init = True`` and is scheduled to become
53-
keyword-only in 0.16.0 (``BREAKING CHANGE``).
5440

5541
## Common pitfalls
5642

.github/instructions/style-guide.instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ package without paying the cost at package load time. See
181181
Import from the package root when the symbol is exported from `__init__.py`:
182182

183183
```python
184-
from pyrit.prompt_target import PromptChatTarget # CORRECT
185-
from pyrit.prompt_target.common.prompt_chat_target import PromptChatTarget # WRONG
184+
from pyrit.prompt_target import PromptTarget # CORRECT
185+
from pyrit.prompt_target.common.prompt_target import PromptTarget # WRONG
186186
```
187187

188188
Heavy submodules not re-exported from `__init__.py` are imported directly:

.github/instructions/targets.instructions.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,9 @@ def __init__(self, endpoint: str, api_key: str) -> None: ... # missing *
6565
```
6666

6767
> [!NOTE]
68-
> ``PromptTarget.__init__`` *itself* still accepts positional parameters and
69-
> is not currently keyword-only. The ``__init_subclass__`` hook only runs for
70-
> subclasses, so the base class non-compliance is tolerated during the warn-
71-
> first phase. The base ``__init__`` will be reshaped to be keyword-only in
72-
> 0.16.0 as a BREAKING CHANGE.
73-
74-
## Temporary opt-out: ``_brick_legacy_init``
75-
76-
A handful of legacy targets whose positional ``__init__`` is part of the
77-
public API are grandfathered with ``_brick_legacy_init = True``. They
78-
emit a ``DeprecationWarning`` at import time and the opt-out is scheduled
79-
for removal in **0.16.0**. Do not set this flag on new targets; new
80-
targets MUST follow the keyword-only contract.
81-
82-
Currently grandfathered (slated for cleanup in 0.16.0):
83-
``HTTPTarget``, ``OpenAICompletionTarget``, ``OpenAIImageTarget``,
84-
``PromptShieldTarget``.
68+
> ``PromptTarget.__init__`` *itself* is now keyword-only as well (``*`` after
69+
> ``self``), so both the base class and its subclasses enforce the same
70+
> contract.
8571
8672
## Configuration and Capabilities
8773

doc/code/executor/2_multi_turn.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
" RedTeamingAttack,\n",
234234
" RTASystemPromptPaths,\n",
235235
")\n",
236+
"from pyrit.models import SeedPrompt\n",
236237
"from pyrit.score import SelfAskTrueFalseScorer, TrueFalseQuestion\n",
237238
"\n",
238239
"scoring_config = AttackScoringConfig(\n",
@@ -246,7 +247,7 @@
246247
" objective_target=objective_target,\n",
247248
" attack_adversarial_config=AttackAdversarialConfig(\n",
248249
" target=adversarial_chat,\n",
249-
" system_prompt_path=RTASystemPromptPaths.TEXT_GENERATION.value,\n",
250+
" system_prompt=SeedPrompt.from_yaml_file(RTASystemPromptPaths.TEXT_GENERATION.value),\n",
250251
" ),\n",
251252
" attack_scoring_config=scoring_config,\n",
252253
" max_turns=2,\n",

doc/code/executor/2_multi_turn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
RedTeamingAttack,
8484
RTASystemPromptPaths,
8585
)
86+
from pyrit.models import SeedPrompt
8687
from pyrit.score import SelfAskTrueFalseScorer, TrueFalseQuestion
8788

8889
scoring_config = AttackScoringConfig(
@@ -96,7 +97,7 @@
9697
objective_target=objective_target,
9798
attack_adversarial_config=AttackAdversarialConfig(
9899
target=adversarial_chat,
99-
system_prompt_path=RTASystemPromptPaths.TEXT_GENERATION.value,
100+
system_prompt=SeedPrompt.from_yaml_file(RTASystemPromptPaths.TEXT_GENERATION.value),
100101
),
101102
attack_scoring_config=scoring_config,
102103
max_turns=2,

doc/code/executor/3_attack_configuration.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@
471471
" RedTeamingAttack,\n",
472472
" RTASystemPromptPaths,\n",
473473
")\n",
474+
"from pyrit.models import SeedPrompt\n",
474475
"from pyrit.prompt_target import OpenAIChatTarget, OpenAIImageTarget\n",
475476
"from pyrit.score import SelfAskTrueFalseScorer, TrueFalseQuestion\n",
476477
"\n",
@@ -482,7 +483,7 @@
482483
"# Adversarial config: an unfiltered chat model drafts each image prompt, primed for image generation.\n",
483484
"adversarial_config = AttackAdversarialConfig(\n",
484485
" target=OpenAIChatTarget(),\n",
485-
" system_prompt_path=RTASystemPromptPaths.IMAGE_GENERATION.value,\n",
486+
" system_prompt=SeedPrompt.from_yaml_file(RTASystemPromptPaths.IMAGE_GENERATION.value),\n",
486487
")\n",
487488
"\n",
488489
"# Scoring config: a vision-capable model inspects the generated image and scores the objective.\n",

0 commit comments

Comments
 (0)