Skip to content

The open-source app everyone uses to manage agents at work

feat(runner-e2e): publish declared screenshots (#12895)

Dotta87832c48fda5
diff --git a/.github/workflows/runner-full-stack-e2e.yml b/.github/workflows/runner-full-stack-e2e.yml
index 3250469823..0c4fa59387 100644
--- a/.github/workflows/runner-full-stack-e2e.yml
+++ b/.github/workflows/runner-full-stack-e2e.yml
@@ -1132,7 +1132,7 @@ jobs:
fi
publish_history:
- name: Publish trusted-summary S3 history and structured Pages bundle
+ name: Publish S3 history and Pages bundle with declared screenshots
needs: [authorize, catalog, report]
if: always() && needs.catalog.result == 'success' && needs.report.outputs.history_source_ready == 'true'
runs-on: ubuntu-latest
@@ -1183,7 +1183,7 @@ jobs:
role-to-assume: ${{ vars.RUNNER_E2E_HISTORY_AWS_ROLE_ARN }}
aws-region: ${{ vars.RUNNER_E2E_HISTORY_AWS_REGION }}
- - name: Publish trusted summary image to S3 and prune the Pages bundle
+ - name: Publish trusted summary and declared screenshots to public bundles
env:
PAPERCLIP_RUNNER_E2E_REPORT_DIR: ${{ github.workspace }}/runner-e2e-merged-report/normalized
RUNNER_E2E_HISTORY_S3_BUCKET: ${{ vars.RUNNER_E2E_HISTORY_S3_BUCKET }}
@@ -1196,7 +1196,7 @@ jobs:
if: vars.RUNNER_FULL_STACK_E2E_PUBLISH_PAGES == 'true'
run: echo "name=github-pages-${{ github.run_id }}-${{ github.run_attempt }}" >> "$GITHUB_OUTPUT"
- - name: Package structured-only dashboard for GitHub Pages
+ - name: Package pruned dashboard with declared screenshots for GitHub Pages
if: vars.RUNNER_FULL_STACK_E2E_PUBLISH_PAGES == 'true'
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4
with:
@@ -1204,7 +1204,7 @@ jobs:
path: runner-e2e-merged-report/pages
pages:
- name: Publish latest structured dashboard
+ name: Publish latest dashboard with declared screenshots
needs: [report, publish_history]
if: always() && needs.report.outputs.history_source_ready == 'true' && needs.publish_history.result == 'success' && vars.RUNNER_FULL_STACK_E2E_PUBLISH_PAGES == 'true'
runs-on: ubuntu-latest
diff --git a/tests/runner-e2e/README.md b/tests/runner-e2e/README.md
index cbf336f459..ed9fed5caa 100644
--- a/tests/runner-e2e/README.md
+++ b/tests/runner-e2e/README.md
@@ -189,10 +189,11 @@ Packaged, access-controlled evidence is written beneath
outcomes, sanitized fixture/API metadata, a result record, JUnit, HTML, and a
blob report. Failures additionally retain the Playwright trace/video, browser
diagnostics, failure screenshot, and sanitized Paperclip/run logs when
-produced. Provider/UI PNG and WebM files remain limited to the local results
-directory and access-controlled GitHub Actions artifact because secrets can be
-rendered into pixels. SVG is active content and is rejected from the packaged
-evidence entirely.
+produced. WebM files remain limited to the local results directory and
+access-controlled GitHub Actions artifact. Declared PNG screenshots are also
+published with permanent campaign dashboards; fixture authors must therefore
+keep credentials and other private data out of every captured UI state. SVG is
+active content and is rejected from the packaged evidence entirely.
Every completed local campaign also writes
`tests/runner-e2e/results/<campaign>/dashboard.html`. The self-contained page
@@ -205,22 +206,30 @@ usage is labeled `unavailable` or `unpriced`; it is never presented as zero
cost. The CI report job stages the same portable site at
`normalized/index.html` inside the access-controlled merged report artifact.
-Permanent publication uses two explicit bundles. The CloudFront-backed S3
-history contains one publisher-generated `public-images/campaign-summary.png`.
+Permanent publication uses two explicit bundles. Both retain only normalized
+result PNG files with the explicit `public-runner-fixture` publication marker,
+including marked `failure.png` captures, so every campaign dashboard has its
+screenshot thumbnails and gallery. The capture helper adds this marker only
+for the reviewed runner fixture and blocks public capture outside the exact
+issue route for the fixture that the harness created. A blocked failure capture
+remains private. The CloudFront-backed S3
+history also contains one publisher-generated
+`public-images/campaign-summary.png`.
Trusted publisher code renders it offline from fixed catalog labels and
sanitized status/count/duration fields; provider output, error text, comments,
and target-produced pixels are never inputs. The PNG must pass a 12 MiB bound
and signature validation before entering the immutable manifest. S3 also
retains allowlisted inert per-attempt evidence (`.json`, `.log`, `.md`, and
`.txt`); `.log` copies have already passed exact-value/key-shape scanning and
-redaction. The GitHub Pages bundle is regenerated separately and remains
-structured-only.
+redaction. The GitHub Pages bundle is regenerated separately with the same
+declared-screenshot boundary.
Both public bundles exclude video, archives, raw/unallowlisted logs, SVG or
other active content, generated Playwright/blob/HTML report trees, and
-per-attempt XML. The root `junit.xml` remains public because the report
-aggregator builds it from fixed markup and XML-escaped fields. Full evidence
-remains available only in the access-controlled workflow artifact.
+undeclared PNG files, and per-attempt XML. The root `junit.xml` remains public
+because the report aggregator builds it from fixed markup and XML-escaped
+fields. Full evidence remains available only in the access-controlled workflow
+artifact.
### Billing interpretation
@@ -388,9 +397,12 @@ bundle digest fails closed.
GitHub Pages remains the stable latest dashboard. Enable Pages with GitHub
Actions as its source and set `RUNNER_FULL_STACK_E2E_PUBLISH_PAGES=true`.
The publisher creates an S3 stage with the trusted synthetic summary PNG and a
-separate structured-only Pages stage. Neither surface publishes provider/UI
-screenshots, video, archives, generated reports, SVG/active content, databases,
-Paperclip homes, workspaces, raw/unallowlisted logs, or credentials.
+separate Pages stage. Both surfaces publish only per-result PNG screenshots
+with the explicit `public-runner-fixture` marker alongside sanitized structured
+evidence. The runner capture helper refuses to mark a screenshot outside the
+exact live fixture issue route. Neither surface publishes video, archives,
+SVG/active content, databases, Paperclip homes, workspaces, raw/unallowlisted
+logs, or credentials.
See [FIXTURES.md](./FIXTURES.md) before adding or changing a profile,
environment, task, matcher, or future Paperclip object fixture.
diff --git a/tests/runner-e2e/SECURITY.md b/tests/runner-e2e/SECURITY.md
index 06f01adfd4..25a7a87333 100644
--- a/tests/runner-e2e/SECURITY.md
+++ b/tests/runner-e2e/SECURITY.md
@@ -179,26 +179,36 @@ latest pointers are mutable, and S3 versioning makes those updates recoverable.
## Public evidence boundary
CloudFront and GitHub Pages are public. Fixture identifiers, timing, token
-usage, costs, normalized results, and allowlisted inert structured per-attempt
-evidence are expected public data. The CloudFront-backed S3 history also
-publishes one synthetic campaign-summary PNG generated by trusted publisher
-code solely from fixed catalog labels and sanitized numeric/status fields.
-Provider output, comments, error text, and provider/UI screenshots are never
-rendered into it. Video, archives, generated
-Playwright/blob/HTML report trees, SVG or other active content, credentials,
-Paperclip homes, databases, workspaces, master keys, raw/unredacted logs, and
-unallowlisted files are not public. Allowlisted `.log` copies must pass the
-existing exact-value/key-shape scan and redaction boundary.
+usage, costs, normalized results, allowlisted inert structured per-attempt
+evidence, and trusted runner PNG screenshots are expected public data. Each
+public screenshot must carry the explicit `public-runner-fixture` marker in
+the normalized result. This includes a `failure.png` capture. Screenshot paths
+must be safe PNG basenames and must be tied to the exact normalized execution
+ID and attempt. The runner capture helper accepts only the exact issue route
+for the live fixture that the harness created. Other issue routes, credential
+pages, setup pages, and administration pages fail closed. The
+CloudFront-backed S3 history also publishes one
+synthetic campaign-summary PNG generated by trusted publisher code solely from
+fixed catalog labels and sanitized numeric/status fields. Video, archives,
+generated Playwright/blob/HTML report trees, SVG or other active content,
+credentials, Paperclip homes, databases, workspaces, master keys,
+raw/unredacted logs, unmarked images, and unallowlisted files are not public.
+Allowlisted `.log` copies must pass the existing exact-value/key-shape scan and
+redaction boundary.
The packaged evidence uploaded as a 30-day GitHub Actions artifact has a
-different, access-controlled boundary. Text is exact-value and key-shape
-scanned and redacted. PNG and WebM are raw-byte scanned; SVG is rejected during
-packaging because it is active content. A raster image cannot be exhaustively
-secret-scanned by bytes, so every target/provider-produced image remains
-access-controlled and is removed at the public boundary.
+different, broader boundary. Text is exact-value and key-shape scanned and
+redacted. PNG and WebM are raw-byte scanned; SVG is rejected during packaging
+because it is active content. Raster pixels cannot be exhaustively
+secret-scanned by bytes, so fixture authors must treat every marked capture as
+public and must never extend the allowed task route to credentials, secrets,
+private user data, or other non-public content. Adding or changing a marked
+capture requires review of the visible page state. Videos remain
+access-controlled.
Before permanent publication, the campaign publisher creates a separate S3
-stage and retains only allowlisted `.json`, `.log`, `.md`, and `.txt` evidence.
+stage and retains only allowlisted `.json`, `.log`, `.md`, and `.txt` evidence,
+result PNGs with the explicit `public-runner-fixture` marker.
It then launches publisher-only Chromium with networking blocked to render one
`public-images/campaign-summary.png`. That fixed-path PNG is capped at 12 MiB
and its signature is validated. Per-attempt XML is excluded because browsers
@@ -208,10 +218,9 @@ constructs from fixed markup and XML-escaped fields. Videos, archives,
raw/unallowlisted logs, SVG, undeclared images, generated reports, and symlinks
fail closed or are removed before the immutable manifest is calculated.
-GitHub Pages is built from a second structured-only stage without the summary
-PNG. This keeps Pages small while the CloudFront-backed S3 dashboard can show a
-useful visual generated without target content. A leak fails the cell and
-withholds the unsafe file.
+GitHub Pages is built from a second stage without the synthetic summary PNG but
+with the same trusted-fixture screenshot allowlist. A leak detected by the
+existing packager scan fails the cell and withholds the unsafe file.
Rotate the affected credential immediately if a secret-scanning failure or
unexpected public object is observed. Preserve the access-controlled Actions
diff --git a/tests/runner-e2e/dashboard.ts b/tests/runner-e2e/dashboard.ts
index 9a9910fb56..820615ff92 100644
--- a/tests/runner-e2e/dashboard.ts
+++ b/tests/runner-e2e/dashboard.ts
@@ -981,7 +981,7 @@ export function renderRunnerE2EDashboard(input: RunnerDashboardInput) {
<div>
<p class="eyebrow">Full-stack acceptance campaign</p>
<h1>${html(input.title)}</h1>
- <p class="lede">A browser-verified matrix of runner profiles, execution environments, and deterministic task contracts. Visual evidence is retained in the access-controlled workflow artifact; public history contains inert structured evidence and a trusted synthetic campaign summary.</p>
+ <p class="lede">A browser-verified matrix of runner profiles, execution environments, and deterministic task contracts. Declared PNG screenshots and sanitized structured evidence are retained with every published campaign; additional diagnostic evidence remains in the access-controlled workflow artifact.</p>
</div>
<div class="report-actions">
<div class="summary" aria-label="Campaign summary">
@@ -1020,7 +1020,7 @@ export function renderRunnerE2EDashboard(input: RunnerDashboardInput) {
</section>
${suiteSections}
${historySection}
- <footer><span>Generated ${html(input.generatedAt)}</span><span>${input.catalog.length} catalog executions · Public history excludes provider-produced visual evidence</span></footer>
+ <footer><span>Generated ${html(input.generatedAt)}</span><span>${input.catalog.length} catalog executions · Declared screenshots and sanitized structured evidence published</span></footer>
</main>
<dialog class="gallery-dialog" data-gallery-dialog aria-labelledby="gallery-title">
<div class="gallery-shell">
diff --git a/tests/runner-e2e/history-index.ts b/tests/runner-e2e/history-index.ts
index dfd8f0593e..8a83a60842 100644
--- a/tests/runner-e2e/history-index.ts
+++ b/tests/runner-e2e/history-index.ts
@@ -215,7 +215,7 @@ export function renderRunnerHistoryIndex(
<div>
<p class="eyebrow">Historical test reporting</p>
<h1>Runner E2E campaigns</h1>
- <p class="lede">Each row is one workflow campaign against a Paperclip revision. Open a report for its configuration matrices, matchers, per-test billing, and sanitized structured evidence. Provider-produced visual evidence remains in access-controlled workflow artifacts.</p>
+ <p class="lede">Each row is one workflow campaign against a Paperclip revision. Open a report for its configuration matrices, matchers, per-test billing, declared screenshots, and sanitized structured evidence. Additional diagnostic evidence remains in access-controlled workflow artifacts.</p>
</div>
<div class="summary" aria-label="History summary">
<div class="metric"><strong>${campaigns.length}</strong><span>Campaigns</span></div>
@@ -234,7 +234,7 @@ export function renderRunnerHistoryIndex(
<tbody>${rows}</tbody>
</table>
</div>
- <footer><span>Updated ${html(date(history.updatedAt))} UTC</span><span>Immutable campaign reports · Trusted synthetic summary image and inert structured evidence</span></footer>
+ <footer><span>Updated ${html(date(history.updatedAt))} UTC</span><span>Immutable campaign reports · Declared screenshots and inert structured evidence</span></footer>
</main>
</body>
</html>`;
diff --git a/tests/runner-e2e/history-publish.ts b/tests/runner-e2e/history-publish.ts
index f869aa3d41..db865998c2 100644
--- a/tests/runner-e2e/history-publish.ts
+++ b/tests/runner-e2e/history-publish.ts
@@ -19,6 +19,7 @@ import os from "node:os";
import { writePublicCampaignSummaryImage } from "./public-summary-image.js";
import { regenerateRunnerDashboard } from "./dashboard-regenerate.js";
import { renderRunnerHistoryIndex } from "./history-index.js";
+import { PUBLIC_RUNNER_SCREENSHOT_MARKER } from "./screenshot-policy.js";
import {
campaignHistoryRecord,
emptyRunnerHistory,
@@ -42,13 +43,17 @@ const PUBLISH_ROOT_FILES = new Set([
]);
const PUBLIC_EVIDENCE_EXTENSIONS = new Set([".json", ".log", ".md", ".txt"]);
const MAX_PUBLIC_RASTER_BYTES = 12 * 1024 * 1024;
+const EMPTY_PUBLIC_SCREENSHOTS: ReadonlySet<string> = new Set();
const PRIVATE_EVIDENCE_DIRECTORIES = new Set([
"blob-report",
"html-report",
"playwright-output",
]);
-function publicEvidencePath(relative: string) {
+function publicEvidencePath(
+ relative: string,
+ publicScreenshots: ReadonlySet<string> = EMPTY_PUBLIC_SCREENSHOTS,
+) {
const match = relative.match(
/^evidence\/[A-Za-z0-9._-]+\/attempt-[1-9][0-9]*\/(.+)$/,
);
@@ -66,14 +71,51 @@ function publicEvidencePath(relative: string) {
) {
return false;
}
- return PUBLIC_EVIDENCE_EXTENSIONS.has(
- path.posix.extname(evidencePath).toLowerCase(),
+ return (
+ PUBLIC_EVIDENCE_EXTENSIONS.has(
+ path.posix.extname(evidencePath).toLowerCase(),
+ ) || publicScreenshots.has(relative)
);
}
+export function publicScreenshotPaths(campaign: RunnerE2ECampaign) {
+ const screenshots = new Set<string>();
+ for (const result of campaign.results) {
+ const files =
+ result.screenshots
+ ?.filter(
+ (screenshot) =>
+ screenshot.publication === PUBLIC_RUNNER_SCREENSHOT_MARKER,
+ )
+ .map((screenshot) => screenshot.file) ?? [];
+ if (files.length === 0) continue;
+ if (
+ !/^[A-Za-z0-9][A-Za-z0-9._-]{0,299}$/.test(result.executionId) ||
+ !Number.isSafeInteger(result.attempt) ||
+ result.attempt < 1
+ ) {
+ throw new Error(
+ `Cannot publish screenshots for unsafe execution identity ${result.executionId}`,
+ );
+ }
+ for (const file of files) {
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}\.png$/i.test(file)) {
+ throw new Error(
+ `Cannot publish unsafe screenshot path for ${result.executionId}: ${file}`,
+ );
+ }
+ screenshots.add(
+ `evidence/${result.executionId}/attempt-${result.attempt}/${file}`,
+ );
+ }
+ }
+ return screenshots;
+}
+
export function isHistoricalBundlePathAllowed(
relative: string,
allowPublicSummary = false,
+ publicScreenshots: ReadonlySet<string> = EMPTY_PUBLIC_SCREENSHOTS,
) {
if (
relative.includes("\\") ||
@@ -92,7 +134,7 @@ export function isHistoricalBundlePathAllowed(
) {
return true;
}
- return publicEvidencePath(relative);
+ return publicEvidencePath(relative, publicScreenshots);
}
function hasPublicPngMagic(content: Buffer) {
@@ -120,32 +162,39 @@ async function validatePublicRaster(absolute: string, relative: string) {
}
}
-async function pruneEvidenceDirectory(root: string, current: string) {
+async function pruneEvidenceDirectory(
+ root: string,
+ current: string,
+ publicScreenshots: ReadonlySet<string>,
+) {
const entries = await readdir(current, { withFileTypes: true });
for (const entry of entries) {
const absolute = path.join(current, entry.name);
if (entry.isDirectory()) {
- await pruneEvidenceDirectory(root, absolute);
+ await pruneEvidenceDirectory(root, absolute, publicScreenshots);
if ((await readdir(absolute)).length === 0) {
await rm(absolute, { recursive: true });
}
continue;
}
const relative = path.relative(root, absolute).split(path.sep).join("/");
- if (!entry.isFile() || !publicEvidencePath(relative)) {
+ if (!entry.isFile() || !publicEvidencePath(relative, publicScreenshots)) {
await rm(absolute, { force: true });
}
}
}
-export async function prunePrivateHistoryEvidence(root: string) {
+export async function prunePrivateHistoryEvidence(
+ root: string,
+ publicScreenshots: ReadonlySet<string> = EMPTY_PUBLIC_SCREENSHOTS,
+) {
const evidenceRoot = path.join(root, "evidence");
const metadata = await lstat(evidenceRoot).catch(() => null);
if (!metadata) return;
if (!metadata.isDirectory()) {
throw new Error("Historical evidence root must be a directory");
}
- await pruneEvidenceDirectory(root, evidenceRoot);
+ await pruneEvidenceDirectory(root, evidenceRoot, publicScreenshots);
}
export async function stageTrustedHistoryAssets(
@@ -248,6 +297,7 @@ async function relativeFiles(
root: string,
current = root,
allowPublicSummary = false,
+ publicScreenshots: ReadonlySet<string> = EMPTY_PUBLIC_SCREENSHOTS,
): Promise<string[]> {
const entries = await readdir(current, { withFileTypes: true });
const files: string[] = [];
@@ -257,11 +307,24 @@ async function relativeFiles(
throw new Error(`Refusing to publish symbolic link ${entry.name}`);
}
if (entry.isDirectory()) {
- files.push(...(await relativeFiles(root, absolute, allowPublicSummary)));
+ files.push(
+ ...(await relativeFiles(
+ root,
+ absolute,
+ allowPublicSummary,
+ publicScreenshots,
+ )),
+ );
} else if (entry.isFile()) {
const relative = path.relative(root, absolute).split(path.sep).join("/");
if (MUTABLE_HISTORY_FILES.has(relative)) continue;
- if (!isHistoricalBundlePathAllowed(relative, allowPublicSummary)) {
+ if (
+ !isHistoricalBundlePathAllowed(
+ relative,
+ allowPublicSummary,
+ publicScreenshots,
+ )
+ ) {
throw new Error(
`Refusing non-allowlisted historical bundle path ${relative}`,
);
@@ -276,16 +339,20 @@ export async function createBundleManifest(
root: string,
campaignId: string,
allowPublicSummary = false,
+ publicScreenshots: ReadonlySet<string> = EMPTY_PUBLIC_SCREENSHOTS,
): Promise<BundleManifest> {
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(campaignId)) {
throw new Error("Campaign ID is unsafe for immutable object storage");
}
const files = await Promise.all(
- (await relativeFiles(root, root, allowPublicSummary))
+ (await relativeFiles(root, root, allowPublicSummary, publicScreenshots))
.sort()
.map(async (relative) => {
const absolute = path.join(root, ...relative.split("/"));
- if (relative === "public-images/campaign-summary.png") {
+ if (
+ relative === "public-images/campaign-summary.png" ||
+ publicScreenshots.has(relative)
+ ) {
await validatePublicRaster(absolute, relative);
}
const [content, metadata] = await Promise.all([
@@ -498,16 +565,17 @@ async function main() {
`${destination.publicBaseUrl}/${destination.prefix}`,
),
);
+ const publicScreenshots = publicScreenshotPaths(campaign);
// Campaign bundles are immutable and must not capture a mutable history
// file left in a reused local directory. The root landing page below is the
// only dashboard that embeds navigation across campaigns. S3 gets its own
- // staged copy. All target/provider-produced raster remains private. The sole
- // public image is rendered below by trusted publisher code from fixed catalog
- // labels and numeric/status fields while Chromium has no network access.
+ // staged copy. Only screenshots declared by normalized results (plus the
+ // fixed failure screenshot for failed executions) cross the public boundary;
+ // all other target-produced files remain subject to the structured allowlist.
const s3ReportRoot = path.join(temporary, "s3-campaign");
await cp(reportRoot, s3ReportRoot, { recursive: true, errorOnExist: true });
- await prunePrivateHistoryEvidence(s3ReportRoot);
+ await prunePrivateHistoryEvidence(s3ReportRoot, publicScreenshots);
await stageTrustedHistoryAssets(s3ReportRoot);
await rm(path.join(s3ReportRoot, "public-images"), {
recursive: true,
@@ -528,6 +596,7 @@ async function main() {
s3ReportRoot,
campaign.campaignId,
true,
+ publicScreenshots,
);
const campaignPrefix = `${destination.prefix}/campaigns/${campaign.campaignId}`;
const manifestKey = `${campaignPrefix}/bundle-manifest.json`;
@@ -556,12 +625,12 @@ async function main() {
);
}
- // Pages intentionally remains a smaller, structured-only publication in a
- // sibling stage. The downloaded report stays intact for this whole job.
+ // Pages uses the same declared-screenshot boundary in a sibling stage. The
+ // downloaded access-controlled report stays intact for this whole job.
const pagesRoot = path.join(path.dirname(reportRoot), "pages");
await rm(pagesRoot, { recursive: true, force: true });
await cp(reportRoot, pagesRoot, { recursive: true, errorOnExist: true });
- await prunePrivateHistoryEvidence(pagesRoot);
+ await prunePrivateHistoryEvidence(pagesRoot, publicScreenshots);
await stageTrustedHistoryAssets(pagesRoot);
await rm(path.join(pagesRoot, "public-images"), {
recursive: true,
@@ -577,7 +646,12 @@ async function main() {
writeFile(latestGreenFile, json(pointers.latestGreen), "utf8"),
]);
await regenerateRunnerDashboard({ bundle: pagesRoot, historyFile });
- await createBundleManifest(pagesRoot, campaign.campaignId);
+ await createBundleManifest(
+ pagesRoot,
+ campaign.campaignId,
+ false,
+ publicScreenshots,
+ );
const landingDirectory = path.join(temporary, "landing");
await regenerateRunnerDashboard({
bundle: s3ReportRoot,
diff --git a/tests/runner-e2e/history.test.ts b/tests/runner-e2e/history.test.ts
index 70ebbc50cb..c11f97e0db 100644
--- a/tests/runner-e2e/history.test.ts
+++ b/tests/runner-e2e/history.test.ts
@@ -17,6 +17,7 @@ import {
createBundleManifest,
isHistoricalBundlePathAllowed,
prunePrivateHistoryEvidence,
+ publicScreenshotPaths,
stageTrustedHistoryAssets,
validateHistoryDestination,
} from "./history-publish.js";
@@ -29,6 +30,7 @@ import {
} from "./history.js";
import { renderRunnerHistoryIndex } from "./history-index.js";
import { renderPublicCampaignSummary } from "./public-summary-image.js";
+import { isPublicRunnerScreenshotRoute } from "./screenshot-policy.js";
import type { MatrixExecution, RunnerE2EResult } from "./types.js";
const temporaryDirectories: string[] = [];
@@ -200,10 +202,10 @@ describe("runner E2E campaign history", () => {
"campaigns/complete-red/public-images/campaign-summary.png",
);
expect(index).toContain(
- "Provider-produced visual evidence remains in access-controlled workflow artifacts",
+ "declared screenshots, and sanitized structured evidence",
);
expect(index).toContain(
- "Trusted synthetic summary image and inert structured evidence",
+ "Declared screenshots and inert structured evidence",
);
expect(index).not.toContain("data-gallery-dialog");
expect(index).not.toContain("Configuration matrix");
@@ -211,7 +213,52 @@ describe("runner E2E campaign history", () => {
});
describe("historical publication security", () => {
- it("keeps visual and active evidence private when building the public dashboard", async () => {
+ it("allows public capture only on an issue task route", () => {
+ const target = {
+ issuePrefix: "PAP",
+ issueId: "issue-id",
+ issueIdentifier: "PAP-123",
+ };
+ expect(
+ isPublicRunnerScreenshotRoute(
+ "http://127.0.0.1:3100/PAP/issues/PAP-123",
+ target,
+ ),
+ ).toBe(true);
+ expect(
+ isPublicRunnerScreenshotRoute(
+ "http://127.0.0.1:3100/PAP/issues/PAP-999",
+ target,
+ ),
+ ).toBe(false);
+ expect(
+ isPublicRunnerScreenshotRoute(
+ "http://127.0.0.1:3100/PAP/settings",
+ target,
+ ),
+ ).toBe(false);
+ expect(
+ isPublicRunnerScreenshotRoute(
+ "http://127.0.0.1:3100/setup/secrets",
+ target,
+ ),
+ ).toBe(false);
+ expect(
+ isPublicRunnerScreenshotRoute(
+ "https://example.test/PAP/issues/PAP-123",
+ target,
+ ),
+ ).toBe(false);
+ expect(isPublicRunnerScreenshotRoute("not a URL", target)).toBe(false);
+ expect(
+ isPublicRunnerScreenshotRoute(
+ "http://127.0.0.1:3100/PAP/issues/PAP-123",
+ { ...target, issueId: null },
+ ),
+ ).toBe(false);
+ });
+
+ it("publishes declared screenshots while keeping active evidence private", async () => {
const root = await mkdtemp(path.join(os.tmpdir(), "runner-landing-test-"));
const output = path.join(root, "landing");
temporaryDirectories.push(root);
@@ -223,6 +270,7 @@ describe("historical publication security", () => {
id: "final-state",
label: "Final state",
file: "final-state.png",
+ publication: "public-runner-fixture",
},
],
} satisfies RunnerE2EResult;
@@ -243,7 +291,11 @@ describe("historical publication security", () => {
path.join(root, "normalized-results.json"),
JSON.stringify(campaign),
);
- await writeFile(path.join(evidenceDirectory, "final-state.png"), "png");
+ const png = Buffer.from(
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
+ "base64",
+ );
+ await writeFile(path.join(evidenceDirectory, "final-state.png"), png);
await writeFile(path.join(evidenceDirectory, "failure.webm"), "webm");
await writeFile(path.join(evidenceDirectory, "unsafe.svg"), "<svg />");
await writeFile(
@@ -267,26 +319,27 @@ describe("historical publication security", () => {
"private archive",
);
- await prunePrivateHistoryEvidence(root);
+ const publicScreenshots = publicScreenshotPaths(campaign);
+ await prunePrivateHistoryEvidence(root, publicScreenshots);
await regenerateRunnerDashboard({
bundle: root,
outputDirectory: output,
evidenceHrefPrefix: "campaigns/campaign-1",
});
const dashboard = await readFile(path.join(output, "index.html"), "utf8");
- expect(dashboard).not.toContain(
+ expect(dashboard).toContain(
`campaigns/campaign-1/evidence/${execution.id}/attempt-1/final-state.png`,
);
- expect(dashboard).toContain("Visual evidence · workflow artifact only");
+ expect(dashboard).toContain("View gallery · 1");
expect(dashboard).toContain(
- "public history contains inert structured evidence and a trusted synthetic campaign summary",
+ "Declared PNG screenshots and sanitized structured evidence are retained with every published campaign",
);
expect(dashboard).toContain(
- "Public history excludes provider-produced visual evidence",
+ "Declared screenshots and sanitized structured evidence published",
);
await expect(
readFile(path.join(evidenceDirectory, "final-state.png")),
- ).rejects.toThrow();
+ ).resolves.toEqual(png);
await expect(
readFile(path.join(evidenceDirectory, "failure.webm")),
).rejects.toThrow();
@@ -325,7 +378,7 @@ describe("historical publication security", () => {
).rejects.toThrow("safe relative URL path");
});
- it("keeps target screenshots private and admits only the trusted summary PNG", async () => {
+ it("admits declared PNG screenshots and the trusted summary only", async () => {
const root = await mkdtemp(path.join(os.tmpdir(), "runner-s3-test-"));
temporaryDirectories.push(root);
const execution = runnerMatrix[0]!;
@@ -342,6 +395,7 @@ describe("historical publication security", () => {
id: "final-state",
label: "PROVIDER_LABEL_MUST_NOT_RENDER",
file: "final-state.png",
+ publication: "public-runner-fixture",
},
],
},
@@ -371,13 +425,12 @@ describe("historical publication security", () => {
writeFile(path.join(evidenceDirectory, "result.json"), "{}\n"),
]);
- await prunePrivateHistoryEvidence(root);
- for (const removed of [
- "final-state.png",
- "undeclared.png",
- "failure.webm",
- "unsafe.svg",
- ]) {
+ const publicScreenshots = publicScreenshotPaths(campaign);
+ await prunePrivateHistoryEvidence(root, publicScreenshots);
+ await expect(
+ readFile(path.join(evidenceDirectory, "final-state.png")),
+ ).resolves.toEqual(png);
+ for (const removed of ["undeclared.png", "failure.webm", "unsafe.svg"]) {
await expect(
readFile(path.join(evidenceDirectory, removed)),
).rejects.toThrow();
@@ -419,8 +472,10 @@ describe("historical publication security", () => {
expect(
isHistoricalBundlePathAllowed(
`evidence/${execution.id}/attempt-1/final-state.png`,
+ false,
+ publicScreenshots,
),
- ).toBe(false);
+ ).toBe(true);
await regenerateRunnerDashboard({
bundle: root,
publicSummaryImageHref: "public-images/campaign-summary.png",
@@ -432,16 +487,87 @@ describe("historical publication security", () => {
root,
campaign.campaignId,
true,
+ publicScreenshots,
);
expect(manifest.files.map((file) => file.path)).toContain(
"public-images/campaign-summary.png",
);
+ expect(manifest.files.map((file) => file.path)).toContain(
+ `evidence/${execution.id}/attempt-1/final-state.png`,
+ );
await writeFile(summaryPath, "not a png");
await expect(
- createBundleManifest(root, campaign.campaignId, true),
+ createBundleManifest(root, campaign.campaignId, true, publicScreenshots),
).rejects.toThrow("does not match its raster file type");
});
+ it("requires trusted-fixture opt-in and rejects unsafe screenshot paths", () => {
+ const execution = runnerMatrix[0]!;
+ const campaign = buildRunnerCampaign({
+ campaignId: "unsafe-screenshot",
+ generatedAt: "2026-08-28T00:01:00.000Z",
+ expected: [execution.id],
+ results: [
+ {
+ ...result(execution, "passed"),
+ screenshots: [
+ {
+ id: "unsafe",
+ label: "Unsafe",
+ file: "../secret.png",
+ publication: "public-runner-fixture",
+ },
+ ],
+ },
+ ],
+ });
+ expect(() => publicScreenshotPaths(campaign)).toThrow(
+ "Cannot publish unsafe screenshot path",
+ );
+
+ const failedCampaign = buildRunnerCampaign({
+ campaignId: "failed-screenshot",
+ generatedAt: "2026-08-28T00:01:00.000Z",
+ expected: [execution.id],
+ results: [
+ {
+ ...result(execution, "failed"),
+ screenshots: [
+ {
+ id: "failure",
+ label: "Task state at failure",
+ file: "failure.png",
+ publication: "public-runner-fixture",
+ },
+ {
+ id: "private-diagnostic",
+ label: "Private diagnostic",
+ file: "private-diagnostic.png",
+ },
+ ],
+ },
+ ],
+ });
+ expect([...publicScreenshotPaths(failedCampaign)]).toEqual([
+ `evidence/${execution.id}/attempt-1/failure.png`,
+ ]);
+
+ const missingArtifactCampaign = buildRunnerCampaign({
+ campaignId: "missing-artifact",
+ generatedAt: "2026-08-28T00:01:00.000Z",
+ expected: [execution.id],
+ results: [
+ {
+ ...result(execution, "failed"),
+ attempt: 0,
+ error: "Missing matrix artifact",
+ screenshots: [],
+ },
+ ],
+ });
+ expect([...publicScreenshotPaths(missingArtifactCampaign)]).toEqual([]);
+ });
+
it("replaces target-supplied public assets with trusted publisher assets", async () => {
const root = await mkdtemp(path.join(os.tmpdir(), "runner-assets-test-"));
const trustedRoot = await mkdtemp(
diff --git a/tests/runner-e2e/report.test.ts b/tests/runner-e2e/report.test.ts
index fc980b781a..2f949b6bc5 100644
--- a/tests/runner-e2e/report.test.ts
+++ b/tests/runner-e2e/report.test.ts
@@ -194,10 +194,10 @@ describe("runner E2E report aggregation", () => {
expect(dashboard).toContain("data-gallery-next");
expect(dashboard).toContain("View gallery · 1");
expect(dashboard).toContain(
- "Visual evidence is retained in the access-controlled workflow artifact",
+ "Declared PNG screenshots and sanitized structured evidence are retained with every published campaign",
);
expect(dashboard).toContain(
- "Public history excludes provider-produced visual evidence",
+ "Declared screenshots and sanitized structured evidence published",
);
expect(dashboard).toContain("message_contains");
expect(dashboard).toContain("Matchers and test context");
diff --git a/tests/runner-e2e/runner.spec.ts b/tests/runner-e2e/runner.spec.ts
index e80af814ba..a1c2682b4e 100644
--- a/tests/runner-e2e/runner.spec.ts
+++ b/tests/runner-e2e/runner.spec.ts
@@ -19,6 +19,10 @@ import {
providerSessionContinuityFailures,
} from "./run-observations.js";
import { resolveRunnerE2ESource } from "./source.js";
+import {
+ isPublicRunnerScreenshotRoute,
+ PUBLIC_RUNNER_SCREENSHOT_MARKER,
+} from "./screenshot-policy.js";
import {
assertSecretFree,
findSecretLeakInJsonValues,
@@ -542,9 +546,8 @@ for (const execution of executions) {
let failureClassOverride: FailureClass | undefined;
let cleanup: RunnerE2EResult["cleanup"] = "not_started";
- const captureScreenshot = async (
+ const capturePrivateScreenshot = async (
id: string,
- label: string,
file: string,
) => {
const screenshotPath = path.join(privateDir, file);
@@ -553,7 +556,32 @@ for (const execution of executions) {
path: screenshotPath,
contentType: "image/png",
});
- screenshots.push({ id, label, file });
+ };
+
+ const isReviewedFixtureScreenshotRoute = () =>
+ isPublicRunnerScreenshotRoute(page.url(), {
+ issuePrefix: fixtures?.company.issuePrefix,
+ issueId: issue?.id,
+ issueIdentifier: issue?.identifier,
+ });
+
+ const captureScreenshot = async (
+ id: string,
+ label: string,
+ file: string,
+ ) => {
+ if (!isReviewedFixtureScreenshotRoute()) {
+ throw new Error(
+ `Public runner screenshot blocked on non-task route ${page.url()}`,
+ );
+ }
+ await capturePrivateScreenshot(id, file);
+ screenshots.push({
+ id,
+ label,
+ file,
+ publication: PUBLIC_RUNNER_SCREENSHOT_MARKER,
+ });
};
const captureRuntimeLeases = async () => {
@@ -1795,16 +1823,17 @@ for (const execution of executions) {
}
}
if (!page.isClosed()) {
- const failureScreenshot = path.join(privateDir, "failure.png");
- await page
- .screenshot({ path: failureScreenshot, fullPage: true })
- .catch(() => undefined);
- await testInfo
- .attach("failure", {
- path: failureScreenshot,
- contentType: "image/png",
- })
- .catch(() => undefined);
+ if (isReviewedFixtureScreenshotRoute()) {
+ await captureScreenshot(
+ "failure",
+ "Task state at failure",
+ "failure.png",
+ ).catch(() => undefined);
+ } else {
+ await capturePrivateScreenshot("failure", "failure.png").catch(
+ () => undefined,
+ );
+ }
}
} finally {
try {
diff --git a/tests/runner-e2e/screenshot-policy.ts b/tests/runner-e2e/screenshot-policy.ts
new file mode 100644
index 0000000000..9a7aff60ce
--- /dev/null
+++ b/tests/runner-e2e/screenshot-policy.ts
@@ -0,0 +1,27 @@
+export const PUBLIC_RUNNER_SCREENSHOT_MARKER = "public-runner-fixture" as const;
+
+export interface PublicRunnerScreenshotTarget {
+ issuePrefix: string | null | undefined;
+ issueId: string | null | undefined;
+ issueIdentifier: string | null | undefined;
+}
+
+export function isPublicRunnerScreenshotRoute(
+ url: string,
+ target: PublicRunnerScreenshotTarget,
+) {
+ try {
+ if (!target.issuePrefix || !target.issueId) return false;
+ const candidate = new URL(url);
+ const issueReference = target.issueIdentifier ?? target.issueId;
+ const expectedPath = `/${encodeURIComponent(target.issuePrefix)}/issues/${encodeURIComponent(issueReference)}`;
+ return (
+ candidate.protocol === "http:" &&
+ candidate.hostname === "127.0.0.1" &&
+ (candidate.pathname === expectedPath ||
+ candidate.pathname === `${expectedPath}/`)
+ );
+ } catch {
+ return false;
+ }
+}
diff --git a/tests/runner-e2e/types.ts b/tests/runner-e2e/types.ts
index 3191832682..d607e60893 100644
--- a/tests/runner-e2e/types.ts
+++ b/tests/runner-e2e/types.ts
@@ -275,6 +275,7 @@ export interface RunnerE2EResult {
id: string;
label: string;
file: string;
+ publication?: "public-runner-fixture";
}>;
cleanup: "not_started" | "passed" | "failed";
}
diff --git a/tests/runner-e2e/workflow-security.test.ts b/tests/runner-e2e/workflow-security.test.ts
index aeceafb6db..55997ce9bb 100644
--- a/tests/runner-e2e/workflow-security.test.ts
+++ b/tests/runner-e2e/workflow-security.test.ts
@@ -697,19 +697,21 @@ describe("public repository paid workflow security", () => {
expect(workflow).toContain("Verify normalized history source report");
expect(workflow).not.toContain("sanitized_screenshot=");
expect(workflow).toContain(
- "Publish trusted-summary S3 history and structured Pages bundle",
+ "Publish S3 history and Pages bundle with declared screenshots",
);
expect(workflow).toContain(
- "Publish trusted summary image to S3 and prune the Pages bundle",
+ "Publish trusted summary and declared screenshots to public bundles",
);
expect(publisher).toContain(
"pnpm exec playwright install --with-deps --only-shell chromium",
);
expect(workflow).toContain(
- "Package structured-only dashboard for GitHub Pages",
+ "Package pruned dashboard with declared screenshots for GitHub Pages",
);
expect(workflow).toContain("path: runner-e2e-merged-report/pages");
- expect(workflow).toContain("Publish latest structured dashboard");
+ expect(workflow).toContain(
+ "Publish latest dashboard with declared screenshots",
+ );
expect(workflow).not.toContain("dashboard_ready");
expect(workflow).not.toContain("Publish latest screenshot dashboard");
expect(