Skip to content

test: differential fuzzing sweep of ranges, multiranges and value sets against PostgreSQL - #113

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
test/differential-fuzz
Oct 17, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
test/differential-fuzz

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #104

Problem

The parity layer against PostgreSQL sweeps hand-picked rows: about ten shapes per domain in ShapeMatrixParityTests, five instants in TemporalStoreParityTests, a fixed list in UnionCanonicalityTests. Every value-level defect between memory and the database so far hid behind correct SQL until someone picked the row that showed it: IsAdjacentTo (6.2.1), IsStrictlyLeftOf and Except (7.0.0), and RangeSet.Except with infinity (8.0.0).

Change

  • DifferentialFuzzParityTests (integration project), with its helpers in Fuzzing/:
    • Generator (FuzzDomains). It is seeded per type, so CI draws the same rows every run, and a seed's first rows stay the same when the budget grows. Bounds are drawn near the extremes, the shared edges, the centre or another bound of the row, then stepped by a few units, so equal, adjacent, touching and off-by-one bounds come up constantly. It draws all five shapes, empties, and RangeSets of 0 to 5 members. Value sets draw from a small pool per row, so they have duplicates. Strings cover case and culture folds, composed and decomposed forms, whitespace, and characters an array literal must quote or escape. Temporal values include the extremes and are drawn at store precision.
    • Types are discovered by reflection, as MappingParityTests does: 11 range types plus their multiranges, and 30 value set types (closed sets and wrapper arities, BCL and NodaTime). An element type with no domain fails loudly.
    • Three legs per operation. Each operation is one expression. Compiled, it is the memory leg. Spliced into a query, it is the EF leg. That leg runs over a column operand (written through Npgsql's parameters), and once per probe as an inlined constant (the funcletized form EF produces) and as a parameter. The literal leg sends PostgreSQL's own operator over the literals the mapping writes. Value results are read back through the mapping's converter. That read-back is also what absorbs the documented (,min) domain boundary.
    • Operations. Range: the 8 relations, ==, Merge, Intersect, Union, Except, Contains(element), bounds, inclusivity, and the 5 shape checks. RangeSet: the same against a range, against a set, and against an element, plus the | & - operators, Merge, Complement, bounds and shape checks. Value sets: Contains, Overlaps, the four subset predicates, ==, Union (projected, and under <@, && and cardinality = 0 only, per the SQL guard), Remove and Count/IsEmpty.
    • Budget. 200 rows per type by default, which takes about 12 s, and about 40 s at 2,000 rows. VALUERANGES_FUZZ_ROWS and VALUERANGES_FUZZ_SEED widen the search locally. Each failure line carries the seed and row, and says "at the domain edge" when an operand touches an exact extreme.
    • Set aside on purpose. Literals PostgreSQL refuses with a data exception (22003, 22008, 22009, the documented domain boundary) are counted and set aside. Sub-microsecond temporal values are left out because TemporalStoreParityTests owns them.
  • Findings, each confirmed with psql on a bare postgres:17-alpine and registered in candidates.json:
  • Oracle machinery. The sweep is registered in oracles.json and added to heldBy of the 15 claims it holds. There are two new seeds: intersect-tied-end-keeps-receiver-inclusivity (ranges) and value-set-subset-ignores-tail (value sets). Candidates.Verdict gains requireEveryCandidate (default true), so a non-default seed does not report a candidate as fixed.
  • Docs. docs/testing.md gets a "The Differential Fuzzing Sweep" section, and docs/oracles.md gets "Generated operands" (the candidate row form, seeds, replay and shrinking).

Tests

  • dotnet test with Docker: all 8 projects green, 1,693 tests. The integration project takes 15 s.
  • The sweep is green at 200 rows, at 2,000 rows and with VALUERANGES_FUZZ_SEED=7. The 2,000-row run finds no family beyond the three above.
  • dotnet run tools/oracles.cs seeds intersect-tied-end and … seeds value-set-subset both print CAUGHT … → DifferentialFuzzParityTests. Both seeds fail the sweep for the planted reason: tied-end Intersect rows on every continuous type, and subset-predicate rows on every value set family.
  • No fix is in this PR. Each finding stays a filed candidate until its own fix PR removes the entry.

🤖 Generated with Claude Code

…s against PostgreSQL

DifferentialFuzzParityTests draws seeded random operands for every range,
multirange and value set type the packages define, discovered by reflection
(BCL and NodaTime). It requires memory, the EF Core translation (column,
inlined constant and parameter operands) and PostgreSQL's operator on EF's
literals to agree on every operation EF translates. 200 rows per type by
default (about 12 s). VALUERANGES_FUZZ_ROWS and VALUERANGES_FUZZ_SEED widen it
locally.

The first run found three families. They are registered as candidates:
IsUnboundedStart/End on (,) (#109), RangeSet.Overlaps on continuous domains
(#106), and adjacency at the date extremes (#110). Two seeds prove the sweep
fails (both CAUGHT by tools/oracles.cs). Candidates.Verdict gains
requireEveryCandidate so that another seed does not report a candidate as
fixed.

Closes #104

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (oracles, harnesses); no library code area/ranges Range unions, variants and the shape engines area/range-set RangeSet and multirange algebra area/value-sets Value set families and wrapper arities package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/core Affects CodoMetis.ValueRanges labels Oct 17, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 804b9dc into main Oct 17, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the test/differential-fuzz branch October 17, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/range-set RangeSet and multirange algebra area/ranges Range unions, variants and the shape engines area/value-sets Value set families and wrapper arities package/core Affects CodoMetis.ValueRanges package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL tests Adds or changes tests only (oracles, harnesses); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Differential fuzzing sweep: random ranges, RangeSets and value sets against PostgreSQL

1 participant