Skip to content

impl(011): an onnx bundle's embedding cache from the record's in-process repeatability, and 011 in make verify (3.14.3) - #533

Merged
bartekus merged 3 commits into
mainfrom
impl/011-complete
Nov 6, 2026
Merged

bartekus merged 3 commits into
mainfrom
impl/011-complete

Conversation

@bartekus

@bartekus bartekus commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Spec 011: an onnx bundle's embedding cache evidence (3.14.3) and 011 in make verify

What changes

  • src/runtime.rs gains IN_PROCESS_REPEATABILITY, the settings under which the committed feasibility record measured bitwise run-to-run repeatability in one process on a qualified platform (one entry: linux-x86_64-gnu, graph SHA-256, ONNX Runtime 1.31.0 and the platform library's SHA-256, ort 2.0.0-rc.15, CPU, optimization all, 1/1 threads, f32, mean_masked + l2), and FEASIBILITY_RECORD, the record's contract digest. repeatability_evidence issues Measured evidence only when the platform is qualified, the manifest names the committed record and every setting matches.
  • src/backend.rs: an onnx bundle's cache is decided after the platform check and before the runtime path is read. The cache is allowed exactly for the measured settings on linux-x86_64-gnu. Everywhere else it is still refused cache_not_equivalent, including linux-aarch64-gnu (bitwise repeatable but unqualified) and macos-aarch64.
  • Platform::key() in src/manifest.rs.
  • Tests (offline, no real graph or library):
    • tests/feasibility_record.rs checks the table and the digest against the record.
    • tests/runtime/mod.rs covers allowed and refused on every platform key and for each changed setting. It also checks setup: cache_not_equivalent before any runtime on the qualified target, unqualified_platform elsewhere.
  • Spec 011: a verify:cli block replaces "Pending with implementation", and a new Implementation record paragraph is added. 011 is added to VERIFIED_SPECS.

Not flipped to implementation: complete

These Acceptance items are still unmet:

  • Partial adoption: the Node binding is not built with local-embed on every spec 027 native matrix target in CI. That needs a bindings workflow change.
  • 3.17.3: the service's local-embed feature is not done.
  • Binding parity: the local-embed conformance case through the service transports, which now exist, is not done.

Checks

Local runs on macos-aarch64:

  • spec-spine verify 011 passed: 5 commands, including the crate's bundle, feasibility_record and lib tests, and the boundary tests and run.
  • make boundaries passed.
  • cargo clippy -p rustev-backend-embed-linear --all-targets -- -D warnings, with and without default features, passed.
  • cargo fmt --all -- --check passed.
  • make gate passed.

On this host the qualified-target branch of the cfg-dependent tests (linux-x86_64-gnu) did not run. CI's Linux x86_64 runners cover it.

…ess repeatability, and 011 in make verify (3.14.3)
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff against the governance context, spec requirements, and code correctness.

Makefile — 011 added to VERIFIED_SPECS. The spec's new ## Verification block declares exactly the commands make verify will run. These are consistent.

manifest.rs — Platform::key() is a pure const fn with exhaustive match over the three variants. No issue.

runtime.rs — InProcessRepeatability::covers() checks QUALIFIED_PLATFORMS.contains(&platform) even though entries in IN_PROCESS_REPEATABILITY already only cover qualified platforms. This is a defensive guard that correctly prevents evidence from being issued for any future entry that might be added for an unqualified platform before the qualified-platforms table is updated. The SHA-256 hex constants (graph_sha256 = 64 chars, runtime_sha256 = 64 chars, FEASIBILITY_RECORD = "sha256:" + 64 chars) are all the correct length.

backend.rs — The refactor moves cache decision (open_cache) before runtime load in onnx_run, so cache_not_equivalent can be returned without touching the runtime path. The two call sites for open_cache are:

  • onnx_run: passes Some(platform) — onnx evidence path.
  • start (for synthetic/non-onnx): passes None — falls to Unproven or (with synthetic feature) Synthetic. Matches prior behavior.

For open_fixture: it now extracts the cache from the onnx setup if the bundle is onnx. The original code also called prepare (which ran onnx_run for onnx bundles), so no behavioral regression; the onnx Arc<Run> is immediately dropped as before since open_fixture uses the custom runner. The #[cfg(feature = "synthetic")] guard on open_fixture ensures this code path is test-only.

tests/feasibility_record.rs — The new test the_crates_cache_evidence_is_the_records_in_process_repeatability filters the feasibility record for verdict == "pass" && bitwise_in_process_repeatability == true. The existing test the_crates_platform_table_is_the_records_passing_verdicts already constrains QUALIFIED_PLATFORMS to exactly the passing platforms; since linux-aarch64-gnu is not in QUALIFIED_PLATFORMS, its record verdict is not "pass", so it would not appear in expected, making the new test consistent.

tests/runtime/mod.rs — The new tests cover: allowed for measured settings on the qualified platform, refused for each changed setting (11 cases), refused on each other platform, and the open path with cache+unmeasured settings. The onnx_bundle() / onnx_config() refactor is a pure extract with no behavioral change.

specs/011-semantic-backend/spec.md — The ## Verification section moves from "pending" prose to declared verify:cli commands, and an implementation record entry is added. The frontmatter is not changed (consistent with "implementation stays pending" as noted in the record). The spec properly owns the crate being changed (spec 011 is the owning spec for rustev-backend-embed-linear). No lifecycle or ratification concern.

No concrete defects found.

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

Subject: a9eeb9f...37aa3fb, diff digest 3f76d329d948f719fb65ec2bab485bb473cb42385c748f8424c863fd823790bc, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff against governance rules, I'll examine each changed file for correctness, security, and consistency.

runtime.rs — SHA-256 constants

Counted all three hex strings: FEASIBILITY_RECORD (64 chars), graph_sha256 (64 chars), runtime_sha256 (64 chars). All are well-formed SHA-256 hex values.

backend.rs — refactored cache/onnx setup

The OnnxSetup = (Arc<Run>, Cache) type alias and the restructured open/start/onnx_run correctly propagate the cache from onnx_run through to start. The two-layer Option<Cache> pattern in start is correct: Some(cache) takes the onnx-decided cache, None falls back to open_cache with None platform (the synthetic path). The ordering in onnx_run — qualified_platform → open_cache → runtime::load — matches the stated intent (cache refusal before any runtime I/O).

manifest.rs — Platform::key()

New const fn is correct; all three variants map to the strings used consistently throughout the codebase and the feasibility record filenames.

runtime.rs — InProcessRepeatability::covers()

The method checks e.kind == EncoderKind::Onnx, platform == self.platform, QUALIFIED_PLATFORMS.contains(&platform), the feasibility record digest, graph sha256, precision, all runtime version/settings, the per-platform library sha256, pooling mode, and normalize. This matches the documented set of fields that determine embedding bits (heads, cost, tokenizer are correctly excluded). The redundancy of platform == self.platform and QUALIFIED_PLATFORMS.contains(&platform) given that table entries only cover qualified platforms is harmless.

tests/offline.rs — no_source_file_names_a_network_api

Correctly limits the scan to src/ only, so the NETWORK_APIS string literals in the test file itself don't self-trigger. The assert!(files.len() >= 10) matches the 11 files in src/. The assert!(...contains("default-features = false, features = [\"std\", \"load-dynamic\"")) is a positive whitelist assertion about ort configuration, not just a negative check.

tests/feasibility_record.rs — new tests

The the_crates_cache_evidence_is_the_records_in_process_repeatability test cross-checks every field of IN_PROCESS_REPEATABILITY against the committed feasibility JSON (probe and complete backend measurements). The the_crates_record_digest_is_the_committed_ones test verifies FEASIBILITY_RECORD against feasibility.sha256. Together these close the trust chain between the hardcoded constants and the committed evidence.

tests/runtime/mod.rs — cache decision tests

measured_manifest correctly assembles a manifest matching IN_PROCESS_REPEATABILITY[0]. The exhaustive "every other platform, every changed setting" test covers all fields checked by covers(). The end-to-end an_onnx_bundle_with_a_cache_and_unmeasured_settings_is_refused_at_setup test verifies the new ordering (cache refusal before runtime path). All branches match the spec commentary.

scripts/acceptance/verify.py and Makefile

011 added to VERIFIED_SPECS and cli-repeat group consistently. The verify:cli block in the spec matches the actual cargo test invocations.

spec.md lifecycle

implementation stays pending with explicit accounting of remaining work (Node binding matrix coverage, service local-embed feature). This is correct per the contract (approved + pending = work order).

No concrete defects found.

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

Subject: a9eeb9f...f076847, diff digest b68b33c9d2e6d137b87cccc6e88018bafb5f71895cfc819adfece3a0dbfc3b26, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Looking at this PR, which wires an ONNX bundle's embedding cache evidence into the backend setup (spec 011, section 3.14.3), and adds declared verification.

Key changes reviewed:

  1. backend.rs: open_cache refactored to accept Option<Platform>; for ONNX bundles the cache is decided after the platform check and before runtime loading. onnx_run now returns OnnxSetup = (Arc<Run>, Cache). start takes the already-decided cache for ONNX paths, falling back to open_cache(..., None) only for the synthetic path.

  2. runtime.rs: FEASIBILITY_RECORD, InProcessRepeatability, IN_PROCESS_REPEATABILITY, and repeatability_evidence added. All SHA-256 hex strings verified as 64 characters.

  3. manifest.rs: Platform::key() added as a const fn; used consistently in cache key construction via platform.map_or("", Platform::key).

  4. Tests: feasibility_record.rs and runtime/mod.rs additions validate the table against the committed record offline. offline.rs checks the crate's source against a network-API allowlist.

  5. verify.py and Makefile: Spec 011 added to cli-repeat and VERIFIED_SPECS.

Correctness trace through open/open_with_runner paths:

  • ONNX path: prepare → onnx_run → (run, cache) decided; open extracts both; start receives Some(cache) and uses it directly. No double-opening.
  • Synthetic path: prepare returns onnx = None; start receives None, falls through to open_cache(..., None) which correctly matches (EncoderKind::Synthetic, _).
  • open_with_runner: for ONNX bundles, the cache is extracted from the onnx setup and the passed runner replaces the ONNX run. For synthetic bundles, same None fallback.

InProcessRepeatability::covers: The QUALIFIED_PLATFORMS.contains(&platform) check is redundant given IN_PROCESS_REPEATABILITY entries only have qualified platforms (enforced by the_crates_cache_evidence_is_the_records_in_process_repeatability), but harmless as defense-in-depth.

Spec 011 lifecycle: implementation stays pending (Node binding and service integration outstanding); approved + pending is a valid "work order" state per the contract table. Adding 011 to make verify is consistent with the declared verification section.

No concrete defects found in code paths, security, authority, or ratification.

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

Subject: a9eeb9f...4871c42, diff digest 5a01163c7137b5edafa3b12b2edb734b2af479366efc56a5e76b8517d9cfb107, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 61260fb Nov 6, 2026
26 checks passed
@bartekus
bartekus deleted the impl/011-complete branch November 6, 2026 20:56
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