epiphany/crates
Levi Neuwirth 7e7a43b050 Fuzzer P1: adversarial decode fuzz + strict-canonical decode + bounded counts
Stands up the Binary Format companion's wire-format-fuzzer charter item as a
core adversarial byte-decode harness, and lands the three robustness fixes it
drove out. The canonical decoders are a trust boundary (a hostile bundle, a
bit-rot chunk, a mismatched implementation), so every byte string must decode
to a clean Err -- never panic, over-allocate, or loop unboundedly -- and any
accepted string must re-encode to itself (canonical decode is injective).

- epiphany-core/src/fuzz.rs (new): run_decode_fuzz mutates a once-built corpus
  (random, substitution, truncation, trailing garbage, length-prefix
  corruption, wrong-type payload, genuine-v0-form) against Score::decode_canonical,
  the versioned seam (v1 + the frozen v0 migration), and a per-value decoder;
  asserts no-panic + injective decode over ~40K inputs/run. Two seeds, plus
  deterministic prefix-rejection sanity tests.

- Strict-canonical decode (the fuzzer's first finding): decode reconstructed via
  normalizing constructors (RationalTime reduces, BTreeSet/BTreeMap re-sort, a
  CanonicalF64/ReferencePitch/Tempo normalizes via new), so distinct byte
  strings could map to one value. Fixed complete-by-construction: Score::
  decode_canonical and the CanonicalValue macro re-encode and reject any input
  not already its canonical form; decode_v0_score does the same against the
  frozen v0 wire form (encode_v0_score promoted to production), so major-0
  snapshots are injective too.

- Bounded collection count (Reader::count): reject any count/length exceeding
  the bytes remaining. A garbage u32 count was a soft-DoS -- decoders looped
  element-by-element toward EOF (e.g. misparsing v1 bytes as v0), ~100ms per
  adversarial input; the bound also caps Vec/set allocation and gives a ~2600x
  fuzz speedup (422s -> 0.16s). Codec round-trips confirm no valid data has
  zero-byte-element collections, so the bound never rejects a real encoding.

Full gate green (workspace tests, clippy -D warnings, fmt, rustdoc -D warnings).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NEs4aYiu8MXjdYdMxw8PTd
2026-07-07 09:42:04 -04:00
..
epiphany-bundle Schema major 1 Phase D2: CreateRegion op-block major + cross-major read-only 2026-07-06 12:09:30 -04:00
epiphany-core Fuzzer P1: adversarial decode fuzz + strict-canonical decode + bounded counts 2026-07-07 09:42:04 -04:00
epiphany-determinism P12-I2: wire the ratified MUSCLOID layout-object id derivation 2026-06-27 12:46:19 -04:00
epiphany-editor-core Phase 3 tranche 2: quality conformance companions, real metrics, multi-system click fix 2026-07-03 10:39:05 -04:00
epiphany-editor-gui Phase 3 tranche 1: casting-off, K1 schema-fill, value-restoring undo 2026-07-02 21:55:26 -04:00
epiphany-engrave Schema major 1 Phase F: ratify engrave I8/I9/I10 + process trail 2026-07-06 17:40:38 -04:00
epiphany-layout-ir Schema major 1 Phase F: ratify engrave I8/I9/I10 + process trail 2026-07-06 17:40:38 -04:00
epiphany-ops Schema major 1 Phase D2: CreateRegion op-block major + cross-major read-only 2026-07-06 12:09:30 -04:00
epiphany-render-svg Clear P12-I11: casting-off widow-rebalance evens the stub last system 2026-07-03 19:09:51 -04:00
epiphany-testkit Schema major 1 Phase D2: CreateRegion op-block major + cross-major read-only 2026-07-06 12:09:30 -04:00