Scale the distribution sum tolerance with two-decimal rounding - #3
Merged
Merged
Conversation
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
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.
Fixes intermittent
distribution must sum to approximately 1rejections 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.01in 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 search6/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.