Skip to content

fix: the infinite range answers IsUnboundedStart and IsUnboundedEnd as lower_inf and upper_inf do - #168

Merged
CaffeinatedCoder merged 4 commits into
mainfrom
fix/infinite-range-is-unbounded
Oct 18, 2026
Merged

CaffeinatedCoder merged 4 commits into
mainfrom
fix/infinite-range-is-unbounded

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #109

Stacked on #167 (fix/rangeset-overlaps-previous-element): merge that first, then retarget this to main.

Problem

IsUnboundedStart() and IsUnboundedEnd() on a single range tested the variant, so the infinite range (,) answered false to both. EF Core translates them to lower_inf and upper_inf, which answer true for it, and the one-element RangeSet holding (,) answered true as well. A query and the same predicate in memory therefore disagreed on every row holding (,), for all eleven range types, with no error. docs/ranges.md and docs/efcore.md promised the PostgreSQL meaning; only the XML doc promised the variant test.

Change

PostgreSQL is the authority, so memory moves:

  • src/CodoMetis.ValueRanges/RangeExtensions.cs: IsUnboundedStart() is IUnboundedStartRange<T> or IInfinityRange<T>, IsUnboundedEnd() likewise; the XML docs say so, name lower_inf/upper_inf, and point at the variant interfaces for the exact shape test. IsInfinity() and IsFinite() are unchanged and now follow from the three primitives in memory as they do in SQL.
  • The translation stays lower_inf / upper_inf. QueryTranslationTests.Range_StateChecks_TranslateToRangeFunctions now also asserts it does not narrow to exclude (,), which was the other way to agree.
  • test/oracles/candidates.json: the 24 rows for IsUnboundedStart/IsUnboundedEnd on the infinite range answer false in memory and true through EF Core (lower_inf) #109 (2 DifferentialFuzzParityTests, 22 RangeSetLiftParityTests) are removed.
  • CHANGELOG.md, src/CodoMetis.ValueRanges/CHANGELOG.md, docs/migration.md: the Breaking row and the Check IsUnboundedStart() and IsUnboundedEnd() on the infinite range section.

Tests

  • RangeShapePredicateTests: Infinite_IsUnboundedAtBothEnds_AsLowerInfAndUpperInfAre, the two HoldsFor…AndTheInfiniteRange tests, EveryShape_IsExactlyOneVariant and IsInfinityAndIsFinite_FollowFromTheUnboundedChecks. Four fail with the fix reverted.
  • ExecutedQueryTests.RangeShapePredicates_MatchInMemory (integration): the five checks over a row of each shape, memory against the server row by row, the infinite row pinned to true, and a Where(IsUnboundedStart) returning the rows memory selects. With the fix reverted: IsUnboundedStart on (,) expected False actual True.
  • With the fix reverted, RangeSetLiftParityTests reports 22 unregistered lines (<Type> (,) IsUnboundedStart: range → False, RangeSet → True) and DifferentialFuzzParityTests 354, since their candidates are gone.
  • The whole suite, including both integration projects in Docker, is green.

🤖 Generated with Claude Code

…s lower_inf and upper_inf do

IsUnboundedStart() and IsUnboundedEnd() on a single range tested the variant,
so the infinite range (,) answered false to both. EF Core translates them to
lower_inf and upper_inf, which answer true for it, and the one-element RangeSet
holding (,) answered true as well, so a query and the same predicate in memory
disagreed on every row holding (,), for all eleven range types, without an
error. docs/ranges.md promised the PostgreSQL meaning ("the state checks match
isempty, lower_inf and upper_inf"); only the XML doc promised the variant test.

PostgreSQL is the authority, so the two methods now answer true for (,) too.
The translation stays lower_inf / upper_inf and QueryTranslationTests pins that
it does not narrow to exclude (,); the variant interfaces remain the exact
shape test. IsInfinity and IsFinite are unchanged and now follow from the three
primitives in memory as they do in SQL.

ExecutedQueryTests.RangeShapePredicates_MatchInMemory runs the five checks over
a row of each shape and pins the infinite row to true; RangeShapePredicateTests
asserts the new partition. With the fix reverted both fail, and the
RangeSetLiftParityTests and DifferentialFuzzParityTests candidates for #109,
removed here, come back as unregistered rows (22 and 354 lines).

Closes #109

Found-By: OT
Defect-Class: ALG

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.0.0 milestone Oct 18, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred breaking Changes an answer or a signature — needs a major found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) area/ranges Range unions, variants and the shape engines package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/core Affects CodoMetis.ValueRanges severity/medium Inconsistency or failure in a narrow scenario stacked Base is another open PR; merge in order, CI does not run until it targets main labels Oct 18, 2026
…te-range-is-unbounded

# Conflicts:
#	test/oracles/candidates.json
Base automatically changed from fix/rangeset-overlaps-previous-element to main October 18, 2026 14:11
@CaffeinatedCoder CaffeinatedCoder removed the stacked Base is another open PR; merge in order, CI does not run until it targets main label Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 28e8239 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/infinite-range-is-unbounded branch October 18, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ranges Range unions, variants and the shape engines breaking Changes an answer or a signature — needs a major bug Something isn't working found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) package/core Affects CodoMetis.ValueRanges package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL severity/medium Inconsistency or failure in a narrow scenario silent Answers wrongly without throwing — fixes go in the next major, never deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IsUnboundedStart/IsUnboundedEnd on the infinite range answer false in memory and true through EF Core (lower_inf)

1 participant