Repository navigation
fix: a finite bound can't land on infinity, and a closed end at the minimum moves - #267
Merged
Merged
Conversation
…inimum moves #224 kept a bound that stands for an infinity where it is under Shift and Expand. Two edges of that rule were wrong. A finite bound moved onto such a value stayed there, so it saved as the infinity and Shift(d).Shift(-d) was not the range: [9999-12-01, 9999-12-29].Shift(1).Shift(-1) was [9999-12-01,9999-12-30], and a stored daterange [2026-01-01,9999-12-30) came back from a +1/-1 shift as [2026-01-01,9999-12-31). As the maintainer decided on #260, that move now throws OverflowException, as a move past an extreme does, on all seven infinity-backed types. A closed end at the minimum counted as -infinity, so [0001-01-01, 0001-01-01].Shift(5) did not move, though PostgreSQL's half-open form of it is [-infinity,0001-01-02), whose upper bound is a date (#257). The end-is-infinity test of DateRange and LocalDateRange drops the minimum, and YearMonthRange, whose last month as a start and first month as an end are dates too, now tests each side for its own extreme. LocalDateRange's day-before-the-maximum rule had no test; the oracle now holds it, with the round trip one step short of an infinity and the moving minimum end, for every infinity-backed type. Three seeds prove it, and InfinityShiftRoundTripTests shows the finite end live. Closes #257 Closes #260 Found-By: CA Defect-Class: STORE Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # test/oracles/claims.json
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.
Closes #257
Closes #260
Problem
#224 (PR #238) kept a bound that stands for an infinity where it is under
ShiftandExpand. The final pre-release analysis found three edges of that rule wrong or unguarded:Shift(d).Shift(-d) != r. For example,DateRange [9999-12-01,9999-12-29].Shift(1).Shift(-1)was[9999-12-01,9999-12-30], and live, a storeddaterange '[2026-01-01,9999-12-30)'came back as[2026-01-01,9999-12-31).-infinity, so[Min,Min].Shift(5)didn't move onDateRangeorLocalDateRange. PostgreSQL's half-open form of that range is[-infinity,0001-01-02), and its upper bound is a date.LocalDateRange's day-before-the-maximum rule had no test. Its seed survived every suite.Change
RangeArithmetic.MoveKeepingInfinity: a finite bound whose moved value stands for an infinity now throwsOverflowException, as decided on A Shift that lands a finite bound on the infinity sentinel keeps it there, so Shift(d).Shift(-d) != r #260, the same exception as a move past an extreme. A bound that already stands for an infinity still stays (Shift/Expand turn a bound that stands for ±infinity into a finite date #224).DateRange.EndIsInfinityandLocalDateRange.EndIsInfinitydrop the minimum. A closed end is infinite only at the maximum or the day before it, per the read rule (A discrete range read as [x,infinity) loses 9999-12-31; UpperBound disagrees between memory and server #117).YearMonthRange: the same bug, on both sides. It used oneIsInfinityfor both bounds. But its last month as a start is 9999-12-01, and its first month as an end is -9998-01-31, both dates the store writes as dates. So it now hasStartIsInfinity(first month only) andEndIsInfinity(last month only).[-9998-01,-9998-01].Shift(5)now moves its end. The oracle found this, beyond the issue's scope.[Max-3, Max-2].Shift(1).Shift(-1) == ron every type. OnDateRangeandLocalDateRange, though, the end's infinity starts at Max-1, soShift(1)of[Max-3, Max-2]lands on it and throws, as decided. The tests therefore use the same row one day lower there,[Max-4, Max-3]. The issue's own example ([9999-12-01,9999-12-29].Shift(1)) now throws.Shiftchangelog line is refined.YearMonthRange's per-side predicates replace two stale entries.Tests
RangeArithmeticOracleTests(seven infinity-backed types). The table now records each type's first infinite end value (Max-1 for the two closed date ranges), a value two steps below it, a value two steps above the minimum, and whether a closed end at the minimum is finite. For each type:ShiftandExpand[middle, first infinite end].Shift(-1)keeps its end[Min,Min].Shift(1)moves its end onDateRange,LocalDateRangeandYearMonthRangedotnet run tools/oracles.cs seeds shift,… minimum-end,… localdate-day):shift-lands-a-finite-bound-on-infinity.patch(A Shift that lands a finite bound on the infinity sentinel keeps it there, so Shift(d).Shift(-d) != r #260): all seven typeslocaldate-day-before-max-not-infinite.patch(#257a)minimum-end-counts-as-infinity.patch(#257b)shift-moves-an-infinite-bound.patchis regenerated for the new helper body.YearMonthRangeminimum-end seed is caught too (checked, not kept as a file).RangeShiftExpandTests.Shift_AFiniteBoundOntoInfinity_Throws_AndOneStepShortRoundTripsandShift_AClosedEndAtTheMinimum_MovesNodaTimeShiftExpandTests.LocalDateRange_InfiniteEnds_StayAndFiniteOnesDoNotLandThere, coveringLocalDateRange[x, MaxIso-1].Shift(-1d)keeping its end, the minimum end,LocalDateTimeRange,InstantRangeandYearMonthRangeInfinityShiftRoundTripTests.Date_FiniteEndBelowInfinity_CannotBeShiftedOntoIt_AndRoundTrips. The issue's stored[2026-01-01,9999-12-30)throws onShift(1)and round-trips unchanged throughShift(-1).Shift(1). It fails with the A Shift that lands a finite bound on the infinity sentinel keeps it there, so Shift(d).Shift(-d) != r #260 check removed.dotnet test: unit 1376, NodaTime 237, EF translation 285 + 83, conventions 399, integration 266, InfinityDisabled 4, all green.🤖 Generated with Claude Code