-
Notifications
You must be signed in to change notification settings - Fork 806
MAINT: Migrate FlipAttack to a core 'flip' attack technique #2178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rlundeen2
merged 5 commits into
microsoft:main
from
rlundeen2:rlundeen2-migrate-flip-attack
Jul 14, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
169a7df
MAINT: Migrate FlipAttack to a core 'flip' attack technique
rlundeen2 ecda85a
Merge origin/main into flip migration
rlundeen2 d5426a1
MAINT: Drop the flip worked-example from setup-techniques instructions
rlundeen2 b124eb8
DOC: Document TaskFramingConverter and drop the flip note from framew…
rlundeen2 ea1620d
Merge origin/main into flip migration
rlundeen2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| applyTo: "pyrit/setup/initializers/techniques/**" | ||
| --- | ||
|
|
||
| # Setup Technique Catalog Guidelines | ||
|
|
||
| **Responsibility**: This directory is the canonical catalog of `AttackTechniqueFactory` | ||
| instances — the declarative "which attack, configured how" entries that scenarios select by | ||
| name. Each group module (`core.py`, `extra.py`) exposes `get_technique_factories()`; | ||
| `technique_initializer.py` aggregates the groups, injects the group name as a technique tag, | ||
| and registers them into the `AttackTechniqueRegistry`. | ||
|
|
||
| **Does not own** (see [framework.md](../../doc/code/framework.md)): attack algorithms, | ||
| converters, scorers, or datasets. A factory only *packages* existing bricks as configuration. | ||
| If an entry needs new branching, prompt scaffolding, or transformation logic, that logic | ||
| belongs in an attack / converter / scorer — not here. See also | ||
| [scenarios.instructions.md](scenarios.instructions.md) for the `AttackTechniqueFactory` API. | ||
|
|
||
| ## Define factories inline | ||
|
|
||
| Define each `AttackTechniqueFactory` **inline** in the `get_technique_factories()` list, not in | ||
| a per-technique `_build_<name>_technique()` helper. A factory is declarative configuration, so | ||
| keeping every entry in the one list makes the whole catalog readable at a glance. | ||
|
|
||
| **No module-level constants or helper functions for factory arguments.** Do not hoist a | ||
| factory's arguments — YAML paths, turn counts, converter stacks, path-building helpers like | ||
| `_role_play_yaml(name)`, or numeric constants like `ROLE_PLAY_SIMULATED_NUM_TURNS` — into | ||
| module-level names or functions. Even when several factories repeat the same literal (e.g. the | ||
| same `next_message_system_prompt_path` or `num_turns=2`), write the literal inline in each entry. | ||
| Repetition here is intentional: it keeps every factory self-contained and readable at a glance, | ||
| and it is the single most common thing that gets "snuck back in" during a refactor. If you catch | ||
| yourself extracting a `_CONSTANT`, a `_build_*`/`_*_yaml` helper, or a shared config object, | ||
| stop — put the value back inline. | ||
|
|
||
| - If an entry needs a few lines of setup (a `seed_technique`, a converter stack), prefer a | ||
| reusable model/config constructor over a bespoke module-level builder — e.g. | ||
| `AttackTechniqueSeedGroup.from_system_prompt(...)` for a system-prompt technique. If you find | ||
| yourself writing a builder, consider whether the reusable piece belongs on the model instead. | ||
| - Reach for a helper function **only** when construction is genuinely dynamic (e.g. a | ||
| `@cache`-decorated builder for a dynamically-enumerated set of techniques). A helper that just | ||
| concatenates a path or returns a fixed literal does not qualify — inline it. | ||
| - Keep entries free of long explanatory comments and paper citations. The factory should read as | ||
| plain configuration; if a technique's mechanics are subtle, document them on the reusable | ||
| converter/model it uses, or here in this file, not as an inline comment block. |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.