Repository navigation
impl(047): one implementation of exp and ln on every target - #139
Conversation
AI review (no-findings)The PR introduces a
Call site migrations -- all four sites (
Spec file -- No bugs, security issues, or inconsistencies found. {"head": "d72d5c79f71d63e7e9480f215b17589f164296d4", "verdict": "no-findings", "findings": []}Subject: 913c0b6...d72d5c7, diff digest ee312c330bf2554c2450cd335c44446502a9c88764df9bfc63c29896596c98d7, 1 call(s). An AI comment is not an approval. |
rustev_core::math::{exp, ln} wrap libm =0.2.16 (default features off); the softmax, calibration, log-loss and temperature-fit call sites use them, and a core test refuses a direct platform math call in the pure crates.
d72d5c7 to
7eb2a03
Compare
AI review (no-findings)The PR introduces Observations checked:
No bugs, security issues, or spec inconsistencies found. {"head": "7eb2a0387aa95e1d74a254254dc69fb80f3f704f", "verdict": "no-findings", "findings": []}Subject: 29d9bed...7eb2a03, diff digest ee312c330bf2554c2450cd335c44446502a9c88764df9bfc63c29896596c98d7, 1 call(s). An AI comment is not an approval. |
Spec 027 increment 7, first change: the native package's platform packages (3.13.1, 3.13.2). - `integrations/rustev-node/npm/<platform>/package.json` for the seven platforms the main package's `optionalDependencies` name (`linux-x64-gnu`, `linux-x64-musl`, `linux-arm64-gnu`, `linux-arm64-musl`, `darwin-arm64`, `darwin-x64`, `win32-x64-msvc`): `@statecrafting/rustev-<platform>` at the main package's version, license and engines; `os`, `cpu` and, on Linux, `libc` as the name says; `main` and `files` the addon `rustev.<platform>.node` alone; no scripts; `private` until spec 031's release. - `tools/rustev-conformance/js/platform-packages.mjs`: - `check`: every optional dependency has its package and they agree as above; no stray platform directory; no script in a platform package and no install-time script (`preinstall`, `install`, `postinstall`, `prepare`) in the main package; - `stage <target>`: copies this host's release addon into its platform package; - `fresh <dir>`: `npm pack`s the main package and this host's platform package and installs both into a fresh project from the tarballs (`--omit=optional --ignore-scripts`), so nothing is fetched for another platform, and fails if the main package's tarball carries an addon. - `copy-addon.mjs` exports the addon naming it already had (`addonName`, `builtAddon`) for that reuse; its command line is unchanged. - `make bindings` runs `check`, `stage`, `fresh`, then the native conformance suite on the fresh install, so the suite exercises the loader's platform-package path (3.13.2), not only the local build. - Spec 027: implementation record. Building and smoke-testing each of the seven targets in CI is a later change of this increment (the `bindings` job). Local verification (macOS arm64, clean build of the changed crates): `make bindings` passes end to end (`npm audit signatures`, WebAssembly conformance 23/23, 27 native tests, native conformance 34/34 on the local build and 34/34 on the fresh install); `make gate`; `bash scripts/check-authored-content.sh`. Review round 1 (3 findings, fixed): 1. `check` refused any `scripts` on the main package. 3.13.2 forbids install-time code, so it now refuses only npm's install lifecycle scripts there (`preinstall`, `install`, `postinstall`, `prepare`); a platform package still has no script at all. Seeded locally: a `build` script on the main package passes, a `postinstall` fails naming it. 2. `stage` and `fresh` let `addonName()`'s throw on an unsupported platform escape as a stack trace; both now go through `hostPlatform()`, which exits with the message. 3. npm ran with `shell: true` on Windows, so cmd.exe parsed the paths. npm now runs without a shell everywhere: on Windows its entry point (`node_modules/npm/bin/npm-cli.js` beside `node.exe`) runs under the current Node, and a missing one fails by name. Review round 2 (2 findings, fixed): 1. `fresh` deleted its target directory unconditionally. It now writes a marker (`.rustev-fresh`) into the directory it makes and replaces only a directory carrying it; any other existing path is refused by name and left alone (seeded locally: a scratch directory holding a file was refused and kept). In `make bindings` the path is under the cargo target directory, which the target already refuses to be empty. 2. `pack` joined npm's reported file name unchecked. A response that is not JSON, or a name that is not one plain `.tgz` file name, or a tarball that is not there, now fails with a message naming the package. Review round 3 (1 finding, answered in the diff, no behavior change): `addonName()` skips `excludeNetwork` when `process.report` has no such own property. That is deliberate and unchanged from #135's loader: only a Node that supports leaving the network section out exposes the property, and assigning it elsewhere would add a plain property the report never reads. The comment at the call now says so; the report then runs whole, slower but correct. Rebased onto `main` after #138 and #139 merged. Local `make bindings` on the rebased branch, after `cargo clean -p` of every crate #139 changed: WebAssembly conformance 23/23, 27 native tests, native conformance 34/34; its `fresh` step refused a `native-fresh` directory left by a run from before the round-2 marker existed (the guard working as intended). With that directory removed, the fresh install's suite passed 34/34. Review round 4 (2 findings, fixed): 1. `builtAddon()` produced a path ending in `.undefined` on an unsupported platform; it now throws naming the platform, and `stage` reports it cleanly. 2. `check` counted any entry under `npm/` as a platform directory, so macOS's `.DS_Store` failed it; only non-hidden directories count now (seeded locally with a `.DS_Store`: `check` passes).
Spec 027 increment 7, third change: the differential floating-point corpus (3.11.3, 3.11.5). After spec 047 (#138, #139) every transcendental call reachable from a pure command is a call of `rustev_core::math`, at four sites: `exp` in core's softmax, `ln` in core's calibration, `ln` in evaluation's log loss, `ln` in its temperature fit. - `tools/rustev-conformance/fp-corpus/` (new crate `rustev-fp-corpus`, `publish = false`, excluded from the release set as tooling; an explicit workspace member, since it sits inside the conformance suite's directory): - 131,072 inputs per site, drawn as each site sees them (non-positive `exp` arguments; positive finite masses; probabilities in (0, 1] and just above). Each set starts with boundary values: zeros, the smallest and largest subnormals, `MIN_POSITIVE`, one ulp either side of 1, where `exp` leaves the normal range and where it rounds to 0, and the format's extremes. It continues with a seeded SplitMix64 using integer arithmetic and correctly rounded basic operations only, so every target draws the same bits. - Per site, the SHA-256 of the input bits and of the output bits, both committed in `expected.json`. - A native runner (`rustev-fp-corpus check expected.json`) and a WebAssembly build of the same crate with plain exports and no imports (`corpus_sites`, `corpus_run`, `corpus_digest_byte`). The exports need `#[unsafe(no_mangle)]`, so the crate relaxes `unsafe_code` to `deny` and allows it on those three functions only; there is no `unsafe` block. - Tests: every `rustev_core::math` call in the pure crates is a corpus site and vice versa (a new call site cannot go unmeasured); the inputs meet 3.11.3 (at least 100,000, no NaN, subnormal and extreme magnitudes, distinct draws for the two evaluation sites); this target reproduces the committed digests. - `tools/rustev-conformance/js/fp-corpus.mjs`: the WebAssembly module in Node and in headless Chromium against the committed digests, writing a result document. - `make bindings`: the corpus natively, then in Node and Chromium. - Release set: `rustev-fp-corpus` excluded with its reason. - Spec 027: implementation record. Local verification (macOS arm64, before the rebase onto `main`): native, Node 24.6.0 and Chromium 153.0.8010.12 agree on all four sites; `make bindings` passes end to end with the corpus steps; `cargo test -p rustev-fp-corpus` (3 tests); clippy `-D warnings`; `cargo test -p rustev-release` with the new exclusion. Seeded check: putting the platform's `exp` and `ln` back into `rustev_core::math` makes the native macOS run differ from the committed digests and fail, while WebAssembly (whose standard library already uses the pure implementation) still matches. That is the divergence spec 047 removed. After the rebase: `make gate`, `bash scripts/check-authored-content.sh`. The results on every CI target come with the `bindings` job, the next PR. Rebased onto `main` after #142 merged. One conflict, in `tools/rustev-release/release-set.json`, resolved by hand: #142 removed lodging's exclusion (lodging became a member), and this PR adds `rustev-fp-corpus`'s, so the result keeps the new exclusion and not lodging's. Review round 1 (1 finding, fixed): `corpus_digest_byte`'s out-of-range sentinel `u32::MAX` reaches JavaScript as -1 (a wasm `i32` result is signed), so `b > 255` never caught it. The runner now accepts only integers 0 to 255 and throws naming the value otherwise; the Rust doc comment states the -1. Checked locally against the module: `corpus_digest_byte(5, 0)` and `(0, 99)` return -1, which the new guard refuses. Review round 2 (2 findings, fixed): 1. `check` compared the committed file byte for byte, so a CRLF checkout (Windows with `core.autocrlf`) would fail with correct digests; the committed text is now compared with carriage returns removed. 2. The call-site guard stripped only `//` comments; it now scans code alone, with line, block (nested) comments and string and character literals blanked (`code_only`, with its own test), counts every occurrence rather than one per line, and compares `/`-separated paths on every host. Local: `cargo test -p rustev-fp-corpus` 4/4, clippy `-D warnings`. Review round 3 (1 finding, fixed): `code_only` did not blank raw string literals. It now recognizes `r"..."`, `r#"..."#` with any number of `#`, and the `br` forms (not when `r` ends an identifier), and the scanner test includes a raw string and a raw byte string holding `math::exp(` and `math::ln(`, which are not counted. Local: `cargo test -p rustev-fp-corpus` 4/4, clippy `-D warnings`. Rebased onto `main` after #146 (profile revision 17, spec-spine 0.31.0): derived shards regenerated with spec-spine 0.31.0; no other conflict.
Implements spec 047 (ratified in #138, A-44): one implementation of
expandlnon every target.crates/rustev-core/src/math.rs(new, public):expandlnwraplibm::expandlibm::log.libmis a workspace dependency of core only, exact-pinned=0.2.16withdefault-features = false, so it takes no architecture-specific path. Unit tests pin special values and three results' bit patterns, so a pin change that moves a bit fails here before the corpus runs.kinds.rs), the log of a distribution mass (calibrate.rs), log loss (rustev-evalmetrics.rs) and the temperature fit (fit.rs). Evaluation's normal dependencies are unchanged (contract, core, serde), so its dependency allowlist test passes unmodified.crates/rustev-core/tests/platform_math.rs: scans the sources of contract, core, evaluation and the surface and fails on a call of anyf64platform math method (the list of 047 3.3, method and path forms) outsidemath.rs, comments excluded; a second test shows the scan finds each seeded form.tools/rustev-release/archive-policy.json: core's newsrc/math.rsjoins its reviewed archive list.extendsedges for the code it touches, implementation record,implementation: complete.Every existing test and golden passes unchanged; none re-blessed.
The ratification (#138) has merged; this PR is rebased onto
main.Local verification (macOS arm64, after
cargo clean -pof contract, core, eval, surface, cli and runtime):cargo test --workspace --no-fail-fast(no failure),cargo clippy --workspace --all-targets -D warnings,cargo fmt --check,make boundaries,make gate,bash scripts/check-authored-content.sh.