fix(core): keep unreadable artifacts marked as incomplete

Merged
MI
4d ago
+109-8

What

An artifact whose file never appeared or could not be read now keeps redaction: 'incomplete' instead of complete, with path, size, and sha256 omitted. Present artifacts keep the same redaction, metadata, and ArtifactStore uploads as before.

Why

An engine can return a screenshot path without writing a file to disk. createAttemptArtifacts initialized record.redaction to 'complete' for screenshots and logs, then returned early without setting path, size, or sha256 when the file read failed. report-v1.schema.json requires path, size, and sha256 on every artifact whose redaction is 'complete', so e2e run wrote a report.json that failed schema validation (surfaced during #2177 review).

How it works

  1. createAttemptArtifacts initializes each registered record with redaction: 'incomplete' (packages/core/src/run/artifacts.ts:104), instead of REDACTION_BY_KIND[kind].
  2. Settlement computes the target label in a local redaction variable (including redactDownload) and assigns record.redaction = redaction only alongside path, size, and sha256 once measure or readFile succeeds (packages/core/src/run/artifacts.ts:112-135). If the file cannot be read, the record stays incomplete without path, size, or sha256, and store.put is skipped.
  3. Update the ArtifactRecord.redaction JSDoc (packages/core/src/run/records.ts:107-109) and the reporter reference (docs/reference/reporters.mdx:534-536) to match.
  4. Cover missing screenshot, log, and download files (with and without an ArtifactStore, before and after settlement) and validate the built report against report-v1.schema.json (packages/e2e/tests/unit/artifact-store.test.ts:184-270).

Issue

Split out from review feedback on #2177 (packages/e2e/src/report/build.ts).

Verified

Ran it locally: yes

  • Built CLI (packages/e2e/dist/cli/bin.js run --reporter json) against a scratch project with a defineEngine whose artifacts.screenshot returns 'screenshots/missing.png' without writing the file, validating .e2e/report.json with Ajv against packages/e2e/schema/report-v1.schema.json:
Checkmain (74e2abea8)this PR
artifact in report.jsonredaction: "complete", no path/size/sha256redaction: "incomplete", no path/size/sha256
report-v1.schema.json validationfailed (must have required property 'path', 'size', 'sha256')passed (0 errors)
CLI main: {"exitCode":0,"artifact":{"id":"01a217b3-2aa0-788e-9d51-cb4a61dea04c:artifact:0","kind":"screenshot","mediaType":"image/png","redaction":"complete","producer":{"kind":"step","stepId":"01a217b3-2aa0-788e-9d51-cb4a61dea04c:0"}},"schemaValid":false,"schemaErrors":["/run/results/0/attempts/0/artifacts/0: must have required property 'path'","/run/results/0/attempts/0/artifacts/0: must have required property 'size'","/run/results/0/attempts/0/artifacts/0: must have required property 'sha256'","/run/results/0/attempts/0/artifacts/0: must match \"else\" schema","/run/results/0: must match \"else\" schema","/run/results/0: must match \"else\" schema","/run/results/0/attempts/0/artifacts/0: must have required property 'path'","/run/results/0/attempts/0/artifacts/0: must have required property 'size'","/run/results/0/attempts/0/artifacts/0: must have required property 'sha256'","/run/results/0/attempts/0/artifacts/0: must match \"else\" schema"]}
CLI pr: {"exitCode":0,"artifact":{"id":"01a217b3-2cf2-7133-8d84-e0e941012d0a:artifact:0","kind":"screenshot","mediaType":"image/png","redaction":"incomplete","producer":{"kind":"step","stepId":"01a217b3-2cf2-7133-8d84-e0e941012d0a:0"}},"schemaValid":true,"schemaErrors":[]}
  • Direct createAttemptArtifacts check against built packages/core/dist/run/artifacts.js on main (74e2abea8) vs this PR for missing screenshot and log files (both with and without a store): main recorded redaction: "complete" with no path; this PR records redaction: "incomplete" with no path and keeps present files complete.
  • Smoke check with real Chromium (apps/testbed, node node_modules/e2e/dist/cli/bin.js run tests/todos.e2e.ts): 7/7 passed.
  • pnpm bench:ab: skipped, because the change only moves one property assignment on artifact registration without extra I/O or async work.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.