Cairn · module

Cairn.Fuzz.Trusted.Export

lean/Cairn/Fuzz/Trusted/Export.lean

Lean's side of the trusted-base fuzzer

C exports for cairn-fuzz-trusted (host/Tests/CairnFuzzTrusted), the Swift executable that links this library next to the Swift host, so both sides of each trusted boundary run in one process (docs/fuzz.md, "Trusted base"). No import Lean: this links into a Swift binary.

  • cairn_tf_gen_frame seed: a random frame (Gen.frame), encoded.
  • cairn_tf_decode_frame bytes and cairn_tf_decode_events bytes: Lean's proved decoders' verdict on any bytes. The reply is "R" (rejected), or "A=" / "A~" (accepted; = when re-encoding the value gives the same bytes back) followed by the canonical dump (Cairn.Dump), which the Swift side compares with its own dump.
  • cairn_tf_field_init/step/frame: an app that is one text field, on the real runtime and boundary (Runtime.stepBytes, Frame.boundary, TextMetrics.host), so the host's NSTextInputClient and its shadow of the field can be checked against Field.apply. The same ABI as cairn_app_* (docs/runtime.md), under other names so it can't clash.
  • cairn_tf_wrap: where Lean breaks a string into lines at a width with TextMetrics.host, and where layout puts each line, so the Swift side can shape each line as the renderer will and compare with Core Text's own line breaking.

Imports Cairn.Fuzz.Trusted.Gen, Cairn.Frame.Dump, Cairn.Abi, Cairn.Runtime.Abi, Cairn.Text.Host, Cairn.Text.Field, Cairn.Layout.Core

Order

Definitions 13

def

Cairn.Fuzz.Trusted.verdict

lean/Cairn/Fuzz/Trusted/Export.lean:32
verdict {α : Type} (decoded : Option α) (reencode : α → ByteArray)
  (dump : α → String) (b : ByteArray) : ByteArray

"A=", "A~" or "R", then the dump.

def

Cairn.Fuzz.Trusted.genFrame

lean/Cairn/Fuzz/Trusted/Export.lean:41
genFrame (seed : UInt64) : ByteArray
def

Cairn.Fuzz.Trusted.decodeFrameVerdict

lean/Cairn/Fuzz/Trusted/Export.lean:44
decodeFrameVerdict (b : ByteArray) : ByteArray
def

Cairn.Fuzz.Trusted.decodeEventsVerdict

lean/Cairn/Fuzz/Trusted/Export.lean:48
decodeEventsVerdict (b : ByteArray) : ByteArray
def

Cairn.Fuzz.Trusted.fieldRef

lean/Cairn/Fuzz/Trusted/Export.lean:53
fieldRef : ControlRef
def

Cairn.Fuzz.Trusted.fieldView

lean/Cairn/Fuzz/Trusted/Export.lean:57
fieldView (f : Text.Field) (ui : UI) : Node

One text field across the window, with a little padding so the field's text is inset and long text scrolls.

def

Cairn.Fuzz.Trusted.fieldUpdate

lean/Cairn/Fuzz/Trusted/Export.lean:63
fieldUpdate (f : Text.Field) : Action → Text.Field × List Effect
def

Cairn.Fuzz.Trusted.fieldApp

lean/Cairn/Fuzz/Trusted/Export.lean:67
fieldApp : App Text.Field
def

Cairn.Fuzz.Trusted.fieldCfg

lean/Cairn/Fuzz/Trusted/Export.lean:74
fieldCfg : Runtime.Config
def

Cairn.Fuzz.Trusted.fieldInit

lean/Cairn/Fuzz/Trusted/Export.lean:77
fieldInit (w h scalePercent : UInt32) : Runtime.State Text.Field
def

Cairn.Fuzz.Trusted.fieldStep

lean/Cairn/Fuzz/Trusted/Export.lean:81
fieldStep (s : Runtime.State Text.Field) (events : ByteArray) :
  Runtime.State Text.Field
def

Cairn.Fuzz.Trusted.fieldFrame

lean/Cairn/Fuzz/Trusted/Export.lean:85
fieldFrame (s : Runtime.State Text.Field) : ByteArray
def

Cairn.Fuzz.Trusted.wrap

lean/Cairn/Fuzz/Trusted/Export.lean:93
wrap (family size weight : UInt32) (style : UInt8)
  (tracking width : UInt32) (s : String) : ByteArray

A string wrapped at width (a para filling a window that wide), as int32s: the line count, then for each line its scalar range a, b, Lean's width for it (o b - o a) and the x, y, w of the line's laid-out rect.