When AI agents write both implementation and tests, passing tests no longer guarantee correctness. Six progressive TypeScript patterns address this: (1) property-based tests with fast-check to assert invariants over random inputs rather than hardcoded pairs; (2) mutation testing with Stryker to verify test quality by flipping operators and checking if tests catch the change; (3) human-owned acceptance tests using Claude Code's .claude/settings.json deny rules to block agent access to critical test directories; (4) CODEOWNERS files on GitHub/GitLab requiring human review before acceptance test changes can merge; and (5) sealed black-box tests in a separate repo that depend on the published artifact, making them completely inaccessible to the agent. Each layer adds more separation between the verifier and the system being verified, drawing on the Dieselgate analogy where the verifier must live outside the system it measures.

7m read timeFrom typescript.tv
Post cover image
Table of contents
ContentsThe Principal-Agent ProblemLessons from DieselgateSurface Separation1. Property-Based Tests with fast-check2. Mutation Testing with Stryker3. Human-owned Acceptance Tests4. Human-owned Code Review5. Sealed Black-Box Tests

Sort: