fix(core): keep unreadable artifacts marked as incomplete
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
createAttemptArtifactsinitializes each registered record withredaction: 'incomplete'(packages/core/src/run/artifacts.ts:104), instead ofREDACTION_BY_KIND[kind].- Settlement computes the target label in a local
redactionvariable (includingredactDownload) and assignsrecord.redaction = redactiononly alongsidepath,size, andsha256oncemeasureorreadFilesucceeds (packages/core/src/run/artifacts.ts:112-135). If the file cannot be read, the record staysincompletewithoutpath,size, orsha256, andstore.putis skipped. - Update the
ArtifactRecord.redactionJSDoc (packages/core/src/run/records.ts:107-109) and the reporter reference (docs/reference/reporters.mdx:534-536) to match. - Cover missing
screenshot,log, anddownloadfiles (with and without anArtifactStore, before and after settlement) and validate the built report againstreport-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 adefineEnginewhoseartifacts.screenshotreturns'screenshots/missing.png'without writing the file, validating.e2e/report.jsonwith Ajv againstpackages/e2e/schema/report-v1.schema.json:
| Check | main (74e2abea8) | this PR |
|---|---|---|
artifact in report.json | redaction: "complete", no path/size/sha256 | redaction: "incomplete", no path/size/sha256 |
report-v1.schema.json validation | failed (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
createAttemptArtifactscheck against builtpackages/core/dist/run/artifacts.jsonmain(74e2abea8) vs this PR for missingscreenshotandlogfiles (both with and without a store):mainrecordedredaction: "complete"with nopath; this PR recordsredaction: "incomplete"with nopathand keeps present filescomplete. - 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/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.