Skip to content

Fuzz parity with markcopy: oracles, surface manifest, seed corpus, engine faults, nightly soak - #24

Open
owenpkent wants to merge 7 commits into
windows-release-bundlefrom
fuzz-parity
Open

owenpkent wants to merge 7 commits into
windows-release-bundlefrom
fuzz-parity

Conversation

@owenpkent

@owenpkent owenpkent commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Brings offloader's fuzzing up to the practices in markcopy's fuzzing strategy, adapted to Hypothesis.

What changes

  • Shared oracle (tests/fuzz_oracle.py): only documented exceptions, a time and memory ceiling per input, no NaN or infinity in a result. Per-test example caps now scale under --fuzz instead of pinning the soak at 20 to 40.
  • New parser targets (tests/test_fuzz_parsers.py): iXML, RIFF chunk walking, the ASC MHL reader, timeline file: URLs, and a differential verify target. Manifests and hashes are produced by the test, and a pass must match the files' current bytes.
  • State files (tests/test_fuzz_state.py): read_json, history, and the CLI control file. Covers no guessed cancel, a cancel staying final, and claim never overwriting a non-control file.
  • Whole offloads under faults (tests/test_fuzz_engine.py): random cards and pre-existing copies. Faults fail reads, writes, fsync or promotion, corrupt a staged copy before its reread, or cancel mid-job. The checks run against the bytes on disk. 1200 offloads at --fuzz depth: no violation. A planted skipped checksum comparison or a no-op _discard fails the target at the quick budget.
  • Surface manifest (tests/fuzz_surfaces.json and tests/test_fuzz_surfaces.py): every module is mapped to its fuzz targets or to a stated gap. The test fails on an unclassified module or an unclaimed fuzz test.
  • Seed corpus (tests/fuzz_corpus/, tests/fuzz_targets.py, tests/make_fuzz_seeds.py): 32 generated seeds, replayed on every test run. Every fix below is also an @example and a regress-* seed.
  • Nightly soak (.github/workflows/fuzz.yml): runs on Linux and Windows, carries the Hypothesis example database between runs, and opens or updates a Fuzz failure: <os> issue from a separate job that holds the only write token. The soak job is removed from ci.yml.

Fixes found by the new targets

  • A damaged encoding declaration in a previous ASC MHL manifest raised LookupError or ValueError out of the reader, which failed the next ASC MHL report. verify now reports such a manifest as a ParseError.
  • An iXML frame rate of inf was accepted and reached the sound report.
  • Deeply nested JSON raised RecursionError out of read_json, so a damaged history file stopped History from loading.
  • A history file_count of 1e400 dropped the whole record and its duplicate-card warning.

Each fix has a regression test that fails without it.

Verification

  • Ran locally on Windows, Python 3.12: lint clean, 982 passed, 7 skipped.
  • The full soak at 3000 examples passed in 7 minutes. The nightly command at 300 examples passed.
  • The issue-filing script was dry-run against fake logs with a stubbed gh.
  • fuzz.yml has not run on GitHub yet. GitHub runs both its schedule and its manual workflow_dispatch trigger only once the file is on the default branch, so the first real run happens after this reaches main. Trigger it by hand then, rather than waiting for the night.

Known gaps

These are listed in tests/fuzz_surfaces.json: companions, installation, longpath, thumbs, volumes, timeline documents, whole ffprobe JSON, source scanning, and pause, paranoid rereads and concurrent instances in the engine fault plan.

Port the oracle-first approach from markcopy's fuzzing strategy.
tests/fuzz_oracle.py holds the checks every parser target applies: only
documented exceptions, a time and memory ceiling per input, and no NaN or
infinity in the result. tests/test_fuzz_parsers.py adds targets for iXML,
RIFF chunk walking, the ASC MHL reader and timeline file: URLs, plus a
differential verify target: manifests are written by the test, hashes are
taken by the test, and a pass must be backed by a hash taken now.

Fixes found by the new targets:

- A damaged encoding declaration in a previous ASC MHL manifest raised
  LookupError (or ValueError for a multi-byte encoding) out of the reader,
  failing the next ASC MHL report instead of starting a new generation.
  verify now reports such a manifest as a ParseError.
- An iXML frame rate of inf was accepted and reached the sound report.

Per-test max_examples now scale with the loaded profile, so --fuzz goes
deeper on the PDF, report and flat-mode properties instead of staying at
20 to 40 examples. .hypothesis/ is ignored.
tests/fuzz_surfaces.json classifies every module under src/offloader and
src/offloader/reports as a surface that reads or renders outside input,
with the Hypothesis tests that fuzz it, or as not a surface, with a
reason. A surface with nothing fuzzed, or only part of it, records the
gap instead of implying coverage: companions, config, history,
installation, longpath, thumbs and volumes have no target yet, and the
OTIO documents, ffprobe JSON, control files and copy/verify/cancel
sequences are listed as gaps on the modules that own them.

tests/test_fuzz_surfaces.py reads files only and fails on an unclassified
module, a listed path that is gone, a surface with neither a target nor a
gap, a target that is not a @given test, a @given test no surface claims,
or a fuzz file missing from the CI soak job's pytest line. Ported from
markcopy's fuzz coverage manifest.
tests/test_fuzz_state.py covers the files kept between runs, each against
an independent reading of what the bytes mean: read_json returns the value
or the default, History keeps every record with a fingerprint, a control
file moves the job only on a whole control word, a cancel stays final, and
claim never overwrites a file that is not a control word.

Fixes found by the new targets:

- Deeply nested JSON raised RecursionError out of read_json, so a damaged
  history.json stopped History from being built.
- A file_count of 1e400 raised OverflowError in HistoryEntry.from_dict,
  dropping the record and the duplicate-card warning its fingerprint gives.

config.py and history.py move from gaps to fuzzed surfaces, and the
control-file targets are listed under engine.py.
Byte-level fuzz targets move to tests/fuzz_targets.py as bytes -> None
functions (braw, riff, ixml, ascmhl, state-json, history, control), so
the Hypothesis tests and a replay share one statement of each property.
tests/fuzz_corpus/<target>/ holds 32 small seeds generated from the
unit-test builders by tests/make_fuzz_seeds.py, including the input behind
every bug the fuzzers have found. tests/test_fuzz_corpus.py replays each
seed through its target in the ordinary suite, and checks that every
corpus folder is a target and every target has seeds.

Every fix found so far is also an @example on the target that found it.
With the fixes reverted, all regression seeds and examples fail.

The corpus is marked binary in .gitattributes, so line-ending
normalisation cannot rewrite a seed such as "pause\r\n".
tests/test_fuzz_engine.py runs engine.run end to end on a random card,
against destinations that may already hold a good copy, a stale one, a
truncated one or a same-size impostor, in each verification mode, with
skip and replace on or off. A fault plan fails source reads, destination
writes, fsync or promotion, transiently or for good, once or from then on;
corrupts a staged copy before its full reread; or cancels the job at an
arbitrary progress event.

The oracle checks the bytes on disk, not the job's account of them: run
raises nothing and finishes within a watchdog, the source is unchanged, no
partial survives and nothing else appears, every final-named file is the
old one or exactly the source, a different existing file survives unless
replace_existing, Verified and Copied destinations hold the source, and a
"Verified" job had every destination verified, was not cancelled, saw no
fault that kept failing and omitted no file.

1200 offloads at --fuzz depth found no violation. Planting a skipped
checksum comparison or a no-op _discard in the engine fails the target at
the quick budget. Hypothesis events report which faults fired and which
verdicts resulted, so a harness that stops reaching the engine shows up in
--hypothesis-show-statistics.
The soak took about 7 minutes on every pull request and ran on Linux
only. .github/workflows/fuzz.yml now runs the whole suite under --fuzz
nightly and on demand (with an example count input), on ubuntu-latest and
windows-latest, with a 60-minute timeout. Hypothesis's example database is
carried between runs through actions/cache, so a failure found one night
is replayed first the next.

Permissions are split: the soak job holds a read-only token, and a
separate report job with issues: write opens or comments on a
"Fuzz failure: <os>" issue carrying the run link and the falsifying
examples with their @reproduce_failure lines. A placeholder log and a
!success() upload mean a setup failure or a timeout still reaches an
issue. The fuzz profile now prints those blobs and reads its depth from
OFFLOADER_FUZZ_EXAMPLES.

Pull requests keep every property at 100 examples and the seed corpus
replay; the soak job is removed from ci.yml. test_fuzz_surfaces now checks
that fuzz.yml is scheduled and runs every fuzz module. The release plan's
candidate qualification adds a dispatched soak run and no open
"Fuzz failure:" issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant