Skip to content

test: make bug-finding systematic with a claim catalogue, API-surface coverage, seeds and candidates - #54

Merged
CaffeinatedCoder merged 4 commits into
mainfrom
test/oracle-machinery
Oct 17, 2026
Merged

CaffeinatedCoder merged 4 commits into
mainfrom
test/oracle-machinery

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #37. Part of #36; the probing round it carries is the work of #52.

What this is

Bug-finding in this repository has been one sweep per shipped bug: the shape matrix after IsAdjacentTo, the small-model oracle after IsStrictlyLeftOf and Except, the multirange oracle after RangeSet.Except, the literal sweeps after the culture defects. Each found more than the bug it was written for, but which sweep to write next was decided by the last bug report, and nothing said which promises had no sweep at all.

This PR ports the generated-oracle approach from CodoMetis.TypeKit the way BLite adopted it: as data and ordinary MSTest classes, without the prober, the ledger or covering arrays. Everything lives under test/oracles/, is held consistent by convention tests, and is described in docs/oracles.md.

The machinery

File What it is Held by
claims.json 121 claims — one per sentence a consumer-facing document states about behaviour, quoted verbatim, with the oracle kind, the public members a probe calls (surfaces) and the tests that hold it (heldBy) OracleCatalogueTests: the quote must still be in the file, the heading must exist, every heldBy is a [TestClass], every surface is a real member, every promise document carries a claim
ApiSurface + surface-waivers.json every public member of the four packages, by reflection (1,005 keys) OracleSurfaceCoverageTests: each is named by a claim or waived with a reason; a waiver whose members are all claimed is stale
oracles.json the 27 registered sweeps (what each checks against, which need Docker) OracleSeedTests: every oracle has a seed
seeds/*.patch 21 seeds — one defect each, planted in src/, naming the oracles it was shown to fail OracleSeedTests: src-only, well-formed, still applies to the tree. dotnet run tools/oracles.cs seeds re-proves locally that each is caught (a scratch copy, the patch, each oracle built and run); all 21 are
candidates.json + Candidates.cs disagreements found but not fixed, keyed to issues Candidates.Verdict replaces the final assert of a sweep: a row fails until its issue is filed, is reported SKIPPED while it is open, and fails as candidate fixed once the defect is gone

An empty heldBy is the worklist. After the probing round two remain (A02, A03), both decidable only by test/consumer-smoke-test.sh, which gained the A02 case.

New oracles

  • DomainParityOracleTests — the small-model sweep generalized from Int32Range/DecimalRange to every discovered range type through an order-preserving embedding (a day, a month, a half hour per grid point). Nine of the eleven types had worked examples only for what each supplies itself. All eleven agree with set theory; 2 s.
  • DecorativeElementContractTests, ClientSideOnlyTranslationTests, ClientSideOnlyProjectionTests, ExclusionConstraintTests, plus claim tests added to existing classes — the probing round over the twelve unheld claims.
  • The three existing small-model sweeps now report through the candidate registry.

What it found (Found-By: OT)

  • Two wrong examples in docs/serialization.md#formatting. CreateUnboundedStart(5).ToString() is "(,4]", not "(,5]" (exclusive by default, canonicalized); CreateFinite(1, 10, endInclusive: false) is "[1,9]", not "[1,10)". A reader copying either would have taken a value to be in the range that is not. Fixed, held by RangeParseFormatTests.FormattingExamples_InTheSerializationGuide_PrintExactlyTheirComments.
  • The NodaTime README promised an exception no input can raise. Every calendar NodaTime ships lies inside the ISO range, so the far-future ArgumentOutOfRangeException was unreachable. The sentence now says the conversion cannot fail (CalendarBoundaryTests holds it).
  • docs/efcore.md named the wrong refusal for ExecuteUpdate to null inside a JSON column: the plugin's guard refuses it before Npgsql's 42804.
  • StringSet<T> writes a decorated wrapper element instead of refusing it — Wrapper set arities don't check that an element's text form round-trips #53, labelled silent because the fix tightens behaviour, so it is not under Epic: 9.1.0 #35. Registered as three candidate rows; DecorativeElementContractTests reports them SKIPPED while Wrapper set arities don't check that an element's text form round-trips #53 is open.

For the reviewer

  • Every seed was proven by planting it: tools/oracles.cs seeds ran all 21 end to end (≈30 min, Docker), every pair CAUGHT. The log is in the commit message's claim, not in the repo; re-run it before the release.
  • A seed that changes only TimeSet<T>.FormatValue does not reach WrapperArityIntegrationTests: the EF bridge pins the format a second time in SetTypeRegistry, exactly as CLAUDE.md's rule says, so that seed unpins both halves.
  • DomainBoundaryDivergenceTests is deliberately not a registered oracle: it only queries the server, so no change to src/ can fail it.
  • CONTRIBUTING gains the oracle rules and the Found-By: / Defect-Class: trailers; CLAUDE.md gains the structure entries and workflow rule 6. Both touch sections that chore: track work as labelled issues with release epics #51 also edits; whichever lands second merges them.
  • tools/oracles.cs is a file-based app (#:property PublishAot=false, since file-based apps default to AOT analysis and the repo's warnings-as-errors would otherwise refuse JsonSerializer). It is never run in CI.

Verification

  • dotnet test on every non-integration project: green (875 + 95 + 194 + 217 + 81 + 31).
  • Integration: the registered sweeps and the three new classes, against a live PostgreSQL 17 container.
  • dotnet run tools/oracles.cs seeds: every seed is caught.

🤖 Generated with Claude Code

… coverage, seeds and candidates

The high-yield sweeps in this repository were each written after a bug of their kind had
shipped, and nothing said which promises had no sweep at all. This ports the generated-oracle
idea from CodoMetis.TypeKit the way BLite adopted it: as data and ordinary tests, without the
prober, the ledger or covering arrays.

test/oracles/ holds the system:
- claims.json — 121 claims, one per sentence a consumer-facing document states about behaviour,
  quoted verbatim (OracleCatalogueTests fails when the document no longer contains it), with the
  oracle kind, the public members a probe calls and the tests that hold it. An empty heldBy is
  the worklist; two remain (A02, A03), decidable only by the consumer smoke test.
- ApiSurface + surface-waivers.json — every public member of the four packages, by reflection,
  must be named by a claim or waived with a reason (OracleSurfaceCoverageTests).
- oracles.json — 27 registered sweeps; every one ships a seed under seeds/, a patch to src/
  that plants a defect it was shown to catch. OracleSeedTests holds the seeds present,
  src-only and applicable in CI; `dotnet run tools/oracles.cs seeds` proves locally that each
  is caught (all 21 are, through the tool, against a live PostgreSQL where the oracle needs one).
- candidates.json + Candidates.cs — a disagreement an oracle finds is registered against its
  issue; it fails labelled until filed, is reported SKIPPED while open, and fails as "candidate
  fixed" once the defect is gone. The three small-model sweeps now report through it.

New oracles: DomainParityOracleTests (the small-model sweep over all eleven range types through
an order-preserving embedding), DecorativeElementContractTests, ClientSideOnlyTranslationTests,
ClientSideOnlyProjectionTests, ExclusionConstraintTests, and claim tests in existing classes.

Found by the first catalogue pass and the probing round over the unheld claims (Found-By: OT):
- docs/serialization.md showed CreateUnboundedStart(5) as "(,5]" and
  CreateFinite(1, 10, endInclusive: false) as "[1,10)"; both canonicalize ("(,4]", "[1,9]").
  Held by RangeParseFormatTests.FormattingExamples_InTheSerializationGuide_PrintExactlyTheirComments.
- The NodaTime README promised an ArgumentOutOfRangeException for a far-future non-ISO date that
  no calendar NodaTime ships can reach; the sentence now says the conversion cannot fail.
- docs/efcore.md said ExecuteUpdate to null inside a JSON column fails with 42804; the plugin's
  guard refuses it first.
- StringSet<T> writes a decorated wrapper element instead of refusing it (#53, silent): registered
  as a candidate, SKIPPED while the issue is open.

docs/oracles.md describes the machinery; CONTRIBUTING gains the oracle rules and the Found-By /
Defect-Class trailers; CLAUDE.md gains the structure entries and workflow rule 6.

Closes #37

Found-By: OT
Defect-Class: LIT

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…p rows of #53

The unit job's loop ran `dotnet test test/oracles/`, a folder of catalogue data with no project,
and failed with MSB1003; it now skips a folder without a csproj. The integration loop matches
`*IntegrationTests/` only and was unaffected.

#53 widened from the string arity to every wrapper arity: none checks that an element's text form
round-trips. Two more rows, measured through the array literal, are registered against it in
DecorativeElementContractTests — `Int32Set<OffByOne>` (ToString gives V + 1, Parse gives V) is
written as {124} and read back as a different set; `StringSet<Lenient>` (ToString decorates, Parse
keeps any text) comes back as {CUST-CUST-123}. Nothing throws in either case.

The rows live in their own methods per arity, so a seeded defect in one cannot be read as the
other's known failure. That exposed a gap in the registry: "candidate fixed" was judged over every
row of the oracle class, so a method with disjoint rows failed on the rows it never produces. A
candidate now carries an optional `method`, Candidates.Verdict takes the calling method, and
OracleCandidateTests checks the method exists in the class.

Found-By: OT
Defect-Class: STORE

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (oracles, harnesses); no library code package/core Affects CodoMetis.ValueRanges package/nodatime Affects CodoMetis.ValueRanges.NodaTime package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL labels Oct 17, 2026
The labels moved to the BLite scheme: `found-by/oracle`, `package/*`, `area/*`, `severity/*`.
The trailer paragraph in CONTRIBUTING and the candidate-filing step in docs/oracles.md named the
old ones.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package/core Affects CodoMetis.ValueRanges package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/nodatime Affects CodoMetis.ValueRanges.NodaTime tests Adds or changes tests only (oracles, harnesses); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce the generated-oracle machinery

1 participant