Cairn.Fuzz.Trusted.Gen
lean/Cairn/Fuzz/Trusted/Gen.lean
Generators for the trusted-base fuzzer
Random frames for differential fuzzing of the Swift frame decoder (docs/fuzz.md, "Trusted
base"). Built on workstream L's SplitMix64 (Cairn.Fuzz.Gen), so a seed replays exactly.
Every generated frame fits the wire (fitsFrame): integers are drawn inside i32/u32, with a
bias toward the edges (0, ±1, the extremes), because that is where a hand-written decoder slips.
Strings lean on what breaks text code: astral scalars (surrogate pairs in UTF-16), the last
scalar before and after the surrogate block, U+10FFFF, NUL, combining marks, ZWJ sequences, skin
tones, flags, CJK, right-to-left scripts, line breaks and the BOM.
Imports Cairn.Fuzz.Rng, Cairn.Frame.Encode, Cairn.Frame.Events
Definitions 35
edgeScalars : Array NatScalars at the edges of UTF-8 and UTF-16 encodings, and ones text code mishandles.
edgeStrings : Array StringWhole strings that are hard to measure or index: ZWJ families, skin tones, flags, combining stacks, mixed bidi.
scalar : Gen Char
str : Gen String
i32 : Gen Int
u32 : Gen Nat
byte : Gen UInt8
opt {α : Type} (g : Gen α) : Gen (Option α)
rect : Gen Rect
color : Gen Color
ref : Gen ControlRef
range : Gen (Nat × Nat)
font : Gen Font
ints : Gen (List Int)
draw : Gen Draw
role : Gen Role
axNode : Gen AxNode
textInput : Gen TextInput
array {α : Type} (n : Nat) (g : Gen α) : Gen (Array α)
u64 : Gen NatA u64, edges first: around 2³² (where the two words split) and the top.
bytes : Gen ByteArray
headers : Gen (List (String × String))
part : Gen Part
secret : Gen Secret
request : Gen Request
effect : Gen Effect
subCmd : Gen SubCmd
canvas (big : Bool) : Gen Canvas
key : Gen Key
mods : Gen Mods
status (big : Bool) : Gen StatusFrame
surface (big : Bool) : Gen SurfaceFrame
frame : Gen Frame
frameOf (seed : UInt64) : Frame
The frame for a seed.