fix(run): exit 3 when a passed test's cleanup failed

Merged
VA
19d ago
+143-10

#1231: a run whose tests all pass but whose required video cannot be finalized exits 0, with the loss visible only as an attempt-level cleanup: "failed" and a secondary error. The exit-code fold never looked at cleanup state.

  • verdictExitCodes (packages/e2e/src/run/runner.ts) now folds an attempt's failed cleanup into the exit code, for ordinary and serial-group attempts alike: the cleanup-phase secondary error's category, defaulting to infrastructure (exit 3) when the record carries none.
  • A forced cleanup (cleanup: "forced") is untouched: the interrupt already sets 130.
  • Docs (docs/reference/errors.mdx) note the new rule under exit codes; changeset added.

This covers both producers of cleanup: "failed": stopVideo for a required recording (packages/e2e/src/run/execute.ts) and the session-close path, plus the standalone attempt's close. Best-effort recordings still fail quietly by design.

Verified

Ran it locally: yes, at the unit level (a real video-finalization failure needs a browser; the regression test drives the exact record shape from the issue: status: "passed", cleanup: "failed", a CLEANUP_TIMEOUT cleanup-phase secondary error).

  • New packages/e2e/tests/unit/runner-exit-codes.test.ts (8 tests): all fail on main, all pass here.
  • Full unit suite: 185 files, 2750 tests, 0 failures.
  • tsc --noEmit: no new errors (only the pre-existing @e2e-dev/web resolution errors this env has on main); oxlint: clean.
mainthis branch
passed attempt + failed required-video cleanup folds to 0folds to 3 (infrastructure), run status error

Closes #1231