Packages
@strict-script/fuzz
A fuzzer of the kernel: it writes programs, asks the compiler about each, and runs what it accepts. A program that compiles and breaks a promise is a finding. It is a tool of this repository and is not published.
pnpm build
pnpm fuzz --seed 1 --count 100000 # the three sources, on every core but two
pnpm fuzz --seed 7 --count 50000 --source attack # made | changed | attack | both
The same seed gives the same programs. A finding is written to packages/fuzz/findings/, one file each, the
shortest first, with what was seen in its first line; the command then ends with exit code 1.
#Where the programs come from
| Source | File | What it is |
|---|---|---|
made | src/generate.ts | Programs written from the types down. Every one is meant to compile: one that is refused is reported (made-refused) |
changed | src/corpus.ts, src/mutate.ts | Every program the repository holds (the examples, the docs, the programs inside the tests), accepted or refused, changed in one to three places |
attack | src/attacks.ts | Programs that try to get a second name for a value that can be changed, or to end a resource twice or never, and say themselves whether they did: a function holds… that gives true when the promise was kept |
#What is a finding
src/judge.ts. For a program the compiler accepts:
| Kind | The promise | What was seen |
|---|---|---|
compiler-threw, compiler-stopped, not-the-same | The compiler answers, and answers one thing | It fell, or wrote two texts for one program |
not-javascript, throws-at-load | What it writes is a module | It does not load |
not-of-type | Safe typing | An exported function, called with values made from the types of its parameters, gave a value that is not of the type it declares |
misuse | Safe typing | It called a function it was given with a value of another type |
throws, rejects | Errors in the types | A call threw, or its promise rejected |
changed | Mutability | A value given to a parameter that is not mut was written to: it is frozen before the call |
door | Safe typing, for a caller in TypeScript | The function behind its door, called with the same values, refused them, gave another value, or left another value in what it was lent to change |
does-not-hold | Ownership | A function holds… of an attack gave false |
Not findings: a panic the program wrote, the machine running out (a recursion without end, a text too long),
and a program that does not end, which a clock stops.
#What it does not see
It is written in docs/known-limits.md, beside what is claimed from it.
#Its tests
test/fuzz.test.ts: each kind of finding is seen on a compiler made wrong on purpose; the programs of the
generator are all accepted; a run on a fixed seed finds nothing.