Native fuzz tests
Fast, stateful tests of the actual SDK implementations, without PocketIC. Each input starts with fresh storage. Stateful targets run up to 128 operations against an independent ownership or byte model; migration targets also exercise fixed compiled version transitions. The same target code runs in deterministic smoke tests and coverage-guided libFuzzer campaigns.
From the repository root:
# Once: fetch locked dependencies into tests/fuzz/tmp/.
python3 tests/fuzz/run.py prepare
# Quick check: authored seeds plus 64 mutation/random cases per target.
python3 tests/fuzz/run.py smoke
# More deterministic cases, with a reproducible seed.
python3 tests/fuzz/run.py smoke all --cases 1024 --seed 42
# Once: also install the pinned cargo-fuzz tool privately.
python3 tests/fuzz/run.py prepare --coverage
# AddressSanitizer, coverage feedback, debug assertions and overflow checks.
# The time budget applies separately to each target, after compilation.
# A failing target does not stop the rest; a summary follows and the exit is nonzero.
python3 tests/fuzz/run.py fuzz all --seconds 30
python3 tests/fuzz/run.py fuzz heap --seconds 300 --seed 42
# Parallel workers per target, continuing past crashes and saving each input.
python3 tests/fuzz/run.py fuzz wire_types --seconds 300 --jobs 8
# Replay an authored hex seed or a raw generated input.
python3 tests/fuzz/run.py replay heap tests/fuzz/seeds/heap/mixed_classes_resize.hex
python3 tests/fuzz/run.py replay heap tests/fuzz/tmp/artifacts/heap/crash-HASH --coverage
The existing SDK compiler must already be installed as described in the
SDK compiler setup. These runners currently
target Linux x86-64. They source the SDK environment and use its pinned compiler;
they do not install or modify it. Python 3.11+, a C++ toolchain and the usual
native Rust linker dependencies are required. prepare permits dependency
downloads; subsequent builds and runs are offline. The lockfile pins Rust
dependencies, including libfuzzer-sys 0.4.12; the private cargo-fuzz version is
0.13.2. One runner owns the build caches at a time.
Targets
The table covers all 31 targets registered in src/lib.rs. Each target's source header documents its exact bytecode and bounds.
| Target | Real implementation exercised | Independent checks |
|---|---|---|
page_pool |
Shared page Pool over bounded backing that moves on growth | Linear first-fit run ledger; exact owner/run queries, alignment, protected ranges, live bytes, Store zeroing, growth refusal, quiescent Runtime recovery |
heap |
Ordinary Heap and HintedHeap over a pinned PageSource | Exact provider run/base/count ledger; live allocation alignment and disjointness, initialized bytes, resize prefix and refusal preservation, complete final release |
vec_memory |
Plain and sparse retained VecMemory | Byte/extent model; growth, direct and region loans, pair isolation, bounds, ordinary callback errors, reopen and genuine Runtime holes |
hylix |
Arena over VecMemory with small cache configurations | Live block/byte model; cache pressure, resize, overlapping copies, stale generations, nested reads, root identity and commit/reopen |
hylix_api |
Hylix Queue, Vec, Map and Blob APIs the ownership targets do not call directly | std models and exact-block ledger; ring wrap, prefix visits and retirement, comparison lookups, all range bound kinds, field reads, transient round trips |
hylix_tokens |
Arena Block admission, read-only frames and Plain records | Mutated live and stale tokens refused by every validating call; survivors unchanged; read-only frames never reach the provider; reopen with different cache settings |
hylix_codec |
Stable codecs over arbitrary bytes | No panic; wrong lengths refused; accepted values reach an encoding fixed point |
hylix_handles |
Hylix scoped owners, shared snapshots, cells and read-only frames | Exact-block ledger proves every displaced or discarded owner retires once; snapshots, identities and counts against a model |
hylix_faults |
Arena/cache reads over a fault-injecting provider | Recoverable full/partial read failures, retry, nested reads and reopen; writes never inject a consuming failure |
hylix_map |
Owned-key Map and scalar Set | Ordered std models, splits/deletions/root shrink, bounded ranges, shared payload identities and exact retirement |
hylix_owners |
Vec/Queue movement and SharedCell with nested shared Blob | Edge/count ledger, conflicting loans, aliases, replacement, carrier reopen and final release |
hylix_transform |
Synchronous consuming collection transforms | Independent filtering/collision model, displaced-target retirement and nested owner identities before conversion |
nyxus |
Public Nyxus allocator, Vec and Box | Exact live layouts, alignment, initialized bytes, resize preservation, impossible growth and final release |
minima |
Collection/detached block ownership | Physical allocation ledger, growth/truncation, stale/foreign owner refusal, reopen and reuse |
minima_hylix |
Minima collections and Hylix sharing one physical provider | Separate logical/physical ownership models, virtual mapping, byte checks, read-only frames and joint reopen |
store_tree |
Native Store ChildMap/ChildSlot ownership | Independent live tree and destructor ledger, moves, retirement, stale bindings and ancestor-cycle refusal |
store_frames |
Buffered Hylix module records in Store frames | Independent rows/owners, repeated writes/reads, projected fields, aliases, dirty orphan retirement and read-only behavior |
store_migration |
Fixed V1/V2/V3 owner-local Store conversion | Independent nested state, retained identities, opaque attachment transfer, ownership/filtering and admission checks |
ashroot_mutations |
Matched Nyxus/Hylix/Minima table mutations | Complete primary/index BTreeMap oracle after every operation and refusal, including bounded-prefix batches |
ashroot_relations |
Cascade, Restrict and SetNull with nullable uniqueness | Independent closure/final-candidate oracle, grouped validity, refusal preservation and exact index state |
ashroot_migration |
Actual V1→V2→V3 table conversions | Independent row/index/edge oracle, moved native and stable owners, removed-table retirement and source refusals |
wire |
Bounded Wire frames | Independent sparse-root encoder; malformed frames, method and direction identity |
wire_types |
Wire decoding of endpoint-shaped types, including Nyxus containers and DEFAULT_LIMITS argument tuples |
Value round trip; byte limits; refused integer forms; hostile length prefixes; Nat and Int against native integers |
tripwire |
Lazy requests, nested lists and source windows | Independent eager parser; boundary sweep of every directory word; ranged and chunked reads; byte limits; failing or lying Sources |
minima_collections |
FixedVec, SlotArena, BitmapSet, FrozenPrefixSums, FrozenSortedMap, FrozenHashMap | std models; exact free-list reuse and generations; paged ranges resumed to completion; overflow refused before allocation |
minima_filters |
Bloom, Counting Bloom, Cuckoo, Binary Fuse, Ribbon, FrozenHashSet | No present key is ever denied; Ribbon returns each stored value; hash set is exact; duplicates refused |
minima_sketches |
Count-Min, HLL, ExaLogLog, SetSketch, QSketch, DDSketch, OmniSketch, Memento, Aeris, Breadcrumb, ZOR, PHOBIC, Rateless IBLT, external graph sketch | Merge equals the union bit for bit; batch and scratch paths equal scalars; no undercount or false negative; quantiles within accuracy; refinement turns a range negative; PHOBIC injective; IBLT difference exact; samples are real crossing edges |
minima_graph |
Packed, paged, delta and frozen graphs, BFS, intersection, compaction | Ordered maps in both directions; pages, anchors and filters; shortest paths; resumable cursors under growing budgets; stale cursors refused |
graph_nyxus |
NyxusGraph | Ordered maps in both directions; sequential batch semantics across the bulk path; a rejected batch changes nothing |
nyxus_shared |
SharedSlice, SharedBytes, SharedText, append builder, String, Rc, Vec, Map, Set, Queue, Box | Byte and owner models; exact strong counts; range and UTF-8 refusals; destructor ledger through split, replacement and copy-on-write |
executor |
Protected and migratory tasks, method handles, recovery, shutdown | Exact queue simulation: poll order and counts, destructor counts, and the query and recovery state each destructor observes |
Heap inputs use 8–16 provider pages, PagePool uses 16–32 pages, and VecMemory
uses at most 16 pages. Hylix has at most 16 live blocks with payloads up to 8,193
bytes. Full survivor checks run between operations and during cleanup, except in
page_pool, vec_memory, hylix_map and hylix_transform: those run them every
FULL_CHECK_INTERVAL operations and throughout cleanup, keeping each operation's
own assertions. A fault fails the same input, only some operations later.
hylix_transform also samples its per-callback sweeps and cleanup, inspecting each
row immediately before it is converted or removed, so no row is consumed unseen. PagePool
recovery and reattachment are bounded separately because full format validation
scans the platform's entire metadata capacity.
The PagePool model deliberately checks the current first-fit placement policy;
a future valid placement-policy change must update that expectation.
Unsafe calls receive only exact live allocations with their current layouts or
exact live page runs. Invalid inputs go to safe validating APIs. Newly allocated
payload and resize growth are initialized by the harness before reading them;
zero fills in the Heap target do not test a zeroed-allocation facade. No loan or
payload pointer survives backing relocation. Callback Err preserves writes;
the harness does not simulate IC rollback by catching a panic and continuing.
Layout and failures
tests/fuzz/
src/targets/ # state machines, models and bytecode documentation
src/bin/ # deterministic seed replay and mutation runner
fuzz_targets/ # thin libFuzzer entry points into the same targets
seeds/<target>/ # authored, commented .hex programs; reduced regressions go here
scripts/ # private build environment
run.py # prepare, smoke, fuzz and replay
tmp/ # ignored tools, dependencies, builds, corpus and crash artifacts
Generated corpus lives in tmp/corpus/<target>/; failures go to
tmp/artifacts/<target>/. Successful campaigns reuse the corpus on later runs.
Smoke assertion failures save the input as tmp/artifacts/<target>/smoke-failure
before propagating the panic; the failed state is discarded. Process aborts and
external kills cannot use that panic handler.
Keep generated inputs and build output out of Git. Preserve a confirmed failure
as a small commented hex regression seed once its driver assumptions have been
checked. The operation encodings are documented at the top of each target.
These tests complement the formal verification.
They check concrete native histories; they do not prove arbitrary histories,
Wasm's shared linear-memory implementation, installed upgrades or IC rollback.
AddressSanitizer observes the provider's backing allocation rather than every
internal slab lifetime, so the independent ownership and byte checks remain
essential. Timers have no target: their system calls exist only inside a canister,
so the public API needs a test seam. Wasm-only paths such as argument_with_limits
and 32-bit layouts stay out of reach of these native runs.
Only API callers are untrusted. Their bytes reach Wire and Tripwire, and the SDK's
compile-fail tests keep stable identities out of both. Developer code decoding a
Codec from stored bytes is trusted, so hylix_tokens does not model tokens aimed
at payload crafted as a descriptor and header.