fix review findings: hostile code accessor + swallowed teardown

Both ds-review-bot findings were real:

- markLlmAdapterFailure's carried-facts cross-check read error.code
  directly; a foreign Error with a valid own failure payload but a
  throwing code accessor would replace the original adapter error with
  the accessor exception, breaking the error-identity guarantee. The
  read now goes through foreignErrorCode(), which contains the trap and
  falls back to the normalized snapshot (test: hostile code accessor
  beside a valid failure payload -> original identity kept, UNKNOWN
  facts).
- live-interactions' afterEach caught scaffold.close() into undefined,
  silently disabling ReplayHandle.assertConsumed() — the fixture-drift
  tripwire — and hiding cleanup defects. Teardown now runs every step,
  collects failures, and rethrows (AggregateError when several).
This commit is contained in:
Tianyi Cui
2026-07-26 14:12:52 +08:00
parent 4b06e9df99
commit f1b7d52a77
3 changed files with 43 additions and 4 deletions

View File

@@ -57,12 +57,19 @@ describe('web e2e: live-turn interactions (cancel / error / retry)', () => {
let sidecarDir: string | undefined
afterEach(async () => {
await browser?.close().catch(() => undefined)
// scaffold.close() failures MUST fail the scenario: assertConsumed() is
// the fixture-drift tripwire and cleanup problems are real defects. Run
// every teardown step regardless, then rethrow what failed.
const failures: unknown[] = []
await browser?.close().catch((error: unknown) => failures.push(error))
browser = undefined
await scaffold?.close().catch(() => undefined)
const closing = scaffold
scaffold = undefined
if (sidecarDir !== undefined) await rm(sidecarDir, { recursive: true, force: true }).catch(() => undefined)
await closing?.close().catch((error: unknown) => failures.push(error))
if (sidecarDir !== undefined) await rm(sidecarDir, { recursive: true, force: true }).catch((error: unknown) => failures.push(error))
sidecarDir = undefined
if (failures.length === 1) throw failures[0]
if (failures.length > 1) throw new AggregateError(failures, 'live-interactions teardown failed')
})
/** Boot scaffold + page with an optional override doc materialized per run. */