Skip to content

Grade expression_in_range against its oracle in Rust (#227) - #357

Merged
wormeyman merged 1 commit into
mainfrom
feat/227-expression-in-range-oracle
Aug 30, 2026
Merged

Grade expression_in_range against its oracle in Rust (#227)#357
wormeyman merged 1 commit into
mainfrom
feat/227-expression-in-range-oracle

Conversation

@wormeyman

Copy link
Copy Markdown
Collaborator

First of the cheap-tier delete-with-loss ports. tiles/expression_in_range.rs
has six tests and all six assert shape on hand-written inputs, so nothing on
this side ever read oracle-expression-in-range.seed123456.json. Deleting
test/expressionInRange.spec.ts with the rest would have left that fixture
committed, version-pinned, and graded by nothing.

The gap is not theoretical. Planting the pre-f32 f64 arithmetic in the builtin
itself - which is the exact defect this fixture was captured to catch - leaves
all six existing tests green, and only the three sweeps added here fail.

Five tests, from the spec being retired:

  • the bounded 1-D sweep, expression_in_range(20, 1, (x/1000), -0.5, 0.5)
  • the unbounded 1-D sweep, which also pins that an infinite maximum does NOT
    clamp: in-range values run past 1, peaking near 2.5, and a clamp would
    silently kill sand-1's coastal boost
  • the 2-D sweep, which pins that dimensions combine by min rather than by
    product or sum
  • the f64 arithmetic rejected against the same fixture, so the three above
    cannot be recording whatever the implementation happens to do
  • sand-1's asymmetric, unbounded shape against the hand-derived formula

All three sweeps are EXACT - every position of 121, 121 and 162. That matters
because the assertion these replaced started life as a toBeLessThan(8e-3)
ceiling which the wrong implementation passed comfortably; the real residual is
about 9.5e-7, so the ceiling was some 8400x too loose.

Two deliberate departures from the spec:

  • The f64-rejection count is frozen at 34 of 121 rather than the spec's "more
    than 10". A number that moves is a finding.
  • The sand-1 case keeps a 1e-6 tolerance rather than tightening it. The builtin
    rounds every step to f32 and intermediates like 1 - 1.2 are not
    representable there, so -1.0 comes back as -1.000000238418579. Asserting the
    exact f32 result would mean recomputing the function inside the test and
    checking it against itself. Bit-exactness is the three sweeps.

One thing worth knowing for the deletion: the fixture stores the unbounded
sweep's maximum as the STRING "inf", so it cannot be read as a number.

Claude-Session: https://claude.ai/code/session_01UVcbv1pAhPUoCC6aBwZUtg

Co-authored-by: Claude Opus 5 (1M context) noreply@anthropic.com

@wormeyman
wormeyman force-pushed the feat/227-expression-in-range-oracle branch from 0650f78 to eaff426 Compare August 30, 2026 06:06
First of the cheap-tier delete-with-loss ports. `tiles/expression_in_range.rs`
has six tests and all six assert shape on hand-written inputs, so nothing on
this side ever read `oracle-expression-in-range.seed123456.json`. Deleting
`test/expressionInRange.spec.ts` with the rest would have left that fixture
committed, version-pinned, and graded by nothing.

The gap is not theoretical. Planting the pre-f32 f64 arithmetic in the builtin
itself - which is the exact defect this fixture was captured to catch - leaves
**all six existing tests green**, and only the three sweeps added here fail.

Five tests, from the spec being retired:

- the bounded 1-D sweep, `expression_in_range(20, 1, (x/1000), -0.5, 0.5)`
- the unbounded 1-D sweep, which also pins that an infinite maximum does NOT
  clamp: in-range values run past 1, peaking near 2.5, and a clamp would
  silently kill sand-1's coastal boost
- the 2-D sweep, which pins that dimensions combine by min rather than by
  product or sum
- the f64 arithmetic rejected against the same fixture, so the three above
  cannot be recording whatever the implementation happens to do
- sand-1's asymmetric, unbounded shape against the hand-derived formula

All three sweeps are EXACT - every position of 121, 121 and 162. That matters
because the assertion these replaced started life as a `toBeLessThan(8e-3)`
ceiling which the wrong implementation passed comfortably; the real residual is
about 9.5e-7, so the ceiling was some 8400x too loose.

Two deliberate departures from the spec:

- The f64-rejection count is frozen at 34 of 121 rather than the spec's "more
  than 10". A number that moves is a finding.
- The sand-1 case keeps a 1e-6 tolerance rather than tightening it. The builtin
  rounds every step to f32 and intermediates like `1 - 1.2` are not
  representable there, so -1.0 comes back as -1.000000238418579. Asserting the
  exact f32 result would mean recomputing the function inside the test and
  checking it against itself. Bit-exactness is the three sweeps.

One thing worth knowing for the deletion: the fixture stores the unbounded
sweep's maximum as the STRING "inf", so it cannot be read as a number.

Claude-Session: https://claude.ai/code/session_01UVcbv1pAhPUoCC6aBwZUtg

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@wormeyman
wormeyman force-pushed the feat/227-expression-in-range-oracle branch from eaff426 to 9be54d9 Compare August 30, 2026 06:31
@wormeyman
wormeyman merged commit 35b0d34 into main Aug 30, 2026
9 checks passed
@wormeyman
wormeyman deleted the feat/227-expression-in-range-oracle branch August 30, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant