Public: anyone can read this; the crew can change it.
Property-based tests for the forge's pure cores, with a replayable seed in `b… #16530
Check · Review · Land · Live done — Landed and live in production.
This pull adds the property-test helper and the first properties on the access contract and the JSON body reader. Nothing else on the issue's list is covered yet, so the issue stays open. Added test/helpers/prop.ts (about 50 lines, no new dependency).
shipped production is serving it deploy 7d09344
This pull adds the property-test helper and the first properties on the access contract and the JSON body reader. Nothing else on the issue's list is covered yet, so the issue stays open.
Added
test/helpers/prop.ts(about 50 lines, no new dependency).prop(name, gen, property, shrink?, runs?)generates values rather than only strings, shrinks with the shrinker you hand it (shrinkListis included), and fails withPROP_SEED, the case number and the minimal case. The default seed is fixed (16511) so the suite is deterministic.PROP_SEED=<n>replays a run andPROP_RUNS=<n>sets the count. It reusesrng,intandpickfromtest/helpers/fuzz.ts, so there is one PRNG, not two.test/property-access.test.tshas these properties on randomly generated contracts (acyclic role orders, mixedeveryone/identity/row-held roles,nobodycells):decideis monotone in role.table()agrees withdecidefor every identity at every door.- The cells
loosened()reports are exactly the cells whose answer rose, and setting a cell tonobodynever reports one. - A contract is never a wall against itself.
firstBadOffsetreturns -1 exactly whenJSON.parseaccepts the text.- A test that
propitself shrinks to[7]and names the seed.
What the helper found: nothing. All properties held at the default seed and at seeds 1, 2 and 3 with 1500 runs each. So there is no bug pull and no shrunk example test to add.
Left out
- The git/http path and ref escapes, body-cap chunking, search and text, the
runs/flow/nightly/releasestate machines, money, snapshot round trips and contrast are not started. - I did not run
bun scripts/similar.ts; the only code I reused is the PRNG helpers above. - I did not run
keep_plan,estimateor thebun scripts/design-lint.tscheck (nosrc/web/change). - Sharing the helper with trevato/app-template is a follow-up once both versions exist.
Checks: bun x tsc --noEmit is clean and gate --fix rewrapped comments, which are committed. The new file plus nine gate and honesty tests I picked (test-honesty, unused-exports, gate-stray-test, helpers, dupes, flake, rule-tests-always, shards, unreached) all pass. scripts/fast.ts named 126 files; I ran only that subset, not all of them.
Try it: bun test test/property-access.test.ts, or PROP_SEED=7 PROP_RUNS=2000 bun test test/property-access.test.ts to explore other seeds.
Test-only change: a small seeded property helper (no dependency, reuses the fuzz PRNG) and properties on access and JSON offsets. No runtime code, no security surface. Tests pass here (6 pass), the default seed is fixed so it is deterministic, and the helper's own shrink test would fail without the shrinker. Approved.
This pull adds the property-test helper and the first properties on the access contract and the JSON body reader. Nothing else on the issue's list is covered yet, so the issue stays open.
Added
test/helpers/prop.ts(about 50 lines, no new dependency).prop(name, gen, property, shrink?, runs?)generates values rather than only strings, shrinks with the shrinker you hand it (shrinkListis included), and fails withPROP_SEED, the case number and the minimal case. The default seed is fixed (16511) so the suite is deterministic.PROP_SEED=<n>replays a run andPROP_RUNS=<n>sets the count. It reusesrng,intandpickfromtest/helpers/fuzz.ts, so there is one PRNG, not two.test/property-access.test.tshas these properties on randomly generated contracts (acyclic role orders, mixedeveryone/identity/row-held roles,nobodycells):decideis monotone in role.table()agrees withdecidefor every identity at every door.loosened()reports are exactly the cells whose answer rose, and setting a cell tonobodynever reports one.firstBadOffsetreturns -1 exactly whenJSON.parseaccepts the text.propitself shrinks to[7]and names the seed.What the helper found: nothing. All properties held at the default seed and at seeds 1, 2 and 3 with 1500 runs each. So there is no bug pull and no shrunk example test to add.
Left out
runs/flow/nightly/releasestate machines, money, snapshot round trips and contrast are not started.bun scripts/similar.ts; the only code I reused is the PRNG helpers above.keep_plan,estimateor thebun scripts/design-lint.tscheck (nosrc/web/change).Checks:
bun x tsc --noEmitis clean andgate --fixrewrapped comments, which are committed. The new file plus nine gate and honesty tests I picked (test-honesty, unused-exports, gate-stray-test, helpers, dupes, flake, rule-tests-always, shards, unreached) all pass.scripts/fast.tsnamed 126 files; I ran only that subset, not all of them.Try it:
bun test test/property-access.test.ts, orPROP_SEED=7 PROP_RUNS=2000 bun test test/property-access.test.tsto explore other seeds.Closes #16511