Skip to content

Scale the distribution sum tolerance with two-decimal rounding - #3

Merged
jkudish merged 1 commit into
mainfrom
fix/rounding-tolerance
Sep 25, 2026
Merged

jkudish merged 1 commit into
mainfrom
fix/rounding-tolerance

Conversation

@jkudish

@jkudish jkudish commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Fixes intermittent distribution must sum to approximately 1 rejections of valid Jev answers.

TypeSafe rounds probabilities to two decimals, so each nonzero entry can be off by up to 0.005. When several options carry weight (a search results page in jev-browser, a wide catalog in jev-mcp), valid answers sum to 0.98 or 1.02. The fixed ±0.01 band rejected them and failed the whole run. This blocked jev-browser 0.7.0's live e2e (typed search, twice in CI, 2 of 3 locally). Instrumented runs recorded live sums of 0.99 with 8 nonzero options, right at the edge.

Also fixed: an exact 1.01 sum was rejected because 1.01 - 1 > 0.01 in IEEE-754, while 0.99 passed.

The tolerance is now max(0.01, 0.005 × nonzero options), capped at 0.05, plus a float epsilon. Two-option answers keep the 1% bound, and garbage sums still fail.

Verified: new unit test (fails on the old code), 12/12 unit, live TypeSafe test, and jev-browser's heuristic-path typed search 6/6 with this build.

Consumers depend on ^0.1.0, so publishing 0.1.3 reaches fresh installs of jev-mcp and jev-browser without re-releasing them. Their lockfiles and CI need a bump to 0.1.3.

@jkudish
jkudish merged commit 022e516 into main Sep 25, 2026
1 check passed
jkudish added a commit that referenced this pull request Sep 25, 2026
Scale the distribution sum tolerance with option count (#3): 0.5% per
nonzero option, 5% cap, 1% floor, float-safe epsilon.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0d53e-c271-716f-94dd-6df00c40c7b8
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