diff --git a/.github/instructions/scenarios.instructions.md b/.github/instructions/scenarios.instructions.md index fb6f412045..b2db9971f4 100644 --- a/.github/instructions/scenarios.instructions.md +++ b/.github/instructions/scenarios.instructions.md @@ -199,6 +199,11 @@ Options: before overrides, validation, and preparation. Do not rewrite user selections in validators. - Declare `DATASET_OPTIONS` (or parameter-aware `get_dataset_options()`): `ANY` only for generic named populations, `SUBSET` for approved alternatives, `FIXED` for ingredients. + The base `get_dataset_options()` reports `FIXED` for inline `seeds` / `seed_groups`, since + named sources can't replace them; keep that in an override. Their limits and filters keep + the declared capabilities. Set `min_selected` + when a scenario has no default sources and can't run without one, so clients mark the + selection required instead of checking the scenario name. Disable limits that would truncate ingredients. Compound source edits are ambiguous; preserve child shaping/caps and allow only supported global edits. - Estimates expose `dataset_defaults`, `effective_datasets`, and `dataset_options`. diff --git a/doc/gui/0_gui.md b/doc/gui/0_gui.md index 8c1760e39e..1cb7b3b5b9 100644 --- a/doc/gui/0_gui.md +++ b/doc/gui/0_gui.md @@ -124,6 +124,15 @@ Each scenario defines a test workflow with its techniques, data, and scoring. Open one to select a target and adjust the settings it supports, such as techniques, dataset selection, and concurrency. +**Browse datasets** in the Datasets section header opens the dataset catalog in a +new tab. **Reset datasets** returns the datasets and the per-dataset limit to the +scenario's defaults, and appears once you change them. To open a scanner with +datasets already selected, add one `dataset` parameter per name, for example +`/scanner/launch/foundry.red_team_agent?dataset=harmbench&dataset=my_dataset`. The +names replace the default or preset datasets; other dataset settings, such as +limits and filters, stay. A scenario that can't take the linked datasets won't +launch with them and offers a link to open it without them. + Use the chevron on the right of a technique to inspect its identity JSON. This does not change the checkbox selection on the left. @@ -258,7 +267,8 @@ for shared behavior. Browse datasets already loaded into backend memory. Open a dataset to inspect its examples, search text, or filter by seed type. Supported media can be -previewed on request. +previewed on request. The **Origins** filter lists datasets whose seeds came from +a given origin, such as local files or a remote provider. Use **Import into Chat** to stage an example directly into Chat without copying text or reattaching files: diff --git a/doc/scanner/0_scanner.md b/doc/scanner/0_scanner.md index 4de563f5f5..043af06bf0 100644 --- a/doc/scanner/0_scanner.md +++ b/doc/scanner/0_scanner.md @@ -41,6 +41,12 @@ from ambient environment variables. A configured deterministic objective scorer needs no scoring model; techniques without generation need no adversarial model. See [scan targets](../code/setup/0_setup.md#scan-targets) for setup options. +Select named datasets with `--datasets [ ...]`. For example, +`foundry.assert_policy` has no default datasets: if it reports "Select a dataset.", +pass the names of stored ASSERT datasets with `--datasets`. Create groups with +`AssertGenerator` and store them with `AssertProvider` as shown in the +[ASSERT generation guide](../code/executor/7_promptgen.ipynb). + ### Connecting to CoPyRIT Point a local configuration file at the remote backend: diff --git a/frontend/e2e/numeric-controls.spec.ts b/frontend/e2e/numeric-controls.spec.ts index 5d1213f5e0..704082d6ae 100644 --- a/frontend/e2e/numeric-controls.spec.ts +++ b/frontend/e2e/numeric-controls.spec.ts @@ -253,7 +253,8 @@ test('dataset sources and explicit loading are separate from Parameters', async await section.getByRole('button', { name: 'Edit Maximum objectives' }).click() await total.fill('0') await total.press('Escape') - await section.getByRole('button', { name: 'Reset datasets' }).click() + // Reset clears only source and per-dataset edits, so a total-only edit doesn't offer it. + await expect(section.getByRole('button', { name: 'Reset datasets' })).toHaveCount(0) await expect(section.getByRole('alert')).toContainText('Maximum objectives must be a positive integer') await expect(page.getByRole('button', { name: 'Launch scan', exact: true })).toBeDisabled() await section.screenshot({ path: testInfo.outputPath('datasets-invalid.png') }) @@ -293,8 +294,8 @@ test('dataset rows add immediately, edit in place, share filters, and reset with await page.goto(`/scanner/launch/${SCENARIO.scenario_name}`) const section = page.getByRole('region', { name: 'Datasets', exact: true }) await section.getByRole('combobox', { name: 'Add dataset' }).click() - await page.getByRole('option', { name: 'custom_objectives (user)', exact: true }).click() - await expect(section.getByText('custom_objectives (user)', { exact: true })).toBeVisible() + await page.getByRole('option', { name: 'custom_objectives (User)', exact: true }).click() + await expect(section.getByText('custom_objectives (User)', { exact: true })).toBeVisible() await section.getByRole('button', { name: 'Remove harmbench' }).click() await expect(section.getByRole('button', { name: 'Load datasets' })).toHaveCount(0) await section.getByRole('button', { name: 'Edit custom_objectives objective limit' }).click() @@ -304,9 +305,10 @@ test('dataset rows add immediately, edit in place, share filters, and reset with await section.getByRole('button', { name: 'Filter data type Image' }).click() await expect(section.getByRole('button', { name: 'Filter data type Text' })).toHaveAttribute('aria-pressed', 'true') await expect(section.getByRole('link', { name: 'Browse datasets' })).toHaveAttribute('href', '/datasets') + await expect(section.getByRole('link', { name: 'Browse datasets' })).toHaveAttribute('target', '_blank') await expect(section.getByText('Filters:', { exact: true })).toHaveCount(0) await section.getByRole('button', { name: 'Reset datasets' }).click() - await expect(section.getByText('harmbench (unknown)', { exact: true })).toBeVisible() + await expect(section.getByText('harmbench (Unknown)', { exact: true })).toBeVisible() await expect(section.getByRole('button', { name: 'Load datasets' })).toBeVisible() await expect(section.getByRole('button', { name: 'Remove type filter text' })).toHaveCount(0) }) @@ -345,7 +347,7 @@ test('dataset refresh requires preview confirmation and warns before replacing u await page.getByRole('combobox', { name: 'Objective Target', exact: true }).selectOption('mock-target') const section = page.getByRole('region', { name: 'Datasets', exact: true }) await section.getByRole('combobox', { name: 'Add dataset' }).click() - await page.getByRole('option', { name: 'custom_objectives (user)', exact: true }).click() + await page.getByRole('option', { name: 'custom_objectives (User)', exact: true }).click() await section.getByRole('button', { name: 'Remove harmbench' }).click() await section.getByRole('radio', { name: 'Refresh', exact: true }).check() await expect(section.getByRole('radio', { name: 'Refresh', exact: true })).toBeChecked() diff --git a/frontend/e2e/scenario-datasets.spec.ts b/frontend/e2e/scenario-datasets.spec.ts index 68a47abcb5..98b9a724d1 100644 --- a/frontend/e2e/scenario-datasets.spec.ts +++ b/frontend/e2e/scenario-datasets.spec.ts @@ -215,11 +215,11 @@ test('configures, saves, refreshes, estimates without a target, and launches the const search = page.getByRole('combobox', { name: 'Add dataset', exact: true }) await search.focus() await search.pressSequentially('SEARCHABLE') - await expect(page.getByRole('listbox').getByRole('option')).toHaveText(['acceptance_searchable (local)']) + await expect(page.getByRole('listbox').getByRole('option')).toHaveText(['acceptance_searchable (Local files)']) await capture(page, testInfo, 'dataset-search-keyboard', search) await search.press('ArrowDown') await search.press('Enter') - await expect(page.getByRole('row').filter({ hasText: 'acceptance_searchable (local)' })).toBeVisible() + await expect(page.getByRole('row').filter({ hasText: 'acceptance_searchable (Local files)' })).toBeVisible() await setLimit(page, 'acceptance_primary objective limit', '3') await setLimit(page, 'acceptance_searchable objective limit', '1') await setLimit(page, 'Maximum objectives', '4') diff --git a/frontend/src/components/Datasets/DatasetCatalog.test.tsx b/frontend/src/components/Datasets/DatasetCatalog.test.tsx index 6b53104af1..86b42f759e 100644 --- a/frontend/src/components/Datasets/DatasetCatalog.test.tsx +++ b/frontend/src/components/Datasets/DatasetCatalog.test.tsx @@ -577,6 +577,26 @@ describe('DatasetCatalog', () => { expect(screen.getByRole('link', { name: '(unnamed)' })).toBeInTheDocument() }) + it('filters to generated datasets from the origin control', async () => { + const user = userEvent.setup() + mockCatalog([ + makeDataset({ name: 'support_policy', selection_key: 'dataset:named:support_policy', origins: ['generated'] }), + makeDataset({ name: 'harmbench', selection_key: 'dataset:named:harmbench', origins: ['remote'] }), + ]) + render() + await screen.findByRole('link', { name: 'support_policy' }) + + await user.click(screen.getByTestId('dataset-origin-filter')) + expect(await screen.findByRole('menuitemcheckbox', { name: 'Remote provider' })).toBeInTheDocument() + await user.click(screen.getByRole('menuitemcheckbox', { name: 'Generated' })) + + expect(currentUrl().searchParams.getAll('origin')).toEqual(['generated']) + expect(screen.getByRole('link', { name: 'support_policy' })).toBeInTheDocument() + expect(screen.queryByRole('link', { name: 'harmbench' })).not.toBeInTheDocument() + await user.keyboard('{Escape}') + expect(screen.getByTestId('dataset-origin-filter')).toHaveValue('Origins: Generated') + }) + it('reaches search, clear, and the dataset link from the keyboard', async () => { const user = userEvent.setup() render() diff --git a/frontend/src/components/Datasets/DatasetCatalog.tsx b/frontend/src/components/Datasets/DatasetCatalog.tsx index 37d4ca7788..6e94fc7162 100644 --- a/frontend/src/components/Datasets/DatasetCatalog.tsx +++ b/frontend/src/components/Datasets/DatasetCatalog.tsx @@ -14,6 +14,7 @@ import { import { SearchRegular } from '@fluentui/react-icons' import { useLocation, useNavigate, useSearchParams } from 'react-router' +import { datasetOriginLabel } from '@/components/Scenarios/datasetPresentation' import SearchableMultiCombobox from '@/components/SearchableMultiCombobox' import { useLoadedDatasets } from '@/hooks/useLoadedDatasets' import type { DatasetInfo, FilterOption } from '@/types' @@ -61,6 +62,14 @@ function harmOptions(datasets: readonly DatasetInfo[], view: DatasetCatalogQuery return uniqueLabels(values) } +function originOptions(datasets: readonly DatasetInfo[]): FilterOption[] { + const values = new Set() + for (const dataset of datasets) for (const origin of dataset.origins ?? []) values.add(origin) + return [...values] + .map((value) => ({ value, label: datasetOriginLabel(value) })) + .sort((left, right) => left.label.localeCompare(right.label, 'en', { sensitivity: 'base' })) +} + /** Stored datasets and available providers share URL-backed views and filters. */ export default function DatasetCatalog() { const styles = useDatasetCatalogStyles() @@ -87,6 +96,7 @@ export default function DatasetCatalog() { const selectedModalities = [...new Set(query.modalities.map( (modality: string) => normalizeDatasetModality(modality, modalityAliases), ))] + const origins = useMemo(() => originOptions(viewDatasets), [viewDatasets]) const filtersActive = !catalogQueryIsDefault({ ...query, view: 'memory' }) const updateQuery = (next: DatasetCatalogQuery): void => { @@ -116,7 +126,7 @@ export default function DatasetCatalog() { {view === 'memory' ? 'Filters describe stored seeds. Not labeled means stored seeds without harm categories.' - : 'Filters use provider declarations for built-ins and stored values for other datasets. Not labeled applies only to stored values.'} + : 'Filters use provider declarations for built-ins and stored values for other datasets. Origins and Not labeled apply only to stored values.'}
@@ -166,6 +176,16 @@ export default function DatasetCatalog() { onChange={(_, data) => updateQuery({ ...query, unlabeled: data.checked === true })} label="Not labeled" /> + updateQuery({ ...query, origins: selected })} + testId="dataset-origin-filter" + />