test(hdf-converters): add adversarial schema-validation corpus - #242
Open
wdower wants to merge 1 commit into
Open
test(hdf-converters): add adversarial schema-validation corpus#242wdower wants to merge 1 commit into
wdower wants to merge 1 commit into
Conversation
Six exporters have schema-validation tests, but every one validates only fully-populated happy-path fixtures. Edge-case tests exist across most converters and assert on structs, thrown errors, or string contents — they never feed output back through the validator. Schema coverage and edge-case coverage are disjoint sets, which is why five spec-violating defects shipped undetected. Add a shared corpus split into the two contracts an exporter owes, which are opposites and were previously conflated: sparse-but-schema-valid HDF must convert into schema-valid output, while HDF the source schema rejects must be refused — never with a panic, and never with a success carrying an invalid document. Each case's tier is asserted against the real HDF schema, so a mislabeled case fails loudly instead of quietly asserting the wrong contract. The per-case contract is a pure function rather than assertions inside a subtest closure, so the runner's own logic is testable. Cross-language parity is enforced byte-for-byte: both sides canonicalize (sorted keys, matched escaping, normalized -0) against a Go-generated golden that TypeScript only verifies, so neither side can redefine the corpus to match itself. Adoption is opt-in per converter; no exporter is wired up yet. Signed-off-by: Will Dower <will@dower.dev>
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.
Six exporters have schema-validation tests, but every one validates only fully-populated happy-path fixtures. Edge-case tests exist across most converters and assert on structs, thrown errors, or string contents — they never feed output back through the validator. Schema coverage and edge-case coverage are disjoint sets, which is why five spec-violating defects shipped undetected.
Add a shared corpus split into the two contracts an exporter owes, which are opposites and were previously conflated: sparse-but-schema-valid HDF must convert into schema-valid output, while HDF the source schema rejects must be refused — never with a panic, and never with a success carrying an invalid document. Each case's tier is asserted against the real HDF schema, so a mislabeled case fails loudly instead of quietly asserting the wrong contract.
The per-case contract is a pure function rather than assertions inside a subtest closure, so the runner's own logic is testable. Cross-language parity is enforced byte-for-byte: both sides canonicalize (sorted keys, matched escaping, normalized -0) against a Go-generated golden that TypeScript only verifies, so neither side can redefine the corpus to match itself.
Adoption is opt-in per converter; no exporter is wired up yet.