Property-based tests for the forge's pure cores, with a replayable seed in bun test
The forge has no property tests today (a code search for the usual libraries found none; I did not read every test file). Start small and keep the dependency list as it is: a ~60-line helper in test/ (seeded PRNG, generators, shrinking, PROP_SEED to replay, a fixed default seed so the suite stays deterministic), the same shape as the one proposed for trevato/app-template so the two stay one idea. If it earns its place, share it rather than fork it.
First targets, chosen because they are pure or nearly so and break in ways examples miss:
Access: src/contract and src/rules: permit is monotone in role; for any identity at any door the table and the action agree; loosening a cell is always detected as a wall, tightening never is.
src/git and src/http: ref, path and branch-name parsing never escapes the repo directory for any generated string (.., absolute paths, unicode, NUL, very long); a body cap holds for any chunking.
src/search, src/text: indexing then querying finds what was indexed; query parsing never throws on any string.
src/runs, src/flow, src/nightly, src/release: state machines. Generate event sequences (including duplicates, reordering and a restart in the middle) and assert the invariants: a run ends in exactly one terminal state, a job is never in two states, retry and cancel are idempotent, a release is never both held and shipped.
src/billing, src/efficiency, src/metrics: money and counters. Sums of parts equal the whole for any split; a budget is never exceeded by a generated spend sequence; rounding never loses a cent.
src/snapshot, src/data: round trip. For any generated data, snapshot then restore equals the original (Git is truth, the database is a derived index, so rebuilding the index from git gives the same index).
src/design, src/looks: contrast of every generated token pair that the stylesheet draws holds in each theme.
Each property that finds a real bug gets a pull of its own with the shrunk case saved as a plain example test beside it. Report in the first pull what the helper found, even if nothing.
Property-based tests for the forge's pure cores, with a replayable seed in
bun testThe forge has no property tests today (a code search for the usual libraries found none; I did not read every test file). Start small and keep the dependency list as it is: a ~60-line helper in
test/(seeded PRNG, generators, shrinking,PROP_SEEDto replay, a fixed default seed so the suite stays deterministic), the same shape as the one proposed for trevato/app-template so the two stay one idea. If it earns its place, share it rather than fork it.First targets, chosen because they are pure or nearly so and break in ways examples miss:
src/contractandsrc/rules: permit is monotone in role; for any identity at any door the table and the action agree; loosening a cell is always detected as a wall, tightening never is.src/gitandsrc/http: ref, path and branch-name parsing never escapes the repo directory for any generated string (.., absolute paths, unicode, NUL, very long); a body cap holds for any chunking.src/search,src/text: indexing then querying finds what was indexed; query parsing never throws on any string.src/runs,src/flow,src/nightly,src/release: state machines. Generate event sequences (including duplicates, reordering and a restart in the middle) and assert the invariants: a run ends in exactly one terminal state, a job is never in two states, retry and cancel are idempotent, a release is never both held and shipped.src/billing,src/efficiency,src/metrics: money and counters. Sums of parts equal the whole for any split; a budget is never exceeded by a generated spend sequence; rounding never loses a cent.src/snapshot,src/data: round trip. For any generated data, snapshot then restore equals the original (Git is truth, the database is a derived index, so rebuilding the index from git gives the same index).src/design,src/looks: contrast of every generated token pair that the stylesheet draws holds in each theme.Each property that finds a real bug gets a pull of its own with the shrunk case saved as a plain example test beside it. Report in the first pull what the helper found, even if nothing.