Skip to content

[BREAKING] FEAT: Make scenario dataset sources and limits explicit - #2956

Open
Richard Lundeen (richlundeen) wants to merge 5 commits into
microsoft:mainfrom
richlundeen:richlundeen-update-scenario-dataset-proposal
Open

Richard Lundeen (richlundeen) wants to merge 5 commits into
microsoft:mainfrom
richlundeen:richlundeen-update-scenario-dataset-proposal

Conversation

@richlundeen

Copy link
Copy Markdown
Contributor

Description

Scenario dataset preparation and limits need clear, consistent rules so overrides do not change fetch policies or remove unrelated caps. This implements the next step in the dataset-generation proposal.

Adds named dataset sources, explicit preparation, and separate source and total limits while keeping dataset reads free of fetching. Uses one limit contract across Python, CLI, API, and GUI: omitted, None, empty, and "default" use defaults; "all" removes the specified cap. Migrates built-in scenarios and preserves retained source settings during overrides; changing None from unlimited to default is a breaking change.

Tests and Documentation

Added regression coverage for preparation, selection, overrides, limit normalization, request persistence, and GUI controls. Updated scenario guidance and paired scenario/scanner notebooks.

Validation commands and results
  • $env:UV_NO_SYNC = '1'; uv run --no-sync pre-commit run --all-files — passed all hooks, including full Python type checking.
  • uv run --no-sync pytest tests\unit\scenario tests\unit\models\test_scenario_request.py tests\unit\models\test_import_boundary.py tests\unit\backend\test_scenario_configuration_resolver.py tests\unit\backend\test_scenario_service.py tests\unit\backend\test_scenario_run_service.py tests\unit\backend\test_scenario_resume.py tests\unit\cli\test_cli_args.py tests\unit\cli\test_pyrit_scan.py tests\unit\cli\test_pyrit_shell.py tests\unit\cli\test_api_client.py -q -n 4 --tb=short --disable-warnings — 2,252 passed.
  • From frontend: npm run type-check -- --pretty false — passed.
  • From frontend: npm test -- --runInBand --silent src\components\Scenarios\ScenarioDetail.test.tsx — 65 passed.

Jupytext cell comparison confirmed that both changed .py/.ipynb pairs match. Notebooks were not executed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve latent-injection test coverage with an explicit total limit while preserving default and all-limit behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use explicit dataset sources and max_total=all for the complete latent-injection population check.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@hannahwestra25 hannahwestra25 self-assigned this Oct 7, 2026
Comment thread pyrit/scenario/scenarios/benchmark/adversarial.py Outdated
Preserve upstream request bounds alongside explicit dataset limits. Increment the benchmark version to 7 for independent named-source sampling.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread pyrit/backend/services/scenario_configuration_resolver.py Outdated
Comment thread pyrit/scenario/scenarios/airt/psychosocial.py
Comment thread pyrit/scenario/core/dataset_configuration.py Outdated
Comment thread pyrit/scenario/core/dataset_configuration.py Outdated
Comment thread .github/instructions/scenarios.instructions.md
Comment thread pyrit/scenario/core/dataset_configuration.py
Comment thread .github/instructions/scenarios.instructions.md Outdated
Remove sampling_scope, retain empty dataset keys, and preserve Psychosocial sub-harm coverage within the total cap. Update scenario guidance and adjust the merged adaptive run-plan test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment on lines 380 to 382
if not isinstance(max_dataset_size, _Unset):
if not isinstance(max_total, _Unset):
raise ValueError("Use only one of 'max_dataset_size' and 'max_total'.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_dataset_size=10 with one dataset gives 10 on main but 5 here, bc max_per_dataset still defaults to 5. None went from unlimited to 5 too. the warning just says rename, so no one will catch it. can we set max_per_dataset="all" here

Comment on lines +495 to +497
raise DatasetConstraintError(
f"Psychosocial max_total ({cap}) must cover every selected sub-harm "
f"({len(self._selected_sub_harms())}); use max_per_dataset=1 for one objective per sub-harm."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check is cap < len(sub_harms), so max_per_dataset=1 doesn't change it. and the backend resolver only takes max_dataset_size, so you can't even set it there. maybe say bump max_total or pick fewer sub-harms?

@hannahwestra25 hannahwestra25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ghcp found :
doc/scanner/garak.py:602 uses dataset_names=, which is deprecated now. and the line below still has max_dataset_size. those are pre-existing, but since we're already in this file could we migrate them? otherwise the docs teach the old way.

so double check that all the docs have been updated

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants