Repository navigation
spec(047): ratify one implementation of exp and ln on every target - #138
Conversation
AI review (findings)The PR adds approval record A-44 and spec 047 for routing Finding: measurement table has 3 rows for 4 declared call sites The spec consistently says "four call sites" (A-44, summary, section 1, section 2) and describes the measurement methodology as "a million inputs per call site drawn as the sites see them." The measurement table, however, has only 3 rows, merging the two evaluation
This makes the "7.1%" figure ambiguous: it is unclear whether 7.1% of inputs differ on each of the two sites independently (which would mean the two sites happen to agree on domain and result), or whether the figure is aggregated across both sites. A reader verifying "a million inputs per call site" against the table sees only three data points for four sites. If the two sites were measured together and the divergence rate differs between them, the table understates the worse one. Separating the row into two (one per source file) would make the measurement claim unambiguous and match the "four call sites" language used throughout. No security issues. No other inconsistencies found; A-44 in {"head": "d1ffdfd13128cbfedcbe414a16a8e46eed999630", "verdict": "findings", "findings": [{"path": "specs/047-target-independent-transcendentals/spec.md", "line": 57, "summary": "Measurement table combines two evaluation ln call sites (metrics.rs log loss and fit.rs temperature fit) into one row, making the 7.1% figure ambiguous against the spec's repeated claim of 'a million inputs per call site' across four distinct call sites."}]}Subject: cbd5bfb...d1ffdfd, diff digest a041e3f05adc14b9309475638c920c847bb191c4c12e8805df2b90b288520d9a, 1 call(s). An AI comment is not an approval. |
d1ffdfd to
ad09a0a
Compare
AI review (findings)Reviewing both changed files for bugs, security problems, and inconsistencies. docs/decisions/00-founding-decisions.md A-44 is internally consistent with the spec: correct spec number, amends 002 3.4.6 and 027 3.11.2, same date (2026-10-21), same pin ( specs/047-target-independent-transcendentals/spec.md The spec is well-structured and largely consistent. One genuine inconsistency stands out:
Minor observation (not a blocking finding): Section 3.1 describes {"head": "ad09a0a8f72bc81208a9871bb6a1d9f1625ed994", "verdict": "findings", "findings": [{"path": "specs/047-target-independent-transcendentals/spec.md", "line": 155, "summary": "Acceptance section asserts the workspace suite 'passes' locally in present tense, contradicting the Implementation record ('Not started') and frontmatter (`implementation: pending`), making it unclear whether acceptance criteria were actually verified or are merely anticipated."}]}Subject: cbd5bfb...ad09a0a, diff digest 0edf54a8257c5d8a5f1ed69a1fe103b57b549f98d08ea943d81e2fa3353640b9, 1 call(s). An AI comment is not an approval. |
ad09a0a to
558b57d
Compare
AI review (findings)Reviewing both changed files for bugs, security problems, and inconsistencies.
The numeric claims in A-44 (0.08% to 7.1%, one-ulp differences, four call sites, two evaluation sites sharing one input domain) are internally consistent with the spec's measurement table. Dates match (2026-10-21). Sequence follows A-43 for spec 046. No issues.
Section 3.3 enumerates the platform math methods the test will ban: No other inconsistencies found: the territory, obligation, amendment text, acceptance criteria, and frontmatter are mutually consistent and consistent with the decisions file entry. {"head": "558b57d84bb13e7e180bdadbe1d6ec7631fd874c", "verdict": "findings", "findings": [{"path": "specs/047-target-independent-transcendentals/spec.md", "line": 119, "summary": "The enforcement test in 3.3 bans exp, ln, log* and trig/hyperbolic methods but omits f64::exp2, a transcendental with the same cross-target divergence risk; it is neither correctly rounded nor covered by the trigonometric/hyperbolic catch-all, so future use in a pure crate would silently bypass the parity guarantee of 027 3.11.5."}]}Subject: cbd5bfb...558b57d, diff digest 685a8ea7dcc3fc419fab964233045f12e41e3c9510a1de5b7a07e83f172becde, 1 call(s). An AI comment is not an approval. |
Ratifies spec 047 (amends 002 3.4.6 and 027 3.11.2) on the owner's decision of 2026-10-21 (A-44): the pure crates' four transcendental call sites go through rustev_core::math (libm =0.2.16, default features off) on every target, the remedy 027 3.11.5 names for a cross-target divergence.
558b57d to
913c0b6
Compare
AI review (no-findings)The PR adds decision record entry A-44 and spec 047, covering the remedy for cross-target transcendental divergence via Decision record (A-44): Consistent with the spec's summary, ratification date, the libm version/feature claim, the four call sites, and the "no golden expected to change" statement. The scope restrictions (no release authorization, no real-user data) follow the established pattern of adjacent entries. Spec 047:
No security issues. No meaningful inconsistencies. {"head": "913c0b6a3cebdf244afb1bf1c06893bf8629bd67", "verdict": "no-findings", "findings": []}Subject: cbd5bfb...913c0b6, diff digest 645ea9ceed53bc73dd2ded81958955ca131d7ad2d3ca33fb0d1ca79894b382ce, 1 call(s). An AI comment is not an approval. |
Implements spec 047 (ratified in #138, A-44): one implementation of `exp` and `ln` on every target. - `crates/rustev-core/src/math.rs` (new, public): `exp` and `ln` wrap `libm::exp` and `libm::log`. `libm` is a workspace dependency of core only, exact-pinned `=0.2.16` with `default-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. - The four call sites use it: softmax (`kinds.rs`), the log of a distribution mass (`calibrate.rs`), log loss (`rustev-eval` `metrics.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 any `f64` platform math method (the list of 047 3.3, method and path forms) outside `math.rs`, comments excluded; a second test shows the scan finds each seeded form. - `tools/rustev-release/archive-policy.json`: core's new `src/math.rs` joins its reviewed archive list. - Spec 047: `extends` edges 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 -p` of 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`.
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 031 increment 1: the facade crate `rustev`, its boundary rules, and `rustev-pkg-lodging` and the facade joining the release family. - `integrations/rustev/` (new, crate `rustev`): `#![forbid(unsafe_code)]`, no binary. `rustev::contract` and `rustev::decision_core` always (3.2.1); features `runtime`, `eval`, `rules`, `remote-http` (the four whose crates are in this release, 3.4), each `dep:` exactly one optional dependency and gating one module named after it; `default = []`; documented with module, crate and subset (3.2.5). - `tests/public_items.rs`: the source is only those re-exports; each feature enables exactly its one `dep:`; `default` is empty; every feature is documented. - `tests/plan_ids.rs` (3.7): both reference plans compiled through `rustev::decision_core` from the conformance suite's pinned `plan check` fixtures equal the plan identities the CLI goldens pin. Passes with no feature and with all features. - `tools/rustev-boundaries` (3.3): `FacadeIntegration` (an integration dependency of the facade that is not optional, not normal, or not enabled by exactly one feature), `DependsOnFacade` (any workspace crate, any dependency kind), `FacadeDefault` (non-empty default), `FacadeFamily` (the facade naming an ecosystem, HTTP or binding family itself), and the facade's no-feature graph checked transitively like the pure crates. Integration crates still may not depend on one another. Eight synthetic-metadata fixtures. - `tools/rustev-release`: - `release-set.json`: `rustev-pkg-lodging` in layer 3 (uploading after the CLI it dev-depends on, as support-routing does); `rustev` alone in a new last layer, uploading last; lodging's exclusion removed. - policy: only the facade may declare features, each exactly one optional normal dependency on a release member (I-3: a feature for a crate outside the release fails), and a non-empty default fails (`FacadeFeature`); the facade's layer is the last one and the set refuses a facade sharing it or not uploading last. Tests for each; three existing tests that used lodging as their excluded example now use `rustev-boundaries`. - `archive-policy.json`: the reviewed file lists of both new archives (equal to `cargo package --list`, which the existing test checks). - `packages/rustev-pkg-lodging`: family metadata, `publish = ["crates-io"]`, `include`, `LICENSE`, workspace dependencies (031 amends 008's out-of-scope publication). Its tests pass unchanged. - Workspace `Cargo.toml`: the two packages as exact-pinned workspace dependencies. - Spec 031: `integrations/rustev/` established (no longer planned), an `extends` edge for lodging's `LICENSE`, implementation record. Later increments: subset jobs, MSRV and semver checks, SBOMs, the changelog, the extended dry run and the release workflow. Local verification (macOS arm64): `cargo test -p rustev` (with no feature and with `--all-features`), `cargo test -p rustev-boundaries` (28), `cargo test -p rustev-release` (all pass, manifests 17), `cargo test -p rustev-pkg-lodging`, `make boundaries`, `cargo clippy --workspace --all-targets -D warnings` and `-p rustev --all-features`, `cargo fmt --check`, `make gate`, `bash scripts/check-authored-content.sh`. Review round 1 (3 findings: 1 fixed, 2 answered in the diff): 1. "The last-layer test calls `check_manifests`, but the message comes from `check_set`." `check_manifests` begins with `let mut v = check_set(set);`, so it carries that verdict; the test passed locally. A comment at the test now says so. 2. A facade feature naming a crate outside the release produced two violations (not a member, and not a dependency). Fixed: the membership violation is the only one (`continue`), and the test now asserts exactly one violation with `only()`. 3. "`README.md` is not in the facade's or lodging's archive." It is: Cargo adds the workspace `README.md` that `readme.workspace` names regardless of `include`, `cargo package --list -p rustev` prints it, and `tests/archives.rs` (`the_reviewed_lists_equal_cargo_package_list`) checks the reviewed lists against that output and passes. Both manifests now say so beside `include`. Review round 2 (2 findings, fixed): 1. A workspace crate depending on the facade was reported twice (`DependsOnIntegration`, since the facade lives under `integrations/`, and `DependsOnFacade`). A dependency on the facade is now `DependsOnFacade` alone; the fixture uses `rustev-eval` (which no other rule restricts) and asserts exactly that one violation for normal, dev and build dependencies. The "integration crates still may not depend on one another" fixture now has a second integration crate depending on the remote binding and asserts exactly `DependsOnIntegration`. 2. `every_feature_is_documented` indexed `entries[0]`; a feature enabling nothing now fails with a message naming it. Review round 3 (2 findings, fixed): `tests/public_items.rs` no longer parses `Cargo.toml` by hand; it reads the facade's features from `cargo metadata --no-deps` (Cargo's own parse), and compares the declared features with the gated modules as sorted sets, so neither file's order matters. Rebased onto `main` after #138 to #141 merged (derived shards regenerated). Review round 4 (1 finding, fixed): the facade's archive bounds (128 KiB compressed, 256 KiB unpacked) were looser than lodging's although the facade holds less. They are now 64 KiB compressed and 128 KiB unpacked, the ceilings of the other small library crates: its archive is `src/lib.rs`, the workspace README and LICENSE (16.5 KB together), the manifests and a `Cargo.lock` of its all-features graph (about 25 KB). The release candidate measures every archive against these bounds and fails on any excess.
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.
Spec 047, ratified by the owner on 2026-10-21 (decision A-44): one implementation of
expandlnon every target (amends 002 3.4.6 and 027 3.11.2).Why: spec 027 increment 7 adds the differential floating-point corpus (027 3.11.3). Measured locally before writing it (Rust 1.98.1, release builds, a million inputs per input domain drawn as the call sites see them; the two evaluation sites share one domain and one input set), macOS arm64 native and
wasm32-unknown-unknownin Node disagree by one ulp on 829 (exp, softmax), 1,080 (ln, calibration) and 71,134 (ln, log loss and fit) inputs. Under 027 3.11.5 the parity job must fail on any such difference, and the remedy it names, "routing those functions through one pure Rust implementation on every target", is a separate amendment of spec 002. This is that amendment.specs/047-target-independent-transcendentals/spec.md: new,approved. The four call sites go through a newrustev_core::math(libm=0.2.16, default features off, pure Rust, MIT); evaluation reaches it through core, so its dependencies stay contract, core and serde; a core test refuses a direct platform math call in the pure crates.expandlnstay outside exact computation.docs/decisions/00-founding-decisions.md: A-44 records the ratification. No release or publication is authorized.Spec only; no code. The implementation is the next PR. Probing it locally (the four call sites switched to
libm), the full workspace test suite passed with no golden changed; only evaluation's dependency allowlist test failed, which the core module avoids.As a ratification, this PR needs the owner's approval of the
statecraft-review-exceptionEnvironment.Local checks:
make gate,bash scripts/check-authored-content.sh.Review round 1 (1 finding, fixed): the measurement table merged the two evaluation
lnsites into one row. They applylnto the same domain, so one input set measured both; the table now has one row per call site, each saying it shares that input set, and the spec, A-44 and this body say "a million inputs per input domain".Review round 2 (1 finding, fixed): the acceptance section stated the pre-spec probe's local result in the present tense although nothing is implemented. The probe is now described in section 1 as an observation made before the spec, not acceptance evidence, and the acceptance item is normative only.
Review round 3 (1 finding, fixed): 3.3 summarized the banned methods and left out
exp2. It now lists everyf64method the standard library computes through a math library (exp2,cbrt,hypotandsin_cosincluded), in both method and path form, which is the list the implementing test uses.