✅ Assert the fast emitter's output always re-parses in differential fuzz#148
Conversation
The differential oracle (check_emit_roundtrip, shared by the differential and differential_options targets) silently returned when the re-emitted YAML failed to re-decode, split into several documents, or was invalid UTF-8. That hid the worst dumps bug class: output a reader rejects or reshapes, with no crash to flag it. Tighten the oracle so each of those is a hard finding. The fast emitter takes a freshly decoded Value tree (no user edits), so it must always produce valid YAML that loads reads back as the same single document. The lenient roundtrip target (round-trip emitter, re-emits modified documents) is left untouched. This closes the fuzz-and-fix pass: the three emitter bugs the strict oracle surfaced are fixed and merged (#144, #145, #146), and both differential targets now run clean under it (702k and 1.5M executions, zero findings).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe differential fuzz harness now treats emitter roundtrip failures as hard assertions. It panics on invalid UTF-8, YAML re-decode failures, and reparsing into anything other than exactly one document, then continues with the existing Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR tightens the differential fuzz oracle (check_emit_roundtrip, shared by the differential and differential_options targets) so that the fast emitter's output is held to a strict re-parse invariant. Previously, invalid UTF-8, re-decode failures, and multi-document output were silently returned (skipped); now each is a hard panic. Since the fast emitter operates on a freshly decoded Value tree with no user edits, any such outcome is a genuine dumps bug. The change is fuzz-harness only and touches no library code or public API. It is the closing step of an emitter hardening pass whose three surfaced bugs were already fixed in #144, #145, and #146.
Changes:
- Convert the three lenient
returnskips (UTF-8 decode, re-decode, document-count) into hard assertions with descriptive panic messages that name the triggering options, input, and emitted text. - Update the
differentialandcheck_emit_roundtripdoc comments to reflect the strict-assertion contract and document the three bugs this oracle surfaced.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Breaking change
None. This change is fuzz-harness only; it touches no library code and no public API.
Proposed change
The differential fuzz oracle (
check_emit_roundtrip, shared by thedifferentialanddifferential_optionstargets) used to silentlyreturnwhen the re-emitted YAML failed to re-decode, split into several documents, or was invalid UTF-8. That hid the worstdumpsbug class: output a reader rejects or reshapes, with no crash to flag it.This tightens the oracle so each of those is a hard finding. The fast emitter takes a freshly decoded
Valuetree (no user edits), so it must always produce valid YAML thatloadsreads back as the same single document; anything else is adumpsbug. The lenientroundtriptarget (the round-trip emitter, which re-emits modified documents and can legitimately produce composer-rejected output for exotic inputs) is left untouched.This is the closing step of the fuzz-and-fix pass: the three emitter bugs the strict oracle surfaced are already fixed and merged (#144 quoting a
...document-end marker, #145 keeping a folded scalar off a marker line, #146 indenting a tagged sequence item under its dash). With those in, both differential targets now run clean under the strict oracle (702k and 1.5M executions locally, zero findings).Type of change
Additional information
Checklist
uv run pytestpasses locally. A pull request cannot be merged unless CI is green.uv run ruff check .anduv run ruff format --check .pass.cargo fmt --checkandcargo clippy --all-targets -- -D warningspass.If the change is user-facing:
docs/is added or updated, anddocs/verify_examples.pystill passes.