Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pyrit/scenario/scenarios/garak/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class DoctorStrategy(ScenarioStrategy):
ALL = ("all", {"all"})
DEFAULT = ("default", {"default"})

# Concrete strategies (values match the technique factory names)
# Concrete strategies (values match the technique factory names). Both are tagged
# "default", so DEFAULT and ALL coincide today; ALL exists so a future non-default
# technique would diverge from DEFAULT without another default-strategy change.
PolicyPuppetry = ("policy_puppetry", {"default"})
PolicyPuppetryLeet = ("policy_puppetry_leet", {"default"})

Expand Down Expand Up @@ -134,7 +136,7 @@ def __init__(
super().__init__(
version=self.VERSION,
strategy_class=DoctorStrategy,
default_strategy=DoctorStrategy.ALL,
default_strategy=DoctorStrategy.DEFAULT,
default_dataset_config=DatasetAttackConfiguration(dataset_names=["garak_doctor"]),
objective_scorer=objective_scorer,
scenario_result_id=scenario_result_id,
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/scenario/garak/test_doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def test_default_dataset_config_uses_garak_doctor(self, mock_objective_scorer):
config = Doctor(objective_scorer=mock_objective_scorer)._default_dataset_config
assert config.dataset_names == ["garak_doctor"]

def test_default_strategy_is_default(self, mock_objective_scorer):
scenario = Doctor(objective_scorer=mock_objective_scorer)
assert scenario._default_strategy == DoctorStrategy.DEFAULT


@pytest.mark.usefixtures("patch_central_database")
class TestDoctorTechniqueFactories:
Expand Down Expand Up @@ -135,12 +139,26 @@ def test_policy_puppetry_leet_wires_both_converters(self, mock_objective_target,
class TestDoctorStrategyExpansion:
"""Tests for Doctor strategy expansion and atomic attack generation."""

async def test_default_expands_to_concrete_strategies(
self, mock_objective_target, mock_objective_scorer, doctor_dataset_config
):
"""No explicit strategies -> DEFAULT -> both Policy Puppetry techniques."""
scenario = Doctor(objective_scorer=mock_objective_scorer)
await scenario.initialize_async(
objective_target=mock_objective_target,
dataset_config=doctor_dataset_config,
)

strategy_values = {s.value for s in scenario._scenario_strategies}
assert strategy_values == {"policy_puppetry", "policy_puppetry_leet"}

async def test_all_expands_to_concrete_strategies(
self, mock_objective_target, mock_objective_scorer, doctor_dataset_config
):
scenario = Doctor(objective_scorer=mock_objective_scorer)
await scenario.initialize_async(
objective_target=mock_objective_target,
scenario_strategies=[DoctorStrategy.ALL],
dataset_config=doctor_dataset_config,
)

Expand Down
Loading