policy/ holds the rules every in-process and hosted test follows, the check that enforces them
(bun run tests:check, a step of bun run check) and the generated coverage. The rules themselves
are in AGENTS.md under "Tests"; this file says how to follow them.
An in-process test runs the product inside the test process through a lab host (see
lab). A hosted test is one under a test/hosted/ directory; it runs against
a real Cloud and self-host started by bun run test:hosted. Both live in a test/ directory beside
the src/ they verify.
Every x.test.ts has a sibling x.verifies.ts whose default export declares its tests
(TestFile in policy/src/contracts/test.ts). A file is one of three kinds:
surface: each test names what it verifies: behaviors of the feature map (area.feature/behavior) or entrypoints assurface/entrypoints.txtwrites them (http local POST /auth/pair). Example:apps/local/server/test/sign-in-link-expiry.verifies.ts. When a change shows on a part of a surface no journey driver speaks, a surface test can reach it over HTTP throughhost.http(); when that is right, and what it may import, is in proving a change.invariant: each test states a rule frompolicy/src/invariants.ts, a rule over pure code that no surface shows, with the reason. These are usually written as aproperty(fromlab) over generated inputs. Example:packages/utils/test/url-policy.verifies.ts.check: each test names a step ofbun run check(an id fromci/src/contracts/checks.ts) or a custom lint rule, and shows it failing on a small violating input. Example:ci/test/check-steps.verifies.ts. A step with no small violating input is listed with the reason inpolicy/src/checks.tsinstead.
The test file registers its bodies with tests(declarations, bodies) from @executor-js/lab; a
name that is not declared, or a declared test with no body, is a compile error. A test imports only
@executor-js/lab, its .verifies.ts, expect, effect and src/contracts/ modules
(lint test-policy/through-surface).
Every test ships a break: test/breaks/<file id>.<test name>.patch, a change under which the test
fails, and a .json beside it: { "fails": "assertion" | "snapshot", "why": "<one sentence>" }.
A surface test's break changes product code under apps/ or packages/; an invariant's may also
change lab/src/ or ci/src/; a check test's break disables the check. A break never changes a
test. apps/local/server/test/breaks/local-apps-model.agrees-with-model.patch is an example.
- Write it as proving a change says: commit the product
change, make the breaking edit, save it with
git diff, undo it. That section also says what to do when the behavior was random before the change. bun run tests:break <file id>.<test name>applies the break to a scratch copy, runs the test there and passes only when the test fails the way the.jsonsays. A test that passes under its break does not test what it claims.bun run tests:checkfails when a break is missing or no longer applies.
A property checks the same generated inputs on every run of a commit: its seed comes from its test
id. A case it once failed on is recorded and replayed first. A known product defect goes in the
test's knownDefects with its smallest case until it is fixed; the list is printed in
policy/coverage.md. Try new inputs outside the gate with
bun run explore <test files>, which writes findings to .lab/explore/.
| Command | What it does |
|---|---|
bun run test |
every in-process test (one package or file: bun run test <path>) |
bun run test:hosted |
the hosted tests, against a real Cloud and self-host |
bun run tests |
regenerates policy/coverage.md and the generated lists in policy/src/generated/ |
bun run tests:check |
the policy check: declarations, breaks, invariants, and the generated files are current |
bun run tests:break <id> |
proves one break |
bun run test:admission <files> --runs 12 |
runs new or changed test files once in each of the conditions the gate admits them under. Without --runs it starts the full count, which takes hours and outlasts a remote machine; leave that to the gate (see proving a change) |
Run bun run tests after adding, renaming or removing a test, a check step or an invariant, and
commit what it regenerates with the change.