feat(config)!: config shape, part 1: recording modes, output root, test-glob exclusions, renames, secrets in engine options

Merged
OK
2mo ago
+2882-1126

First layer of the config redesign agreed after #610 (it replaces the closed #489). Stack: this PR, then #646 (agents), then #648 (the app on the target and services).

Recording modes

  • trace and video share one RecordingMode: 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' | 'on-all-retries'.
  • They can be set at the config root, on a target, on a test or describe, or with --trace [mode] / --video [mode]. Precedence, lowest first: config, target, CLI, test.
  • Trace defaults to on locally and on-first-retry in CI. There's a notice when a retry mode meets retries: 0.
  • A mode set at the config root or with a flag skips targets that can't record, with one notice. A mode set on a target or a test is required and fails with UNSUPPORTED_ARTIFACT.
  • artifacts.kinds and artifacts.trace are removed, and each old form names the trace mode it meant. Failure screenshots are always captured.

Output

  • output (default .e2e, --output) is the one per-run root: report, junit, summary, ai-trace, artifacts/, sessions/, and MCP videos. cache.dir stays separate.
  • <output>/artifacts is cleared at run start. The output directory is validated: not the project root, not inside the cache, not holding the tests.
  • --artifacts is hidden and fails with the --output mapping.
  • artifacts holds only store. The optional ArtifactStore.putLink receives provider-hosted video links, and its ref goes into the report.
trace: 'on-first-retry',
video: 'retain-on-failure',
output: '.e2e',
artifacts: { store: { put, putLink } },
targets: [{ name: 'kernel', engine, video: 'on', trace: 'off' }],
test('checkout', { video: 'on' }, ...);

Smaller changes

  • specVersion is removed. A config that sets it fails with INVALID_CONFIG; the runner version is the format version. The report's internal specVersion is unchanged.
  • tests accepts ! exclusions (['tests/**/*.e2e.ts', '!tests/wip/**']). A list of only exclusions is INVALID_CONFIG.
  • Renames: TraceCacheStore becomes CacheStore, "trace cache" becomes "replay cache" in docs and CLI help, and web({ video: { size, quality } }) becomes web({ screencast }). web({ video }) fails naming screencast.
  • secrets.get('name') works in engine options:
    • At config time it returns a deferred handle that carries only the name. The config load checks the name, with a did-you-mean.
    • The worker resolves it per attempt through the new EngineAttemptContext.resolveSecret, and the value joins the redaction ledger first.
    • web({ basicAuth: { password } }) accepts a Secret.
  • process.loadEnvFile('.env') is documented as the way to load env files.
secrets: { stagingPassword: () => process.env.STAGING_PASSWORD! },
targets: [{ engine: web({ basicAuth: { username: 'staging', password: secrets.get('stagingPassword') } }) }],

Verified

Ran it locally: yes

  • Built CLI in the testbed:
    • --output .e2e-verify wrote the report, junit and markdown files there and cleared a stale artifact.
    • --trace=retain-on-failure kept no traces for passing tests, and --trace kept trace/trace.zip per attempt.
    • --output . and --artifacts exit 2 with the expected messages.
  • Built CLI in the testbed with a scratch config:
    • specVersion is rejected.
    • ! exclusions select the right files, and an exclusions-only list fails.
    • web({ video }) names screencast.
    • An unknown secrets.get() name gets a did-you-mean.
    • e2e cache --help says "replay cache".
  • New engine-secrets.test.ts: a real config, workers, and a browser. A provider-backed basic-auth password echoed by the page is redacted from the failure message, the report, and the reporter files. It fails when the ledger registration is removed from the built dist.