Add wire codec roundtrip fuzz test generator#87
Open
dillonkearns wants to merge 1 commit intolamdera:lamdera-nextfrom
Open
Add wire codec roundtrip fuzz test generator#87dillonkearns wants to merge 1 commit intolamdera:lamdera-nextfrom
dillonkearns wants to merge 1 commit intolamdera:lamdera-nextfrom
Conversation
Adds an elm-pages + elm-codegen based generator that randomly creates Elm type definitions (unions, records, extensible records, alias chains, cross-module references) weighted toward edge cases, then generates elm-test fuzz tests proving the compiler-generated wire codecs are correct via roundtrip testing. Run with: cd test/scenario-alltypes && bash run-roundtrip-tests.sh The generator produces 15 type scenarios including extensible record alias chains, cross-module references, overlapping fields, deep alias chains, many-variant unions, and two-level extensible chains. The two-level extensible chain scenario surfaces a known bug where the wire codec generator loses fields when an extensible record extends another extensible record. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
97aa19d to
c00561c
Compare
Member
|
Thank you! This seems super useful! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey @supermario, I thought I'd add a random generator to try to surface any problematic permutations in types for the wire codecs. I was able to find one case that has errors, which I'll share in a separate issue or PR shortly.
For now, this PR adds an elm-pages + elm-codegen based generator that randomly creates Elm type definitions (unions, records, extensible records, alias chains, cross-module references) weighted toward edge cases, then generates
elm-testfuzz tests running the wire codecs in a roundtrip test.Run with:
cd test/scenario-alltypes && bash run-roundtrip-tests.shThe generator produces 15 type scenarios including extensible record alias chains, cross-module references, overlapping fields, deep alias chains, many-variant unions, and two-level extensible chains. The two-level extensible chain scenario surfaces a known bug where the wire codec generator loses fields when an extensible record extends another extensible record.
Happy to discuss if you have any feedback, and if you don't want to add this to the codebase no worries, still useful for running separately if you don't want to pull it in to this project directly! Just thought I'd share.