Repository navigation
fix(calibrate): a target_error that cannot be compared is refused by name - #1404
NandhaKishorM merged 2 commits into
Conversation
…ion, not a dict key `chosen_key not in lookup` raised a bare interpreter TypeError for a `choice` the remote body sent as a JSON array or object, so neither the RuntimeError nor the fallback_tool path the string case takes was ever reached. agno, crewai and llamaindex already refuse a non-string `choice` at the same boundary.
…ed to a range `0.0 <= target_error <= 1.0` raised the interpreter's own TypeError for a "0.1" from a config file or a None from a missing key, naming neither the parameter nor the caller's mistake. Run the comparison and report its failure through the message the bool arm already uses, so a value that does compare -- a Decimal, which numbers.Real does not cover -- keeps fitting.
24 PRs. Vietnamese kept off the English checkpoint (#1392), deciding-window attribution preserved through end hooks (#1369), RemoteRouter identifying itself with a configurable User-Agent (#1396), ten more inputs refused where they enter (#1372, #1394, #1397, #1398, #1400, #1401, #1402, #1403, #1404, #1405, #1406), per-language temperatures and per-call budgets in .NET and Rust (#1370, #1371), .NET calibration files (#1384), the Go router lifecycle, SHA-256 pins and routed inference (#1374, #1379, #1395), a C++ foundation (#1399, #1407), and parity-lane sharding that replaces the budget headroom added for 0.4.16 (#1373, #1375). Verified before tagging: all 92 suites pass, 640 tests, up from 612. ruff clean on both lists. laya-ts 1251 tests across 44 files, tsc --noEmit clean. Every generated-artifact gate clean on CPython 3.12 / unicodedata 15.0.0: Java 20 families match laya (9 unverified), UnicodeTables matches CPython 15.0.0, LanguageTables matches laya/lang.py, three Go tables_gen.go match, both laya-cpp .inc files match. Version agrees across pyproject.toml, laya.__version__ and nix/package.nix. README carries 0.4.17 only. Security audit of the merge diff, 362766 added lines over 480 files: zero obfuscation, zero secrets, zero boundary hits, zero binaries, no mode or symlink changes, 20 of 20 actions SHA-pinned including the new cpp.yml, npm install hooks unchanged, and no third-party host in any added line (example.com 90, github.com 2, download.pytorch.org 1, docs.rs 1). The 12 dynamic-exec hits are the C++ test harness invoking its own checker through sys.executable, the Go sample generator reading laya's own example by AST at development time, and one comment in rust.yml. Held: #1364 (unchanged, it moves a cross-port contract), #1381 (a #[doc(hidden)] but pub Rust hook that would ship as public API able to replace the forward pass), #1386 (route_batch switched from self.route to self._route, silently bypassing subclass overrides the docstring promises), and nine stacked port PRs that conflict with each other and need linearizing (#1377, #1378, #1380, #1382, #1383, #1385, #1387, #1388, #1389, #1390). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Merged. The reasoning I want to single out is why you ran the comparison and caught The failure being fixed is worth stating plainly for anyone reading later. Keeping the Shipped in 0.4.17. |
What
fit_abstention_thresholdsnow reports a non-comparabletarget_errorthrough theValueErrorit already raises for a bool, instead of letting the interpreter'sTypeErrorescape. Onetryaround the existing comparison; no new message, no new import.Why
laya/calibrate.py:485read:A
str(a"0.1"read out of JSON), aNone(a key that was not there), acomplex, alistor adictis not bool and not comparable, so the<=raises before theifcompletes. Measured against the suite's own_smallrecords:The parameter is a documented
floaton a public fitting entry point thatlaya.trainreaches from a config file, and the very next line runsmin_bucket_nthrough_positive_int(:114), which has refused a string and aNoneby name for a while — so the two arguments one line apart disagreed about whether a bad shape is worth naming. After the change all five rows above printtarget_error must be in [0.0, 1.0], got '0.1'and so on.The comparison is run and its
TypeErrorturned into a refusal, rather than the range test being replaced by anisinstancecheck, because anisinstancelist is what would break a working caller:not isinstance(target_error, Real)refusesDecimal("0.10")—decimal.Decimalis registered asnumbers.Number, notnumbers.Real— and aDecimalcompares against0.0/1.0perfectly well and is only ever used forrate <= target_error(:435). My first draft usedRealand the newDecimalcase caught it; the case stays in the suite so the simpler-looking version cannot be swapped back in later.How it was verified
The pristine
b9fe351worktree gives80 passed, 0 failedfor the same suite, so the six added checks are the only difference.ruff check laya/(the CI gate) passes; the 14 errorsruff check tests/prints are pre-existing on base and outside the gate.The mutation arm reverts only the guard and keeps the tests, which fails exactly the five refusals and quotes both sides — and shows the
Decimalcase passing in both arms, which is what it is for:Nothing is fixture-pinned:
grep -rn "target_error must be"overlaya-java/ laya-go/ laya-rust/ laya-dotnet/ laya-ts/returns nothing, andgen_fixtures.py --checkreports the same two families stale as a pristine base worktree (lang_detect.json,python_json.json— the Linux/macOS regeneration documented atgen_fixtures.py:1922), so this diff moves no fixture.Checklist
main