Skip to content

docs: pin the date extremes as a documented boundary where adjacency diverges - #169

Merged
CaffeinatedCoder merged 3 commits into
mainfrom
fix/date-extremes-adjacency-divergence
Oct 18, 2026
Merged

CaffeinatedCoder merged 3 commits into
mainfrom
fix/date-extremes-adjacency-divergence

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #110

Stacked on #168 (fix/infinite-range-is-unbounded), which is stacked on #167: merge those first, then retarget this to main.

Problem

At the extremes of a date domain IsAdjacentTo returns true in memory and false in PostgreSQL. Npgsql writes DateOnly.MinValue/MaxValue and LocalDate.MinIsoValue/MaxIsoValue as -infinity/infinity, so [0001-01-01,0001-01-01] is [-infinity,-infinity] on the server, and no finite date is next to a sentinel. Every other operator agrees on these values (both sides map the sentinel the same way, and the reader turns it back into the extreme); adjacency is the one with a step. Neither the domain-boundary table nor the EF Core guide said so.

Decision

The issue offered two fixes: document the row as a domain boundary, or stop the in-memory check stepping across an extreme. This PR takes the first, because the second would create a new disagreement: with Npgsql.DisableDateTimeInfinityConversions set, the extremes reach the server as dates and -|- returns true there, exactly as memory does. The new InfinityConversionsDisabledTests.AtTheDateExtremes_AdjacencyAgrees_BecauseTheExtremesStayDates holds that, so the in-memory answer is right for one configuration and the documented divergence is a property of Npgsql's infinity mapping, not of the algebra. Nothing in src/ changes; the issue's breaking label is removed accordingly, silent stays (the disagreement exists and is now documented and pinned).

Change

  • docs/architecture.md: the date extremes join the domain-boundary section, with a table of the two divergent pairs and the pair that agrees, and why the model keeps its answer.
  • docs/efcore.md (Store timestamp ranges) and docs/ranges.md (Check adjacency, Good to know): the consumer-facing sentence; claim E44-date-extremes-adjacent-to-nothing-in-sql quotes it, held by the three tests below.
  • DomainBoundaryDivergenceTests.DateRange_AtTheDomainEdge_IsNotAdjacentAcrossAnExtremeOnTheServer: memory true, the literals EF writes false, column-against-parameter through EF Core false for DateRange at both extremes and LocalDateRange at MaxIsoValue, and the pair one day inside the extremes true on both sides.
  • DifferentialFuzzParityTests: an adjacency row at a date extreme is set aside only when it disagrees in exactly the documented shape (memory true, EF and PostgreSQL false) and counted in the test output; any other disagreement at the edge still fails. FuzzDomain exposes its extremes for the check, which keys on the literal EF writes for the extreme containing infinity, so YearMonthRange (whose extremes are month boundaries, never sentinels) is not covered by it.
  • docs/testing.md: the set-aside rule. test/oracles/candidates.json: the two IsAdjacentTo at the date extremes: memory says adjacent, PostgreSQL does not (MinValue/MaxValue are ±infinity there) #110 rows removed.

Tests

  • With the fuzz set-aside removed, DifferentialFuzzParityTests.Ranges_AgreeWithPostgres fails with the two previously registered rows (DateRange IsAdjacentTo at the domain edge …, RangeSet<DateRange> IsAdjacentTo(set) at the domain edge …), so the candidates were right to go and the set-aside is what holds them.
  • The whole suite, both integration projects in Docker included, is green; the conventions project accepts the new claim (verbatim quote, sorted id, held).

🤖 Generated with Claude Code

…diverges

At the extremes of a date domain, IsAdjacentTo answers true in memory and
false in PostgreSQL. Npgsql writes DateOnly.MinValue / MaxValue and
LocalDate.MinIsoValue / MaxIsoValue as -infinity / infinity, so a range
bounded at an extreme holds a sentinel on the server where the model holds a
date, and no finite date is next to a sentinel: [-infinity,-infinity] -|-
[0001-01-02,) is false where [0001-01-01,0001-01-01] and [0001-01-02,) are one
day apart. Every other operator agrees, since both sides map the sentinel the
same way and the reader turns it back into the extreme.

The model keeps its answer on purpose. With Npgsql.DisableDateTimeInfinityConversions
set the extremes reach the server as dates and -|- answers true there, so a
model that stopped stepping across an extreme would disagree with that
configuration instead; InfinityConversionsDisabledTests now holds that. The
divergence joins the integer sentinel rows in docs/architecture.md's boundary
table, docs/efcore.md and docs/ranges.md say it in the consumer's voice, claim
E44 quotes it, DomainBoundaryDivergenceTests pins it as a literal, a parameter
and through EF Core for DateRange and LocalDateRange, and
DifferentialFuzzParityTests sets an adjacency row at a date extreme aside only
when it disagrees in exactly the documented shape (memory true, EF and
PostgreSQL false), counting it. The two #110 candidates are removed; with the
set-aside removed the sweep reports them as unregistered rows again.

Closes #110

Found-By: OT
Defect-Class: STORE

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 documentation Improvements or additions to documentation silent Answers wrongly without throwing — fixes go in the next major, never deferred found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) area/ranges Range unions, variants and the shape engines area/range-set RangeSet and multirange algebra package/nodatime Affects CodoMetis.ValueRanges.NodaTime package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference stacked Base is another open PR; merge in order, CI does not run until it targets main labels Oct 18, 2026
…-adjacency-divergence

# Conflicts:
#	test/oracles/candidates.json
Base automatically changed from fix/infinite-range-is-unbounded to main October 18, 2026 14:16
@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 37736b9 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/date-extremes-adjacency-divergence branch October 18, 2026 14:21
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 documentation Improvements or additions to documentation found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) package/core Affects CodoMetis.ValueRanges package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/nodatime Affects CodoMetis.ValueRanges.NodaTime severity/low Cosmetic, message or documentation-level difference 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.

IsAdjacentTo at the date extremes: memory says adjacent, PostgreSQL does not (MinValue/MaxValue are ±infinity there)

1 participant