protocol/testing/arbitraries
packages/protocol/src/testing/arbitraries
Purpose
Public barrel for schema-derived protocol arbitraries used by tests.Public surface
allRpcMethods
Variable
RpcMap directly.
arbitraryAnyCall
Function
arbitraryCallFor
Function
arbitraryConfidentCall
Function
fc.constantFrom(...kept).chain( arbitraryCallFor). Probe at module load uses the same
arbitraryCallFor(m) generator as execution — so confidence is
checked on the same distribution the property exercises.
If a kept method turns out to be param-sensitive under a later
draw (model predicts ok for the one probe sample but rejects a
subsequent arbitrary-drawn params), the safety-net guard in
registerModelEquivalence raises PropertyInvariantViolation
pointing at this file — the fix is to widen the derivation (probe
K > 1 samples and keep only methods where every probe predicts ok)
per the architect’s contract. Single-probe is sufficient when
applyCall is method-only (today).
arbitraryForParams
Function
Type.Unknown, Type.Any)
produce open-world trees that drown properties in noise. This returns a
narrowed arbitrary still Value.Check-valid against schema but biased
toward “small typical” values the reference model can reason about.
For now the narrowing strategy is identical to arbitraryFromSchema with
smaller default string/array bounds (handled inside walk). Exposed as a
distinct export so call sites document their intent.
arbitraryFromSchema
Function
Arbitrary<Static<S>> for any TypeBox schema. The derivation
is pure: given the same schema + fast-check seed, it yields the same
value tree (AC10 reproducibility).
arbitraryMalformedFrame
Function
ArbitraryMalformedFrame
Interface
(baseFrame, MalformedFrameKind, seed) tuple so Tier A /
D can replay a specific mutation on shrink.
arbitraryNotificationFrame
Function
arbitraryRequestFrame
Function
arbitraryResponseFrame
Function
ArbitraryRpcCall
Interface
confidentOracleMethods
Variable
_tag: "ok"
for on initialReferenceState — derived mechanically at module load
by probing applyCall with a single drawn params value per method.
Per architect #197 §2.2: this is NOT a hand-curated list. Methods
move in/out of the confident set automatically when applyCall’s
allowNoEvents / uncertainError split moves, so the sampling
distribution tracks the model.
Param-invariance contract: every kept method is treated as
oracle-confident for every params value. If a future applyCall
amendment branches on call.params, the safety-net guard in
registerModelEquivalence (rpc-semantics.ts) fires loudly on the
first non-confident draw and the derivation must widen from the
single-probe form to an fc.sample-based invariant check.
Files
frames.tsfrom-typebox.tsrpc.ts