Skip to content

impl(027): increment 7, the differential floating-point corpus - #145

Merged
bartekus merged 1 commit into
mainfrom
impl/027-inc7-corpus
Oct 21, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/027-inc7-corpus

Conversation

@bartekus

@bartekus bartekus commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the differential floating-point corpus crate (rustev-fp-corpus) added for spec 027, section 3.11.3.

lib.rs — generator correctness

The Domain::Positive pick 0/1 mask (0x7FEF_FFFF_FFFF_FFFF) clears the sign bit and caps the exponent at 2046, correctly excluding infinities/NaNs while allowing subnormals through zero. Zero itself (bits == 0) is possible and is correctly rejected by the x > 0.0 admissibility gate, with the loop continuing — not a hang risk.

The Domain::Probability pick-3 path uses % 0x3FF0_0000_0000_0000 (the bit-pattern of 1.0), giving values in [0.0, 1.0) by bit-casting; zero is again rejected cleanly.

f64::NEG_INFINITY appears in NonPositive specials. -∞ <= 0.0 is true, so it is admitted and digested. exp(-∞) = 0.0; its bit pattern is well-defined. Intentional and fine.

lib.rs — WebAssembly exports and Mutex

static LAST: Mutex<...> works on wasm32-unknown-unknown (Rust's single-threaded Wasm target provides a stub Mutex that never blocks). The corpus_digest_byte sentinel return of u32::MAX for out-of-range indices is caught in the JS runner (if (b > 255) throw). No memory-sharing issues: all Wasm exports communicate only scalar u32 values.

main.rs — check command

The check sub-command compares the computed string to the file contents byte-for-byte. This is intentional golden-file testing and the committed expected.json was produced by the same report() function, so the comparison is stable. Rust's read_to_string on Windows collapses \r\n to \n, matching the \n the formatter writes; no platform mismatch.

tests/corpus.rs — coverage test

math_calls() strips line-comments with .split("//").next() before searching for math::exp( / math::ln(. Block comments (/* … */) are not stripped, which could produce false positives if a block-commented call site exists. No such sites are present in the repo today, so this is a latent limitation, not a current bug.

The root derivation concat!(env!("CARGO_MANIFEST_DIR"), "/../../..") → repo root is correct for the crate at tools/rustev-conformance/fp-corpus.

fp-corpus.mjs

runCorpus.toString() serialises cleanly: the function uses only Web-platform APIs (WebAssembly, fetch) and its only free variable e is bound at the call site in both Node and Chromium paths. The digest-range check (b > 255) is correct. Cleanup is wrapped in finally, so browser/server teardown runs even when digest checks throw.

No bugs, security issues, or spec-027 inconsistencies found.

{"head": "354f471e4ff6d69ed19b36cc148d279267cae37f", "verdict": "no-findings", "findings": []}

Subject: a99f7bf...354f471, diff digest 26adab080b990852196c3d89d2be030bcc7512b5c8919532b5a609d4ac3f8ac6, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge (squash) October 21, 2026 16:30
@bartekus
bartekus force-pushed the impl/027-inc7-corpus branch from 354f471 to a2df2f6 Compare October 21, 2026 16:33
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the new rustev-fp-corpus crate and its JavaScript runner.

Finding 1 – corpus_digest_byte error sentinel is invisible to JavaScript

lib.rs returns u32::MAX when called with an out-of-range index. However the WebAssembly JS API maps every i32 export to a signed JavaScript number, so u32::MAX (0xFFFF_FFFF) arrives in JS as -1. The guard in fp-corpus.mjs:

if (b > 255) throw new Error(...)   // line 37

is never true for -1, so the error is swallowed silently. The subsequent line

s += b.toString(16).padStart(2, '0')   // "-1"

would produce a corrupted hex string. In the normal code path indices are always valid (0–1 for which, 0–31 for index), so this is latent rather than immediately triggered, but the sentinel as written has no effect on the JS side.

Finding 2 – minor: nonPositive specials include f64::NEG_INFINITY, then f64::MIN – both are admissible and correct (exp(-∞) = 0, exp(MIN) = 0), so this is not a bug.

Everything else looks sound. The SplitMix64 generator, SHA-256 chaining, WASM export shape, Makefile wiring, workspace membership, release-set.json exclusion, and the every_call_site_is_in_the_corpus test all look correct. The Mutex compiles fine for single-threaded wasm32-unknown-unknown.

{"head": "a2df2f6402eef8aaccc59867149b44a34bc04439", "verdict": "findings", "findings": [{"path": "tools/rustev-conformance/js/fp-corpus.mjs", "line": 37, "summary": "The out-of-range sentinel `u32::MAX` returned from `corpus_digest_byte` is converted by the WebAssembly JS ABI to -1 (signed i32), so the guard `if (b > 255)` never fires; the error path silently produces a corrupted hex string instead of throwing."}]}

Subject: 541f3ca...a2df2f6, diff digest 13f87557ad3cc904bb7722176d231fc30bef7db18a10f440478b2f77de817f96, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 16:35 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/027-inc7-corpus branch from a2df2f6 to f6bf718 Compare October 21, 2026 17:15
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the new rustev-fp-corpus crate and its supporting files.

tools/rustev-conformance/fp-corpus/src/main.rs

The check subcommand compares the generated JSON to the file content using exact string equality (expected == doc, line 27). report() produces LF-only output. On any host where git has autocrlf = true (Windows), expected.json would be checked out with CRLF endings, causing every check invocation to fail even when the floating-point results are correct. The Makefile invokes this command as part of make bindings.

tools/rustev-conformance/fp-corpus/tests/corpus.rs

math_calls() strips line comments by splitting on "//" (line 44), but does not strip block comments (/* ... */) or string literals. If any source file in the scanned crates contains math::exp( or math::ln( inside a block comment or a string literal, the scanner will produce a spurious entry and every_call_site_is_in_the_corpus will fail with a confusing diff. Low severity for internal tooling, but it is the guard against unmeasured call sites.

Everything else looks correct: the SplitMix64 generator is standard, the admissibility filters are sound for each domain, the wasm export interface is consistent with the JS consumer, the poison-guard unwrap_or_else(|e| e.into_inner()) on the Mutex is appropriate, and the release-set.json exclusion and Cargo.toml membership are consistent with the crate's publish = false.

{"head": "f6bf718ba247ac68e9f2f88b9d9f0ff073d09f61", "verdict": "findings", "findings": [{"path": "tools/rustev-conformance/fp-corpus/src/main.rs", "line": 27, "summary": "Exact string comparison of file content against generated JSON will fail on Windows where git autocrlf produces CRLF line endings, even when all floating-point digests are correct."}, {"path": "tools/rustev-conformance/fp-corpus/tests/corpus.rs", "line": 44, "summary": "math_calls() strips only // line comments, so math::exp( or math::ln( inside a block comment or string literal would be counted as a call site, breaking the all-sites-covered guard."}]}

Subject: 541f3ca...f6bf718, diff digest d44fddadae6f855b04d8c6950bfaa8c60d0b634a5d08faeecb21743e456faded, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 17:19 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/027-inc7-corpus branch from f6bf718 to cc36eb1 Compare October 21, 2026 17:28
@github-actions

Copy link
Copy Markdown

AI review (findings)

Looking through this PR, which adds the differential floating-point corpus tool (spec 027, section 3.11.3), I found one notable issue.

tests/corpus.rs — code_only doesn't strip raw string literals

The scanner in every_call_site_is_in_the_corpus calls code_only to remove comments and ordinary "..." string literals before searching for math::exp( and math::ln( patterns. However, raw string literals (r"...", r#"..."#, br"...", etc.) are not handled. If any source file in the four scanned crates introduces a raw string containing one of those patterns — e.g., r#"calls math::ln(x)"# in a test or doc-comment-adjacent string — the scanner would count it as an additional call site, causing every_call_site_is_in_the_corpus to fail spuriously (overcounting) rather than silently pass. The risk is low given the specific files scanned, but it is a real correctness gap in the guard that's meant to prevent unmeasured call sites from being added undetected.

Everything else looks correct:

  • The SplitMix64 generator uses only integer arithmetic and exact basic operations, giving identical bits across targets.
  • The 0x7FEF_FFFF_FFFF_FFFF mask in the NonPositive draw correctly prevents NaN/infinity bit patterns (bit 52 of the exponent field is forced to 0, so the exponent can never reach 0x7FF).
  • The wasm32-unknown-unknown module uses Mutex (no-op lock in single-threaded Wasm) with unwrap_or_else(|e| e.into_inner()) for poison recovery — safe and correct.
  • runCorpus serialized via .toString() has no closure captures, so the Chromium injection pattern is reliable.
  • The strip_prefix(root()) trick in math_calls works because p is constructed from the same non-canonical root() prefix, so component matching is consistent without needing path canonicalization.
  • The release-set exclusion, crate-type ["rlib", "cdylib"], and lints override (deny instead of forbid) are all consistent with the stated design rationale.
{"head": "cc36eb125b2063a90617ed4f64b9877bb3d89df2", "verdict": "findings", "findings": [{"path": "tools/rustev-conformance/fp-corpus/tests/corpus.rs", "line": 17, "summary": "code_only does not strip raw string literals (r\"...\", r#\"...\"#), so a raw string in a scanned file containing \"math::exp(\" or \"math::ln(\" would be miscounted as a call site and cause every_call_site_is_in_the_corpus to fail spuriously."}]}

Subject: 541f3ca...cc36eb1, diff digest 675fece8682aa1584491b4263fd628636735b01f99537c6a3c15e6c12f00ad3b, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 17:32 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/027-inc7-corpus branch from cc36eb1 to cf3a50a Compare October 21, 2026 17:34
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the new rustev-fp-corpus crate and supporting changes:

Cargo.toml / Cargo.lock / release-set.json: Workspace membership and exclusion from the release set are consistent; publish = false matches the exclusion entry.

lib.rs -- LAST Mutex in wasm32-unknown-unknown: The static Mutex compiles and works correctly on this single-threaded target; unwrap_or_else(|e| e.into_inner()) handles the poison case cleanly. The call sequence (always corpus_run before corpus_digest_byte) is enforced by the JS runner, so there is no observable read-before-write risk.

lib.rs -- input generation: next() is a standard SplitMix64. unit() gives [0, 1) by shifting off 11 bits and scaling by 2^-53, which is exact. The NonPositive mask 0x7FEF_FFFF_FFFF_FFFF clears the sign bit and the low exponent bit (bit 52), preventing infinity/NaN from appearing before negation; -0.0 can appear but is admissible and already in specials. The modulo in the Probability arm can produce 0.0, which the admissibility filter correctly rejects. All fine.

lib.rs -- u32::MAX sentinel: corpus_digest_byte returns u32::MAX for out-of-range; the JS comment and b < 0 check correctly handle the signed i32 sign-extension that WebAssembly applies. Correct.

main.rs -- check comparison: CRLF normalisation on the expected file (expected.replace("\r\n", "\n") == doc) is correct because report() always emits LF-only. No false positives on Windows checkouts.

tests/corpus.rs -- code_only: The line-comment branch does not increment i, leaving the terminating \n to be emitted by the outer else branch on re-entry, so newlines are preserved. Block comments: the depth counter initialises at 0 and the first /* brings it to 1; the loop exits only when depth reaches 0 again, so nested comments are handled correctly. The character-literal branch handles only 'x' (3 chars) and '\x' (4 chars), missing multi-character escapes like '\x41'; however none of the transcendental call signatures (math::exp(, math::ln() can appear inside a character literal, so this imprecision has no practical effect on the scan.

tests/corpus.rs -- every_call_site_is_in_the_corpus: The function-name inference (id.ends_with(".exp") → exp, else ln) is correct given the two transcendentals in scope. math_calls() sorts before comparison; std::fs::read_dir ordering is non-deterministic across OSes but the sort makes the assertion deterministic.

fp-corpus.mjs: runCorpus.toString() serialises the function without closures, which evaluates correctly in the page context. The wasm module is instantiated with empty imports {}, matching the crate's no-import design. Failures propagate correctly via process.exit(1).

No bugs, security issues, or spec inconsistencies found.

{"head": "cf3a50aff163b7955bf5f3ee082b79afc01d99f0", "verdict": "no-findings", "findings": []}

Subject: 541f3ca...cf3a50a, diff digest 312892e87ce0cf4ad75e6fa040375325103ed2d9c72c69edc146b375f59c2104, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/027-inc7-corpus branch from cf3a50a to cc53f11 Compare October 21, 2026 18:10
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

I reviewed the PR carefully across all changed files: the new rustev-fp-corpus crate (Cargo.toml, src/lib.rs, src/main.rs, tests/corpus.rs), the JS runner, Makefile additions, spec text, and release-set exclusion. Below are my findings.

SplitMix64 / input generation — the PRNG and domain generators are correct. unit() produces [0,1) via the standard 53-bit shift. The per-domain draw arms produce admissible values; the admissibility filter rejects the rare zeros that can arise (e.g. from Domain::Probability pick 0/1 when the PRNG gives 0). The specials lists are all within their domains, so they are safe to push without the filter.

expected.json digests — all four inputs_sha256 and outputs_sha256 values are 64 hex characters (32 bytes), consistent with SHA-256.

WebAssembly exports — corpus_run / corpus_sites / corpus_digest_byte are correct. The u32::MAX sentinel returned for an out-of-range byte arrives in JavaScript as -1 (signed i32), and the JS guard b < 0 || b > 255 catches it.

Mutex in wasm32-unknown-unknown — single-threaded WASM never contends on the lock; unwrap_or_else(|e| e.into_inner()) is appropriate defensive coding since WASM panics abort rather than unwind.

lints.rust override — setting unsafe_code = "deny" at the crate level to override the workspace forbid is the correct Cargo mechanism; the #[allow(unsafe_code)] gates on the three export functions are then coherent.

CRLF normalisation in main.rs — expected.replace("\r\n", "\n") is compared against doc (which uses \n throughout). Covers Windows checkout line endings; standalone \r (old-Mac) is not normalised, but that is not a concern for CI.

code_only comment/string stripper — the line-comment, nested block-comment, raw-string, string, and character-literal handlers are all structurally correct. The depth counter starts at 0 and the first /* encountered inside the while loop immediately increments it to 1. The outer-loop i advancement is properly delegated in each branch.

root() path — concat!(env!("CARGO_MANIFEST_DIR"), "/../../..") from tools/rustev-conformance/fp-corpus resolves correctly to the workspace root.

sha2 workspace dependency — sha2.workspace = true in fp-corpus/Cargo.toml is valid because sha2 already appears in the pre-existing Cargo.lock (it would have been listed in the diff's additions otherwise); no new entry was added to Cargo.lock for sha2 itself.

Makefile — wasm artifact name rustev_fp_corpus.wasm (hyphens → underscores) is correct for the rustev-fp-corpus crate.

No concrete bugs, security defects, or governance inconsistencies found.

{"head": "cc53f1102306fff7c29df02cb864d603ede83310", "verdict": "no-findings", "findings": []}

Subject: 1204bc8...cc53f11, diff digest 312892e87ce0cf4ad75e6fa040375325103ed2d9c72c69edc146b375f59c2104, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit df053f6 into main Oct 21, 2026
7 checks passed
@bartekus
bartekus deleted the impl/027-inc7-corpus branch October 21, 2026 18:31
bartekus added a commit that referenced this pull request Oct 21, 2026
…checks (#143)

Spec 031 increment 2: the partial-adoption subsets, MSRV and
API-compatibility checks, as repository commands (3.5, 3.6.7, 3.8).

- `tools/rustev-release/adoption.sh` (`make adoption [subset ...]`):
each subset is a fresh consumer project outside the workspace (its own
empty `[workspace]`, the workspace's `Cargo.lock` and
`rust-toolchain.toml` copied in) depending on the facade by path with
`default-features = false` and exactly the subset's features (plus
`rustev-pkg-support-routing` for embedded decisions). Its test names
every module the subset takes and parses a definition through the
facade, and must run and pass (a build alone fails); `cargo tree -e
normal` must contain each chosen crate and none of the omitted ones
(tokio and hyper included where omitted). Subsets: documents (no
feature), embedded (`runtime`, `rules`), evaluation (`eval`), remote
over HTTP (`runtime`, `remote-http`), and `runtime`, `rules`,
`remote-http` alone. `serve`, `bedrock`, `typesafe`, `otel`,
`local-embed` print "skipped, not passed" with the reason their crate is
not in this release.
- `tools/rustev-release/msrv.sh` (`make msrv`): `cargo +<MSRV> test
--locked` of every release member, the MSRV read by the release policy
from the members' `rust-version`.
- `tools/rustev-release/semver.sh` (`make semver`): for each member, the
newest earlier non-yanked version in the crates.io sparse index; with
one, `cargo semver-checks check-release` at the exact pin 0.51.0
(refusing any other version); with none, `no-baseline`, written as "not
applicable, not passed". The npm packages report `no-baseline` while
unpublished and refuse a verdict once published until their declaration
diff exists; the service API has no crate in this release. Registry
reads only, with a project User-Agent; no credential.
- `Makefile`: `adoption`, `msrv`, `semver`.
- Spec 031: implementation record.

The CI jobs that will run these come in a later workflow change,
together with spec 027's `bindings` job (one
`statecraft-review-exception` approval); this PR changes no workflow.

#142 has merged; this PR is rebased onto `main`.

Local verification (macOS arm64):
- `make adoption`: all 7 subsets pass (normal graphs of 30 to 62
crates), 5 skipped with reasons.
- `make semver`: 11 crates and 2 npm packages `no-baseline`; nothing
compared.
- `make msrv`: every member builds at 1.88 and its tests started, but
this Mac's `syspolicyd` held the freshly built CLI binaries in
`_dyld_start` for over 20 minutes in `rustev-cli`'s `actionability`
test, so I stopped it; the MSRV test run is not locally verified. The CI
job is the verdict.
- `make gate`, `bash scripts/check-authored-content.sh`.

Review round 1 (3 findings, fixed):
1. The record said the CI jobs "are registered"; no workflow changes
here. It now says they will be registered by a later workflow change,
with spec 027's `bindings` job, and that this increment changes no
workflow (this body likewise).
2. `semver.sh` created a temporary file per crate outside any trap; it
now uses one scratch directory removed by an `EXIT` trap.
3. `adoption.sh` matched `test result: ok. 1 passed` as a regex; it is
now a fixed-string match (`grep -qF`).

Review round 2 (2 findings, both mistaken, answered in the diff):
1. "`process.argv.slice(1)` is off by one under `node -e`." Under `-e`
there is no script path, so the first argument after the program is
`argv[1]`: `node -e 'console.log(process.argv.slice(1))' a b` prints
`["a","b"]` (checked on Node 24). A comment at the call now says so, and
the local `make semver` run read the index responses this way.
2. "The documents subset references `rustev::decision_core::compile`,
which may be feature-gated." It is not: `contract` and `decision_core`
are the facade's always-present modules (031 3.2.1, `#[cfg]`-free in
`lib.rs`, checked by `tests/public_items.rs`), and the documents subset
passed locally. A comment in the generator now says so.

Review round 3 (1 finding, the round-2 claim again, made moot): the
index file and version now reach the inline script as environment
variables (`INDEX_FILE`, `CURRENT`) rather than arguments, so no
argument indexing remains to dispute. Checked locally on a synthetic
index (`0.0.9`, `0.1.0`, yanked `0.0.5`, current `0.1.0`): it selects
`0.0.9`.

Review round 4 (3 findings: 2 fixed, 1 answered in the diff):
1. The consumer ran without `--locked`. `--locked` cannot hold for a
fresh consumer (the copied lockfile names the workspace's packages,
which the consumer's root replaces), so the guarantee is now checked
directly: after the build, every registry package in the consumer's
lockfile must be at a version the workspace's `Cargo.lock` pins, or the
subset fails naming it. Seeded locally on a copy of the lockfile:
identical gives nothing; `serde` at `9.9.9` is reported.
2. `curl` had no timeout; every registry request now has `--max-time
60`.
3. "`use rustev::contract::Document` is unused." It is the trait whose
`parse` the generated test calls (`Definition::parse` is
`Document::parse`); a comment in the generator now says so.

Review round 5 (1 finding, answered and guarded): "a pre-release family
version makes the comparator return NaN." The release policy refuses any
family version that is not `X.Y.Z` (`check_set`, 021 3.2), so none
reaches this script. `semver.sh` now also refuses a non-`X.Y.Z` version
itself before comparing (checked locally: `0.1.0` accepted, `0.1.0-rc.1`
and `1..0` refused).

The previous round's review was cancelled at its time limit; it was
rerun once by re-signing the commit.

Review round 6 (4 findings, fixed):
1. A four-part version passed the shape check; the family version must
now have exactly two dots and digits only.
2. The consumer's edition was hard-coded; it is now the workspace's own
`edition`, read from the root manifest (refusing when absent).
3. Whether the subset test ran was read from the harness's summary text;
the generated test now writes a mark file (`RUSTEV_ADOPTION_MARK`) and
the script checks that file instead.
4. The pinned `cargo-semver-checks` was probed only when a baseline
existed; it is now required up front on every run (exact version), so a
missing or wrong tool is found before the first release needs it. The CI
job installs it.

Review round 7 (1 finding, answered and made explicit): "a failing
`node` leaves `baseline` empty and reads as `no-baseline`." In POSIX
`sh` an assignment's exit status is its command substitution's, so `set
-e` already stops the script (`sh -c 'set -eu; b=$(false); echo
reached'` prints nothing and exits 1). The lookup now also has an
explicit `|| { ...; exit 1; }` naming the crate ("could not read its
index response; no verdict"), checked against a non-JSON index file.

Rebased onto `main` after #142 merged. The round-7 review (on `3451a98`)
repeated the `node` substitution finding, which `3305bd4` had already
answered with the explicit guard (`|| { echo "$name: could not read its
index response; no verdict" >&2; exit 1; }`); that head's review was
cancelled at the time limit, so this push is its rerun.

Review round 8 (3 findings, fixed):
1. A missing `node` surfaced as "could not read its index response":
`semver.sh` now checks `git`, `cargo`, `curl` and `node` on PATH before
anything else and names the missing one.
2. `make semver` computed the report path with an inline `node` call, so
a missing `node` gave `/semver.txt`: the script now defaults the report
to `semver.txt` in the cargo target directory it already resolves, and
the Makefile target passes nothing.
3. `adoption.sh` ignored an unknown subset name: a requested name that
is neither a present nor a skipped subset now exits 2 naming it (checked
locally: `adoption.sh nosuch` gives "no subset named 'nosuch'").

Review round 9 (1 finding, mistaken, answered in the diff): "`IFS='|'`
on `read` persists into the loop body, so the lists split as one token."
A prefix assignment to a regular built-in such as `read` lasts for that
command only (POSIX); `sh -c 'printf "a|x y z\n" | while IFS="|" read -r
n l; do for c in $l; do echo $c; done; done'` prints `x`, `y`, `z` on
separate lines (macOS `sh` and `bash`). The local adoption run is the
same evidence: the embedded subset's chosen-crate check passed over
three names, which it could not with `|` as the separator. A comment at
the loop now says so.

Review round 10 (1 finding, fixed): an empty member list from the
release policy would have run `cargo test` over the whole workspace;
`msrv.sh` now refuses an empty package list or MSRV.

Review round 11 (1 finding, fixed): Node's role in `semver.sh` is now
documented where a user meets it: the script's header, the Makefile
target's comment and the spec record each state that `make semver` needs
`curl`, Node 20 or later (to read the index's JSON lines) and the pinned
`cargo-semver-checks`; the script still refuses each by name when
missing.

Rebased onto `main` after #146 (profile revision 17, spec-spine 0.31.0):
derived shards regenerated with 0.31.0.

Review round 12 (3 findings, fixed):
1. The pinned `cargo-semver-checks` is now checked with the other tools,
before anything is built.
2. Node's version is checked too (20 or later), not only its presence.
3. Both remote subsets now require `tokio` in their graph (the remote
binding depends on it normally), as the runtime-only subset does.

Review round 13 (1 finding, fixed): the embedded subset (which enables
`runtime`) now also requires `tokio` in its graph, like every subset
that takes the runtime or the remote binding.

Rebased onto `main` after #145 merged (derived shards only).
bartekus added a commit that referenced this pull request Oct 21, 2026
After rebasing onto #145, the corpus test refuses an unmeasured
rustev_core::math call. The dynamic report's log-loss ln joins the corpus
as eval.dynamic_log_loss.ln with its committed digests; 019 extends
tools/rustev-conformance/ for it and verifies the corpus test.
bartekus added a commit that referenced this pull request Oct 21, 2026
Spec 026, increments 1 and 2: live re-execution of a recorded decision
shape as a new decision, behind a host authorization seam, and its
comparison with the verified historical case.

- `crates/rustev-contract` (`src/live.rs`, new): the
`rustev.live-reexecution/1` document (`LiveReexecution`): the new
decision, plan and computed snapshot identities, evaluation time, opaque
subject and scope, the historical case as a `HistoricalLink`
(identities, evaluation time and the bundle's record digest, never
content) or explicit `none`, admission, the new run record's digest,
termination and cost summary, one `LiveEffect` per proposed external
attempt (with the host's `AuthorizationReference` or the typed refusal,
and the dispatch observation), unreconciled attempts, delivery, capture
and retention posture, and the comparison section. `check` bounds every
list and free text and refuses an effect or liability not attributable
to the new decision, or a new decision id equal to the historical one.
`AuthorizationRequest` and its tagged digest
(`rustev.live-authorization/1`) bind an answer to exactly one attempt;
refusals are `missing`, `expired`, `mismatched`, `errored` and
`refused`.
  - `tests/live.rs`: bounds, refusals, digest binding and round trips.
- `crates/rustev-runtime` (`src/live.rs`, new; `src/driver.rs`):
`Runtime::reexecute_live(plan, LiveRequest, &dyn LiveAuthorizer,
cancel)`, the only function that takes an authorizer. Before admission
it refuses a reused historical decision id, a snapshot whose computed
`SnapshotId` differs from the stated one, an invalid capture
configuration, an out-of-range historical decision id, and a plan whose
worst-case attempts exceed the document bound. It then runs an ordinary
spec 003 decision; in the attempt driver, after the full worst-case
reservation and the deadline and cancellation re-check, the host is
asked about that exact attempt (a panic is contained as `errored`). An
allow counts only if it names the presented digest and is still valid by
the runtime clock. A refusal releases the reservation, sends nothing and
stops the request; retries and fallbacks are each authorized again.
- `tests/live.rs`: section 5 rows 2 to 6 and 9; allow, refusal,
mismatch, error, panic, expiry, retry, fallback, cancellation, unknown
charge, possibly continuing work and sink failure with exact attempt
attribution; exact steps still judge when the host refuses all external
work; cache and batch bypass; capture. Compile-fail examples show
`decide` and `decide_with_capture` take no authorizer.
- `crates/rustev-eval` (`src/live.rs`, new): `compare_live(LiveCase)`, a
pure function over host-supplied documents. It refuses a document that
does not check, an unbound run record, a plan that is not the
document's, and a bundle other than the linked one; verifies the
historical case by spec 004 reproduction (an unavailable item makes the
comparison `unavailable`, nothing restored); then reports `agreement`,
`live-diverged` (`proposal_changed` or `unresolved_category_changed`) or
incomparable, with snapshot, plan, evaluation-time, artifact, backend,
definition, policy, calibration, runtime count, cost, termination,
cancellation, remote-state, retention and delivery differences reported
apart. `with_comparison` returns a copy; no source is modified.
- `tests/live.rs`: section 5 rows 1, 7 and 8; byte-identical sources
after a live run and its comparison; a source scan showing eval names no
runtime, backend or authorizer.
- Mutation seeds: eight `live:` seeds in
`crates/rustev-runtime/mutation/seeds.py` and two `live-comparison`
seeds in `crates/rustev-eval/mutation/seeds.py`; all ten detected.
- `Makefile`: 026 joins `VERIFIED_SPECS`.
`tools/rustev-release/archive-policy.json`: the new source files in the
contract, runtime and eval archives.
- Spec 026: implementation record. Derived shards regenerated.

What remains: the comparison reports the first unavailable item
reproduction meets, not every item; served identity stays `unknown`
until a run record carries it; the live document's later members (spec
043 3.9) are not part of this implementation.

Owner decisions (engineering choices made within the spec, open to
review; see the implementation record):
- E-26-1: an authorization refusal is typed in the live document, and
the core is supplied `backend_unavailable` with detail
`authorization_refused: <refusal>` (the spec 003 3.6.4 form). Spec 002's
four runtime reasons, `rustev.run/1` and the core are unchanged.
- E-26-2: the authorizer is synchronous and lives in `rustev-runtime`,
not in the core seams; its answer is neither serializable nor clonable,
and only its reference is kept. Validity is a duration judged by the
runtime's clock.
- E-26-3: live runs bypass the memory cache and general batching (a
diagnostic says so when the plan enables either); each attempt is fresh
work, authorized on its own.
- E-26-4: no JSON Schema yet: the live document is not added to spec
027's emitted schemas, since that would regenerate the committed
TypeScript declarations. A spec 027 follow-up.

Local verification (macOS arm64): `make gate`, `make code` (build, test,
clippy `-D warnings`, fmt, boundaries), `.bin/spec-spine verify 026` (10
commands, 10/10 seeds detected), `bash
scripts/check-authored-content.sh`.

Review round 1 (1 finding, fixed): `LiveReexecution::check` refused a
historical decision id longer than 256 bytes but not an empty one, so a
parsed document linking an empty historical id passed `check` although
`reexecute_live` refuses it. `check` now refuses it too;
`the_historical_decision_id_is_one_to_256_bytes` checks 0 and 257 bytes
(refused) and 256 bytes (accepted).

Rebased onto `main` after #143, #144 and #145 merged (derived shards
regenerated).

Review round 2 (0 findings).

Review round 3 (0 findings), after the rebase onto #144.
bartekus added a commit that referenced this pull request Oct 21, 2026
After rebasing onto #145, the corpus test refuses an unmeasured
rustev_core::math call. The dynamic report's log-loss ln joins the corpus
as eval.dynamic_log_loss.ln with its committed digests; 019 extends
tools/rustev-conformance/ for it and verifies the corpus test.
bartekus added a commit that referenced this pull request Oct 21, 2026
After rebasing onto #145, the corpus test refuses an unmeasured
rustev_core::math call. The dynamic report's log-loss ln joins the corpus
as eval.dynamic_log_loss.ln with its committed digests; 019 extends
tools/rustev-conformance/ for it and verifies the corpus test.
bartekus added a commit that referenced this pull request Oct 21, 2026
Spec 019, increments 1 and 2: dynamic questions as a narrow evaluated
class. The documents, pure validation and identity, `ask_dynamic`,
offline reproduction and the dynamic evaluation report. Scripted
backends only; nothing here selects a backend, authorizes live inference
or spend, or claims accuracy or calibration.

- `crates/rustev-contract/` (`src/dynamic.rs`, `ids.rs`, `limits.rs`):
`rustev.dynamic-question/1`, `rustev.dynamic-capability/1` (identified
by `DynamicCapabilityId`) and `rustev.dynamic-outcome/1` (`RECORD_V1`);
`DynamicRequestId`, `TemplateId`; the `DYNAMIC_QUESTION_V1` scan limits.
Parsing scans the bytes first, then checks the structural bounds of 3.2
(sizes, counts, byte-exact uniqueness of labels and context names, 64
KiB of context values, 128 KiB canonical); unknown members are refused.
The canonical request identity covers what a backend computes from,
including label order, template and preprocessing; the backend receives
a projection under fixed member names only.
- `crates/rustev-core/` (`src/dynamic.rs`, `seams.rs`): `validate`
builds the only `ValidatedQuestion`; `admit` (capability fit, no
truncation, `bounded` cost model only), `admit_cost` (enforceable bound
at or below the hard cap), `judge` (exact support, non-answer material
is invalid, pinned served identity, named abstention rules), `proposal`
(`model-derived`, with lineage). `DynamicBackend` and
`DynamicEvidenceSink` seams, separate from `DecisionBackend`, with no
tool, function or retrieval surface. Compile-fail tests with a compiling
control keep dynamic outcomes, raw outputs and proposals out of
`Supplied`, `Evaluation::supply` and `Judgment`, and keep
`ValidatedQuestion` unforgeable.
- `crates/rustev-runtime/` (`src/dynamic.rs`): `ask_dynamic`, one
attempt under a fresh hard ledger at the request's cap (and the optional
host ledger), deadline over every phase, spec 003/013 cancellation
evidence, optional sink whose delivery never changes the outcome. No
retry, fallback, batching or cache on this path.
- `crates/rustev-eval/` (`src/dynamic.rs`): `reproduce` takes no
backend; a changed canonical identity is `incomparable{request_changed}`
(section 5's last row: reordered labels), another declaration
`capability_changed`, a missing raw response `raw_response_unavailable`,
a different judgment `diverged`. `rustev.dynamic-dataset/1` and
`rustev.dynamic-evaluator-config/1` bind task family, exact question
schema, artifact and template; the dataset requires an
injection-adversarial case and refuses leakage across splits.
`rustev.dynamic-eval-report/1`: coverage, abstention by reason, accepted
error, uncalibrated Brier and log loss or mean level distance, overall
and over adversarial cases; `uncalibrated`, `mechanics_only` on
synthetic data, every gate `unknown`.
- Tests: `rustev-contract/tests/dynamic_wire.rs`,
`rustev-core/tests/dynamic.rs` (including adversarial text in every
caller-controlled field), `rustev-runtime/tests/dynamic.rs` (section 5
rows 1 to 7 with a dispatch counter), `rustev-eval/tests/dynamic.rs`.
- `tools/rustev-release/archive-policy.json`: the four new source files
join the reviewed archive lists; 019 now `extends`
`tools/rustev-release/` (additive) for it.
- `tools/rustev-conformance/fp-corpus` (spec 027, 3.11.3): the dynamic
log loss's `rustev_core::math::ln` call joins the differential corpus as
`eval.dynamic_log_loss.ln` (probability domain, as the existing log-loss
site), with its digests committed in `expected.json`; 019 `extends`
`tools/rustev-conformance/` (additive) and its verification runs the
corpus test.
- `Makefile`: 019 joins `VERIFIED_SPECS`.
- Spec 019: `implementation: complete`, Verification declares the
acceptance commands, implementation record. No existing document,
golden, plan id or test changed.

What remains: nothing in 019's acceptance. Calibration of a dynamic task
family needs a separately fitted artifact with its own binding; none
exists and none is claimed.

Owner decisions:
1. Whether the dynamic documents join spec 027's JSON Schema emitter
(3.2.2, "every public document type"). They are not emitted here: doing
so adds schema files under `crates/rustev-contract/schema/` and changes
the generated binding types under `integrations/rustev-wasm/types/` that
spec 027 owns, and neither spec says whether dynamic documents belong in
the binding surface.
2. Defaults chosen where the spec is silent, recorded in the
implementation record:
- `DISTRIBUTION_TOLERANCE` is 0.000001, equal to the reference plans'
tolerance.
- `min_margin` is top mass minus the second mass; ties go to the earlier
declared label.
- Free-text backend output retained in an outcome is cut to 256 bytes.
- Every evaluation gate is reported `unknown`: over synthetic data a
gate would claim quality from mechanics, and real data needs separately
governed admission (spec 023) that no dynamic dataset binds yet.

Local verification (macOS arm64): `make gate`, `make code` (build, test,
clippy `-D warnings`, fmt, boundaries), `.bin/spec-spine verify 019` (12
commands, passed), `rustev-fp-corpus check` (5 sites agree natively).
The WebAssembly corpus runs (`make bindings`) were not run locally: this
toolchain lacks the `wasm32-unknown-unknown` target. Rebased onto `main`
after #146, again after #143 to #145 merged (#145's corpus test required
the new site), and again after #150 (`VERIFIED_SPECS` and the contract's
schema constants unioned); derived shards regenerated each time.

Review round 1 (1 finding, fixed): `bounded_raw` kept NaN and infinite
distribution masses, so the outcome for that invalid output could not be
serialized and the evidence was lost. Such a distribution is now
recorded, and judged, as `Unrecognized { shape: non_finite_mass }` with
the masses as text (a new `ResponseShape` variant), so the outcome stays
a writable record and offline reproduction judges exactly what was
recorded.
`adapter_failures_and_malformed_outputs_are_named_and_never_retried` now
includes a NaN and an infinite distribution, asserts the recorded shape
and round-trips both outcomes. The implementation record says so.

Review round 1 (1 finding, fixed): `bounded_raw` kept NaN and infinite
distribution masses, so the outcome for that invalid output could not be
serialized and the evidence was lost. Such a distribution is now
recorded, and judged, as `Unrecognized { shape: non_finite_mass }` with
the masses as text (a new `ResponseShape` variant), so the outcome stays
a writable record and offline reproduction judges exactly what was
recorded.
`adapter_failures_and_malformed_outputs_are_named_and_never_retried` now
includes a NaN and an infinite distribution, asserts the recorded shape
and round-trips both outcomes. The implementation record says so.

Review round 2 (0 findings) on the rebased head 48c6c15.

Review round 3 (1 finding, fixed in the docs, behavior kept):
"`proposal()` omits `abstention` from `exact_processing` for label
answers, contradicting its doc comment and the implementation record."
The behavior is intended: under the explicit `label_only` posture no
abstention rule runs (`judge` returns `AbstentionDecision::LabelOnly`),
so listing `abstention` would claim an exact step that never ran. The
doc comment and the implementation record were wrong and now say
`validate` always, `abstention` only when thresholds were applied. The
core test for label output now builds the proposal and asserts its
lineage is exactly `["validate"]`.

Review round 4 (0 findings) on f9c4045. Rebased onto `main` after #152
(no conflicts, shards current).

Review round 5 (0 findings) on 54587eb; ci-gate passed.
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