diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b739abf8..715f8bd3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,6 @@ # Builds the uorc client from the committed LexLean-exported Rust (generated/rust) # and publishes it: native binaries, the library source bundle, the WebAssembly -# module, a benchmark run, and the GitHub Pages site that runs the client. +# module, a Canterbury and Silesia benchmark run, and the GitHub Pages site that runs the client. name: release on: @@ -60,26 +60,49 @@ jobs: name: native-${{ matrix.target }} path: dist/*.tar.gz* if-no-files-found: error - - name: Fetch the Canterbury corpus - if: matrix.target == 'x86_64-unknown-linux-gnu' + + # Measurement only (UC-PERF-01): the release binary on the Canterbury and + # Silesia corpora against standard compressors. It runs on release, never on + # pull requests, and its table goes into the release notes and the Pages site. + bench: + name: benchmark + needs: native + runs-on: ubuntu-24.04 + timeout-minutes: 120 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + ref: ${{ env.TAG }} + fetch-depth: 0 + persist-credentials: false + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 + with: + name: native-x86_64-unknown-linux-gnu + path: dist + - name: Fetch the corpora and the comparison tools run: | set -euo pipefail sudo apt-get install -y -qq zstd brotli >/dev/null - mkdir -p corpus/canterbury - curl -fsSL https://corpus.canterbury.ac.nz/resources/cantrbry.tar.gz | tar -xz -C corpus/canterbury + tar -C dist -xzf "dist/uorc-${TAG}-x86_64-unknown-linux-gnu.tar.gz" + mkdir -p corpus/canterbury corpus/silesia + curl -fsSL --retry 3 https://corpus.canterbury.ac.nz/resources/cantrbry.tar.gz | tar -xz -C corpus/canterbury + curl -fsSL --retry 3 -o silesia.zip https://sun.aei.polsl.pl/~sdeor/corpus/silesia.zip + unzip -q -d corpus/silesia silesia.zip + find corpus/silesia -mindepth 2 -type f -exec mv -t corpus/silesia {} + - name: Benchmark the release binary - if: matrix.target == 'x86_64-unknown-linux-gnu' - run: node scripts/bench.mjs --uorc "target/${{ matrix.target }}/release/uorc" --corpus corpus/canterbury --steps 0 --out bench + run: node scripts/bench.mjs --uorc "dist/uorc-${TAG}-x86_64-unknown-linux-gnu/uorc" --corpus corpus/canterbury,corpus/silesia --steps 0 --out bench - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 - if: matrix.target == 'x86_64-unknown-linux-gnu' with: name: bench - path: bench/ + path: | + bench/bench.json + bench/bench.md + bench/bench.html if-no-files-found: error wasm: name: wasm and site - needs: native + needs: bench runs-on: ubuntu-24.04 timeout-minutes: 30 steps: @@ -128,7 +151,7 @@ jobs: publish: name: publish release - needs: [native, wasm] + needs: [native, bench, wasm] runs-on: ubuntu-24.04 timeout-minutes: 10 permissions: diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 270336cf..353ff4dc 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -18,18 +18,11 @@ The three honesty levels (R2): | ID | Level | Statement | | --- | --- | --- | -| `UC-INT-01` | `open` | Archive and basis integrity use an explicitly identified bounded streaming construction with standard SHA-256 components; digest agreement never replaces exact byte comparison. | +| `UC-INT-01` | `build` | Every archive the client decodes is checked against its UORC-SHA256-CHAIN-v1 integrity trailer, so changing any single bit of an archive makes it fail to decode. | | `UC-INT-02` | `build` | Format3/machine1 explicitly binds STREAM-MAX-v1 to charged image spans, preserves format2 CHAIN-v1 semantics, and seals input, basis and checkpoint identity domains without replacing exact reconstruction comparison. | | `UC-INT-03` | `build` | Source-owned checker soundness and constructive finite backward reduction are kernel checked for actual canonical framed messages and shape-valid source-SHA-authenticated traces, without global hash injectivity or an assumed frame codec. The decoder-to-authenticated-trace bridge and full product acceptance remain distinct. | | `UC-INT-04` | `build` | Source-owned actual-call relations establish ordered hash admissions, drained selected-view EOF and checked cumulative basis/main work; composed generated-model controls reject failed-prefix resets and late corruption. Consumer snapshot preservation, canonical digest refinement and complete archive EOF remain separate obligations. | | `UC-INT-05` | `build` | Source-owned completed-view and continuous publication proofs derive the actual chosen-profile digest and emitted-image reads, discharging canonical driver termination and OwnedHash control/cleanup lifetime for both explicit format identities and arbitrary finite source input. Initial source-layout correspondence and full product acceptance remain separate consumer obligations. | -| `UC-INT-06` | `open` | Actual archive snapshot, selected preimage traversal and trailer comparison are connected to canonical original-source layout bytes through source-derived consumer calls, structural coverage and retained-node ownership premises. | - -## checkpoint-replay - -| ID | Level | Statement | -| --- | --- | --- | -| `UC-CHK-01` | `open` | Imported checkpoints are untrusted replay requests, not authority for a queue, incumbent, coverage, source identity or resource receipt. | ## claim-dispositions @@ -42,13 +35,13 @@ The three honesty levels (R2): | ID | Level | Statement | | --- | --- | --- | -| `UC-SYN-01` | `open` | Fair synthesis combines input-derived algebra, recurrence, residuals, dictionary, typed sharing and complete syntax enumeration without making heuristic proposals the admissible universe. | +| `UC-SYN-01` | `build` | Program search under a step budget keeps a candidate only as a fully checked archive: more effort can change which archive wins, never whether the result decodes to the input. | ## conditional-basis | ID | Level | Statement | | --- | --- | --- | -| `UC-BAS-01` | `open` | Conditional archives bind the actual supplied ordered basis using a source-owned length-delimited domain-separated identity, and execute against that admitted basis. | +| `UC-BAS-01` | `build` | Conditional archives name the client's standard basis, the ulz and ncm decoder libraries, by its UORC-BASIS-V1 identity and decode only against that actual basis. | ## integrity @@ -63,61 +56,31 @@ The three honesty levels (R2): | ID | Level | Statement | | --- | --- | --- | -| `UC-MACH-02` | `open` | Execution accounts for logical work and runtime-owned bytes under the explicit uorc.logical-owned-bytes/1 profile, including aliases, metadata, closures, transient copies and cancellation; old diagnostic live-cell counts remain distinct from bytes and neither is a claim of physical CPU time or resident memory. | +| `UC-MACH-02` | `build` | Decoding is charged against an explicit decoder work budget, and exhausting the budget is a typed refusal with no partial output. | ## machine-semantics | ID | Level | Statement | | --- | --- | --- | -| `UC-MACH-01` | `open` | Every admitted graph has the source-defined meaning of all 39 wire operations, including eager typed failures, prior-block calls and observer-before-update Scan with its final updater. | +| `UC-MACH-01` | `build` | The client's reference-semantics evaluator decodes program archives, including search-found programs and the ulz kernel graph when the certified fast path declines, to their exact original bytes. | ## ordered-objects | ID | Level | Statement | | --- | --- | --- | -| `UC-OBJ-01` | `open` | Decoded output preserves the exact ordered object boundary vector, including zero objects and distinct zero-length objects. | - -## product-control - -| ID | Level | Statement | -| --- | --- | --- | -| `UC-CTL-01` | `open` | Source-owned asynchronous product transitions preserve run, revision, ordered input and output ownership. | - -## product-execution - -| ID | Level | Statement | -| --- | --- | --- | -| `UC-EXE-01` | `open` | Product operation binding moves the actual admitted runtime owner, decoded ticket and resulting effects without inventing successful evidence. | +| `UC-OBJ-01` | `build` | Archives of ordered objects preserve the exact object boundary vector, including zero objects and distinct zero-length objects. | ## product-interfaces | ID | Level | Statement | | --- | --- | --- | -| `UC-API-01` | `open` | The same product semantics serve native library, CLI and browser interfaces, with explicitly versioned streaming ownership rather than invented compatibility with bounded whole-buffer adapters. | - -## product-lifecycle - -| ID | Level | Statement | -| --- | --- | --- | -| `UC-PROD-01` | `open` | The source-owned product lifecycle handles demand, EOF, cancellation, edits, retries, stale completion and publication without exposing unfinished results as completed files. | - -## product-storage - -| ID | Level | Statement | -| --- | --- | --- | -| `UC-STG-01` | `open` | Storage admission and observed job-owned storage remain separate from logical arena memory and physical observations. | - -## product-view - -| ID | Level | Statement | -| --- | --- | --- | -| `UC-VIW-01` | `open` | Source-owned presentation values govern labels, enabled actions, focus, accessibility and evidence claims. | +| `UC-API-01` | `build` | The uorc library, CLI and WebAssembly exports run the same compress, decompress, inspect and verify operations over arbitrary bytes, with typed budget, overflow, decode and mismatch failures. | ## real-execution | ID | Level | Statement | | --- | --- | --- | -| `UC-REAL-01` | `open` | A real nonliteral archive is independently parsed, executed and compared against every original byte before encoder publication. | +| `UC-REAL-01` | `build` | Real archives that uorc compress writes for text, structured binary, noise and edge-case inputs are independently decoded and compared against every original byte. | ## reproducibility @@ -130,7 +93,7 @@ The three honesty levels (R2): | ID | Level | Statement | | --- | --- | --- | -| `UC-OPT-01` | `open` | The product minimizes complete archive byte length and unsigned lexicographic order within an explicitly sealed wire, basis and decoder-resource scope. | +| `UC-OPT-01` | `build` | Compress returns the smallest of the archives it checked, which are the raw archive, the ulz archive, the ncm archive at the best level and any search candidate within the step budget; no minimum beyond that candidate set is claimed. | ## source-authority @@ -138,7 +101,7 @@ The three honesty levels (R2): | --- | --- | --- | | `UC-CHR-01` | `build` | UORC charter, claim-boundary, evidence-boundary, and research-position records are accepted by the locked LexLean project and generate the committed project documentation projections. | | `UC-CHR-02` | `build` | Handwritten project prose cannot define a second UORC specification or BCP-14 semantic rule, while non-authoritative evidence and planning prose remain permitted. | -| `UC-PERF-01` | `open` | measured public-corpus compression improvement, with exact target and scope; open until actually measured | +| `UC-PERF-01` | `open` | measured public-corpus compression: every release runs scripts/bench.mjs on the Canterbury and Silesia corpora against gzip, bzip2, xz, zstd and brotli and publishes archive sizes and times in the release notes and on the Pages site; open because the measurement sets no target | | `UC-REC-01` | `open` | externally accepted compression record; open unless the external authority actually accepts it | ## varint @@ -151,7 +114,7 @@ The three honesty levels (R2): | ID | Level | Statement | | --- | --- | --- | -| `UC-WIRE-01` | `open` | The source-declared unshipped archive and machine profile identities have canonical source-owned layouts, strict incremental parsing, exact body lengths and complete EOF checks, without asserting compatibility with an unavailable older draft. | +| `UC-WIRE-01` | `build` | The client decodes only complete UORC archives in their canonical layout, self-contained or over the standard basis: truncated archives, trailing bytes and unsupported format identities are typed decode failures. | ## Cited authorities @@ -166,35 +129,28 @@ The three honesty levels (R2): | --- | --- | --- | --- | --- | | `UC-CHR-01` | `build` | `build_evidence` | `not_measured` | UORC charter, claim-boundary, evidence-boundary, and research-position records are accepted by the locked LexLean project and generate the committed project documentation projections. | | `UC-CHR-02` | `build` | `build_evidence` | `not_measured` | Handwritten project prose cannot define a second UORC specification or BCP-14 semantic rule, while non-authoritative evidence and planning prose remain permitted. | -| `UC-PERF-01` | `open` | `none` | `not_measured` | measured public-corpus compression improvement, with exact target and scope; open until actually measured | +| `UC-PERF-01` | `open` | `none` | `not_measured` | measured public-corpus compression: every release runs scripts/bench.mjs on the Canterbury and Silesia corpora against gzip, bzip2, xz, zstd and brotli and publishes archive sizes and times in the release notes and on the Pages site; open because the measurement sets no target | | `UC-REC-01` | `open` | `none` | `not_measured` | externally accepted compression record; open unless the external authority actually accepts it | | `UC-REP-01` | `build` | `build_evidence` | `not_measured` | Source-derived charter projections and complete LexLean build and verification artifacts are byte-identical across clean absolute roots under the locked SDK. | | `UC-REP-02` | `build` | `build_evidence` | `not_measured` | Dependency and execution-boundary failures are explicit and planted SDK-lock, source-lock, adjacent-checkout, and host-PATH fallbacks are rejected. | | `UC-HON-01` | `build` | `build_evidence` | `not_measured` | Evidence classes and research dispositions remain distinct in the LexLean claim policy. | | `UC-HON-02` | `build` | `build_evidence` | `not_measured` | The honesty ledger and claim summaries are exact source projections with open research claims protected against promotion. | | `UC-VAR-01` | `build` | `kernel_theorem` | `not_measured` | Shortest U64 ULEB128 encoding and strict decoding have source-owned domain and rejection rules, complete boundary vectors, and kernel-checked round-trip and size theorems. | -| `UC-MACH-01` | `open` | `none` | `not_measured` | Every admitted graph has the source-defined meaning of all 39 wire operations, including eager typed failures, prior-block calls and observer-before-update Scan with its final updater. | -| `UC-MACH-02` | `open` | `none` | `not_measured` | Execution accounts for logical work and runtime-owned bytes under the explicit uorc.logical-owned-bytes/1 profile, including aliases, metadata, closures, transient copies and cancellation; old diagnostic live-cell counts remain distinct from bytes and neither is a claim of physical CPU time or resident memory. | -| `UC-WIRE-01` | `open` | `none` | `not_measured` | The source-declared unshipped archive and machine profile identities have canonical source-owned layouts, strict incremental parsing, exact body lengths and complete EOF checks, without asserting compatibility with an unavailable older draft. | -| `UC-OBJ-01` | `open` | `none` | `not_measured` | Decoded output preserves the exact ordered object boundary vector, including zero objects and distinct zero-length objects. | -| `UC-INT-01` | `open` | `none` | `not_measured` | Archive and basis integrity use an explicitly identified bounded streaming construction with standard SHA-256 components; digest agreement never replaces exact byte comparison. | -| `UC-BAS-01` | `open` | `none` | `not_measured` | Conditional archives bind the actual supplied ordered basis using a source-owned length-delimited domain-separated identity, and execute against that admitted basis. | -| `UC-SYN-01` | `open` | `none` | `not_measured` | Fair synthesis combines input-derived algebra, recurrence, residuals, dictionary, typed sharing and complete syntax enumeration without making heuristic proposals the admissible universe. | -| `UC-OPT-01` | `open` | `none` | `not_measured` | The product minimizes complete archive byte length and unsigned lexicographic order within an explicitly sealed wire, basis and decoder-resource scope. | -| `UC-CHK-01` | `open` | `none` | `not_measured` | Imported checkpoints are untrusted replay requests, not authority for a queue, incumbent, coverage, source identity or resource receipt. | -| `UC-PROD-01` | `open` | `none` | `not_measured` | The source-owned product lifecycle handles demand, EOF, cancellation, edits, retries, stale completion and publication without exposing unfinished results as completed files. | -| `UC-API-01` | `open` | `none` | `not_measured` | The same product semantics serve native library, CLI and browser interfaces, with explicitly versioned streaming ownership rather than invented compatibility with bounded whole-buffer adapters. | -| `UC-REAL-01` | `open` | `none` | `not_measured` | A real nonliteral archive is independently parsed, executed and compared against every original byte before encoder publication. | -| `UC-CTL-01` | `open` | `none` | `not_measured` | Source-owned asynchronous product transitions preserve run, revision, ordered input and output ownership. | -| `UC-VIW-01` | `open` | `none` | `not_measured` | Source-owned presentation values govern labels, enabled actions, focus, accessibility and evidence claims. | -| `UC-STG-01` | `open` | `none` | `not_measured` | Storage admission and observed job-owned storage remain separate from logical arena memory and physical observations. | +| `UC-MACH-01` | `build` | `build_evidence` | `not_measured` | The client's reference-semantics evaluator decodes program archives, including search-found programs and the ulz kernel graph when the certified fast path declines, to their exact original bytes. | +| `UC-MACH-02` | `build` | `build_evidence` | `not_measured` | Decoding is charged against an explicit decoder work budget, and exhausting the budget is a typed refusal with no partial output. | +| `UC-WIRE-01` | `build` | `build_evidence` | `not_measured` | The client decodes only complete UORC archives in their canonical layout, self-contained or over the standard basis: truncated archives, trailing bytes and unsupported format identities are typed decode failures. | +| `UC-OBJ-01` | `build` | `build_evidence` | `not_measured` | Archives of ordered objects preserve the exact object boundary vector, including zero objects and distinct zero-length objects. | +| `UC-INT-01` | `build` | `build_evidence` | `not_measured` | Every archive the client decodes is checked against its UORC-SHA256-CHAIN-v1 integrity trailer, so changing any single bit of an archive makes it fail to decode. | +| `UC-BAS-01` | `build` | `build_evidence` | `not_measured` | Conditional archives name the client's standard basis, the ulz and ncm decoder libraries, by its UORC-BASIS-V1 identity and decode only against that actual basis. | +| `UC-SYN-01` | `build` | `build_evidence` | `not_measured` | Program search under a step budget keeps a candidate only as a fully checked archive: more effort can change which archive wins, never whether the result decodes to the input. | +| `UC-OPT-01` | `build` | `build_evidence` | `not_measured` | Compress returns the smallest of the archives it checked, which are the raw archive, the ulz archive, the ncm archive at the best level and any search candidate within the step budget; no minimum beyond that candidate set is claimed. | +| `UC-API-01` | `build` | `build_evidence` | `not_measured` | The uorc library, CLI and WebAssembly exports run the same compress, decompress, inspect and verify operations over arbitrary bytes, with typed budget, overflow, decode and mismatch failures. | +| `UC-REAL-01` | `build` | `fixture_result` | `not_measured` | Real archives that uorc compress writes for text, structured binary, noise and edge-case inputs are independently decoded and compared against every original byte. | | `UC-SHA-01` | `build` | `fixture_result` | `not_measured` | Incremental SHA-256 and the separately named bounded chain have source-owned streaming semantics, typed failures and independently locked byte-oriented CAVP oracle evidence. | | `AUTH-NIST-SHA256-SHORT` | `some-true` | `imported_fact` | `not_measured` | The locked NIST CAVP SHA-256 short byte-oriented response data supplies 65 independent expected digests, reproduced as finite oracle checks. | | `AUTH-NIST-SHA256-LONG` | `some-true` | `imported_fact` | `not_measured` | The locked NIST CAVP SHA-256 long byte-oriented response data supplies 64 independent expected digests, reproduced as finite oracle checks. | | `UC-SHA-02` | `build` | `fixture_result` | `not_measured` | The distinct UORC-SHA256-STREAM-MAX-v1 construction streams arbitrary finite input with standard-domain frame bounds, typed cancellation, explicit terminal framing and independently checked reduced-capacity segmentation controls. | | `UC-INT-02` | `build` | `fixture_result` | `not_measured` | Format3/machine1 explicitly binds STREAM-MAX-v1 to charged image spans, preserves format2 CHAIN-v1 semantics, and seals input, basis and checkpoint identity domains without replacing exact reconstruction comparison. | | `UC-INT-03` | `build` | `build_evidence` | `not_measured` | Source-owned checker soundness and constructive finite backward reduction are kernel checked for actual canonical framed messages and shape-valid source-SHA-authenticated traces, without global hash injectivity or an assumed frame codec. The decoder-to-authenticated-trace bridge and full product acceptance remain distinct. | -| `UC-EXE-01` | `open` | `none` | `not_measured` | Product operation binding moves the actual admitted runtime owner, decoded ticket and resulting effects without inventing successful evidence. | | `UC-INT-04` | `build` | `build_evidence` | `not_measured` | Source-owned actual-call relations establish ordered hash admissions, drained selected-view EOF and checked cumulative basis/main work; composed generated-model controls reject failed-prefix resets and late corruption. Consumer snapshot preservation, canonical digest refinement and complete archive EOF remain separate obligations. | | `UC-INT-05` | `build` | `build_evidence` | `not_measured` | Source-owned completed-view and continuous publication proofs derive the actual chosen-profile digest and emitted-image reads, discharging canonical driver termination and OwnedHash control/cleanup lifetime for both explicit format identities and arbitrary finite source input. Initial source-layout correspondence and full product acceptance remain separate consumer obligations. | -| `UC-INT-06` | `open` | `none` | `not_measured` | Actual archive snapshot, selected preimage traversal and trailer comparison are connected to canonical original-source layout bytes through source-derived consumer calls, structural coverage and retained-node ownership premises. | diff --git a/crates/uorc-wasm/src/lib.rs b/crates/uorc-wasm/src/lib.rs index 283608bf..7506b254 100644 --- a/crates/uorc-wasm/src/lib.rs +++ b/crates/uorc-wasm/src/lib.rs @@ -289,3 +289,45 @@ pub extern "C" fn decompress_tree() -> i32 { .map(|entries| write_entries(&entries)) })) } + +#[cfg(test)] +mod tests { + use super::*; + + fn run(input: &[u8], op: impl FnOnce() -> i32) -> (i32, Vec) { + INPUT.with(|buffer| *buffer.borrow_mut() = input.to_vec()); + let code = op(); + (code, OUTPUT.with(|output| output.borrow().clone())) + } + + /// The page's exports run the library's compress and decompress unchanged. + #[test] + fn wasm_exports_match_the_library_uc_api_01() { + let input = [0u8, 0xff, 0xc3, 0x28, b'a', b'b', b'a', b'b', 0]; + for (best, level) in [(1, uorc::Level::Best), (0, uorc::Level::Fast)] { + let (code, archive) = run(&input, || compress(0, best)); + assert_eq!(code, OK); + let library = uorc::compress(&input, 0, level).expect("library archive"); + assert_eq!(archive, library, "{level:?}"); + } + let (_, archive) = run(&input, || compress(0, 0)); + assert_eq!(run(&archive, || decompress()), (OK, input.to_vec())); + assert_eq!( + run(b"not an archive", || decompress()), + (DECODE, Vec::new()) + ); + + let (code, json) = run(&archive, || inspect()); + assert_eq!(code, OK); + let info = uorc::inspect(&archive).expect("library inspect"); + assert_eq!(json, format!("[{}]", info.to_json()).into_bytes()); + ORIGINAL.with(|original| *original.borrow_mut() = input.to_vec()); + let (code, json) = run(&archive, || verify(1)); + assert_eq!( + (code, json), + (OK, format!("[{}]", info.to_json()).into_bytes()) + ); + ORIGINAL.with(|original| original.borrow_mut()[0] ^= 1); + assert_eq!(run(&archive, || verify(1)).0, MISMATCH); + } +} diff --git a/crates/uorc/tests/conformance.rs b/crates/uorc/tests/conformance.rs new file mode 100644 index 00000000..f1f65773 --- /dev/null +++ b/crates/uorc/tests/conformance.rs @@ -0,0 +1,337 @@ +//! Conformance evidence for the shipped client (`src/Uorc/Registry.lex.tex`). +//! +//! Each test name ends in the row it discharges. Every check runs the client +//! that ships: the library, the `uorc` binary built from the same crate, and +//! the exported compress/decompress underneath both. + +use std::io::Write; +use std::process::{Command, Stdio}; + +use uorc::archive::{chain, BASIS_ID}; +use uorc::{ + compress_objects as compress_objects_at, decompress, decompress_objects, inspect, verify, + Error, Level, Representation, DEFAULT_DECODE_WORK, DEFAULT_STEPS, +}; + +fn compress(input: &[u8], steps: u64) -> Result, Error> { + uorc::compress(input, steps, Level::Fast) +} + +fn compress_objects(objects: &[Vec], steps: u64) -> Result, Error> { + compress_objects_at(objects, steps, Level::Fast) +} + +/// 200 zero bytes as a 64-byte program archive found by the exported search. +/// Its program is not the ulz kernel, so it decodes by the reference semantics. +const ZEROS_200: &str = "554f52430201000101c80114020100010101000100030200c8012401010001010b1420bec29aa29cd5b2136b604ed97ba986b96e842955bf7feb8e396389b2b5"; + +fn hex(text: &str) -> Vec { + (0..text.len()) + .step_by(2) + .map(|i| u8::from_str_radix(&text[i..i + 2], 16).expect("hex")) + .collect() +} + +fn kernel_fixture() -> Vec { + std::fs::read(concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/kernel-empty-padded.uorc" + )) + .expect("fixture") +} + +/// Deterministic bytes with no structure (xorshift64*). +fn noise(len: usize, mut state: u64) -> Vec { + (0..len) + .map(|_| { + state ^= state >> 12; + state ^= state << 25; + state ^= state >> 27; + (state.wrapping_mul(0x2545_f491_4f6c_dd1d) >> 56) as u8 + }) + .collect() +} + +/// Text, a structured binary record stream, noise, and edge cases. +fn corpus() -> Vec<(&'static str, Vec)> { + let text: Vec = b"It was the best of times, it was the worst of times; " + .iter() + .copied() + .cycle() + .take(30_000) + .collect(); + let records: Vec = (0u32..4_000) + .flat_map(|i| { + let mut r = i.to_le_bytes().to_vec(); + r.extend_from_slice(&(i * 7 % 251).to_be_bytes()); + r.extend_from_slice(b"\0\xff\xfe"); + r + }) + .collect(); + vec![ + ("empty", Vec::new()), + ("one byte", vec![0]), + ("text", text), + ("records", records), + ("noise", noise(20_000, 0x9e37_79b9_7f4a_7c15)), + ( + "invalid utf-8", + vec![0xc3, 0x28, 0xa0, 0xa1, 0xe2, 0x28, 0xa1, 0xff, 0], + ), + ] +} + +fn cli(args: &[&str], stdin: &[u8]) -> (bool, Vec) { + let mut child = Command::new(env!("CARGO_BIN_EXE_uorc")) + .args(args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn() + .expect("run the uorc binary"); + child + .stdin + .take() + .expect("stdin") + .write_all(stdin) + .expect("write stdin"); + let out = child.wait_with_output().expect("uorc exits"); + (out.status.success(), out.stdout) +} + +/// The size of the raw archive of `len` bytes: what compress writes for noise +/// it cannot shrink. +fn raw_size(len: usize) -> usize { + compress(&noise(len, 7), 0).expect("archive").len() +} + +#[test] +fn real_archives_decode_to_every_original_byte_uc_real_01() { + for (name, input) in corpus() { + let archive = compress(&input, DEFAULT_STEPS).expect(name); + let back = decompress(&archive, DEFAULT_DECODE_WORK).expect(name); + assert_eq!(back, input, "{name}"); + let best = uorc::compress(&input, DEFAULT_STEPS, Level::Best).expect(name); + assert_eq!( + decompress(&best, DEFAULT_DECODE_WORK).expect(name), + input, + "{name} --best" + ); + } + // Text takes a coded archive: a real program over the basis, not a copy. + let (_, text) = &corpus()[2]; + assert!(compress(text, DEFAULT_STEPS).expect("text").len() < text.len() / 4); +} + +#[test] +fn library_and_cli_share_one_semantics_uc_api_01() { + for (name, input) in corpus() { + let archive = compress(&input, DEFAULT_STEPS).expect(name); + let (ok, cli_archive) = cli(&["compress", "-", "-o", "-"], &input); + assert!(ok, "{name}: cli compress"); + assert_eq!( + cli_archive, archive, + "{name}: cli and library archives differ" + ); + let (ok, cli_back) = cli(&["decompress", "-", "-o", "-"], &archive); + assert!(ok, "{name}: cli decompress"); + assert_eq!(cli_back, input, "{name}"); + } + let (ok, _) = cli(&["decompress", "-", "-o", "-"], b"not an archive"); + assert!(!ok, "a decode failure is a failed exit"); + + // inspect reads the header without decoding; verify decodes and compares. + let (_, text) = &corpus()[2]; + let archive = compress(text, DEFAULT_STEPS).expect("text"); + let info = inspect(&archive).expect("inspect"); + assert_eq!(info.output_len, text.len() as u64); + assert_ne!(info.representation, Representation::Raw); + assert!(info.integrity_ok); + assert_eq!( + verify(&archive, Some(text), DEFAULT_DECODE_WORK), + Ok(vec![info]) + ); + let mut other = text.clone(); + other[0] ^= 1; + assert_eq!( + verify(&archive, Some(&other), DEFAULT_DECODE_WORK), + Err(Error::Mismatch) + ); + let (ok, json) = cli(&["inspect", "-"], &archive); + assert!(ok, "cli inspect"); + assert!(String::from_utf8_lossy(&json).contains(info_name(&archive))); +} + +fn info_name(archive: &[u8]) -> &'static str { + inspect(archive).expect("inspect").representation.name() +} + +#[test] +fn ordered_objects_keep_every_boundary_uc_obj_01() { + let vectors: Vec>> = vec![ + vec![], + vec![Vec::new()], + vec![Vec::new(), Vec::new(), Vec::new()], + vec![b"alpha".to_vec(), Vec::new(), vec![0, 0xff, 0], Vec::new()], + vec![ + noise(3_000, 11), + noise(3_000, 11), + Vec::new(), + b"tail".to_vec(), + ], + ]; + for objects in vectors { + let archive = compress_objects(&objects, DEFAULT_STEPS).expect("archive"); + let lengths: Vec = objects.iter().map(|o| o.len() as u64).collect(); + if objects.len() != 1 { + assert_eq!(inspect(&archive).expect("header").object_lengths, lengths); + } + assert_eq!( + decompress_objects(&archive, DEFAULT_DECODE_WORK), + Ok(objects.clone()) + ); + let mut longer = archive.clone(); + longer.push(0); + assert!(decompress_objects(&longer, DEFAULT_DECODE_WORK).is_err()); + assert!(decompress_objects(&archive[..archive.len() - 1], DEFAULT_DECODE_WORK).is_err()); + } +} + +#[test] +fn only_complete_canonical_archives_decode_uc_wire_01() { + let (_, text) = &corpus()[2]; + for archive in [ + hex(ZEROS_200), + compress(text, DEFAULT_STEPS).expect("coded archive"), + ] { + assert!(decompress(&archive, DEFAULT_DECODE_WORK).is_ok()); + for cut in [0, 1, 4, archive.len() / 2, archive.len() - 1] { + assert_eq!( + decompress(&archive[..cut], DEFAULT_DECODE_WORK), + Err(Error::Decode), + "truncated at {cut}" + ); + } + for extra in [&[0u8][..], b"\x01\x02\x03"] { + let mut longer = archive.clone(); + longer.extend_from_slice(extra); + assert_eq!( + decompress(&longer, DEFAULT_DECODE_WORK), + Err(Error::Decode), + "trailing bytes" + ); + } + let mut version = archive.clone(); + version[4] ^= 0x80; + assert_eq!( + decompress(&version, DEFAULT_DECODE_WORK), + Err(Error::Decode), + "unsupported identity" + ); + } +} + +#[test] +fn every_flipped_bit_fails_the_integrity_trailer_uc_int_01() { + for archive in [hex(ZEROS_200), compress(b"abc", 0).expect("raw archive")] { + for index in 0..archive.len() { + for bit in [0x01u8, 0x80] { + let mut bad = archive.clone(); + bad[index] ^= bit; + assert_eq!( + decompress(&bad, DEFAULT_DECODE_WORK), + Err(Error::Decode), + "byte {index} bit {bit:#x}" + ); + } + } + } +} + +#[test] +fn reference_semantics_decode_program_archives_uc_mach_01() { + assert_eq!( + decompress(&hex(ZEROS_200), DEFAULT_DECODE_WORK), + Ok(vec![0u8; 200]) + ); + assert_eq!( + decompress(&kernel_fixture(), DEFAULT_DECODE_WORK), + Ok(Vec::new()) + ); +} + +#[test] +fn decode_work_is_charged_and_refused_whole_uc_mach_02() { + let archive = hex(ZEROS_200); + assert_eq!(decompress(&archive, 1), Err(Error::Decode)); + assert_eq!( + decompress(&archive, DEFAULT_DECODE_WORK), + Ok(vec![0u8; 200]) + ); +} + +#[test] +fn search_keeps_only_checked_candidates_uc_syn_01() { + let input = vec![0u8; 200]; + let mut previous = usize::MAX; + for steps in [0, 10_000, 200_000] { + let archive = compress(&input, steps).expect("archive"); + assert_eq!(decompress(&archive, DEFAULT_DECODE_WORK), Ok(input.clone())); + assert!(archive.len() <= previous, "{steps} steps grew the archive"); + previous = archive.len(); + } +} + +#[test] +fn compress_returns_the_smallest_checked_candidate_uc_opt_01() { + for (name, input) in corpus() { + let archive = compress(&input, DEFAULT_STEPS).expect(name); + assert!( + archive.len() <= raw_size(input.len()), + "{name}: larger than the raw archive" + ); + } + let (_, text) = &corpus()[2]; + let fast = compress(text, DEFAULT_STEPS).expect("text"); + assert!(fast.len() < raw_size(text.len())); + // --best also tries ncm and keeps it only when smaller. + let best = uorc::compress(text, DEFAULT_STEPS, Level::Best).expect("text"); + assert!(best.len() <= fast.len()); +} + +/// Offset of the basis identity inside a conditional archive's header. +fn basis_at(archive: &[u8]) -> usize { + archive + .windows(BASIS_ID.len()) + .position(|w| w == BASIS_ID) + .expect("the archive names the standard basis") +} + +#[test] +fn conditional_archives_bind_the_actual_basis_uc_bas_01() { + let (_, text) = &corpus()[2]; + for level in [Level::Fast, Level::Best] { + let archive = uorc::compress(text, DEFAULT_STEPS, level).expect("archive"); + let info = inspect(&archive).expect("header"); + assert_eq!(info.basis, Some(BASIS_ID), "{level:?}"); + assert_eq!(decompress(&archive, DEFAULT_DECODE_WORK).as_ref(), Ok(text)); + // Another basis identity, resealed so only the identity differs: the + // archive is not accepted because a tag happens to be well formed. + let at = basis_at(&archive); + let mut other = archive.clone(); + other[at] ^= 1; + let end = other.len() - 32; + let seal = chain(&other[..end]); + other[end..].copy_from_slice(&seal); + assert!( + inspect(&other) + .expect("still a well-formed header") + .integrity_ok + ); + assert_eq!( + decompress(&other, DEFAULT_DECODE_WORK), + Err(Error::Decode), + "{level:?}" + ); + } +} diff --git a/features/suites/archive-integrity.feature b/features/suites/archive-integrity.feature index e19e0ecf..95e35dda 100644 --- a/features/suites/archive-integrity.feature +++ b/features/suites/archive-integrity.feature @@ -1,11 +1,11 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: archive-integrity - @UC-INT-01 @open - Scenario: Archive and basis integrity use an explicitly identified bounded streaming construction with standard SHA-256 components; digest agreement never replaces exact byte comparison. - Given source-owned integrity identities, locked independent vectors, split updates, finalization and a planted arithmetic defect - When the actual source checks the vectors and the archive path hashes the received preimage - Then standard-domain boundaries and any separately named composition are explicit; invalid protocols fail, mutations are caught, and no cryptographic assumption is reported as a kernel theorem + @UC-INT-01 @build + Scenario: Every archive the client decodes is checked against its UORC-SHA256-CHAIN-v1 integrity trailer, so changing any single bit of an archive makes it fail to decode. + Given a program archive and a raw archive, each with every byte altered in its low and in its high bit + When uorc decompress reads each altered archive + Then every altered archive returns a decode failure and none yields output @UC-INT-02 @build Scenario: Format3/machine1 explicitly binds STREAM-MAX-v1 to charged image spans, preserves format2 CHAIN-v1 semantics, and seals input, basis and checkpoint identity domains without replacing exact reconstruction comparison. @@ -30,9 +30,3 @@ Feature: archive-integrity Given actual completed ordered views, continuous actual finish/publication transitions and source-derived profile progress and lifetime laws When the composed source theorem, all-declaration audits, exact source mutations and restored generated-model controls are replayed Then canonical digest equality and emitted-image reads follow without caller-supplied hash success or preservation flags; source-layout and full byte reconstruction claims require their own consumer proofs - - @UC-INT-06 @open - Scenario: Actual archive snapshot, selected preimage traversal and trailer comparison are connected to canonical original-source layout bytes through source-derived consumer calls, structural coverage and retained-node ownership premises. - Given the exact compatible Core and Wire source, actual archive ownership and independently specified structural source layout - When the consumer bridge derives source-selected reader coverage and actual snapshot, retain/feed, trailer comparison and EOF transitions - Then only canonical digest equality for the actual retained preimage and exactly32 stored trailer bytes can establish main archive integrity; source lifetime and layout are not inferred from live roots or lengths diff --git a/features/suites/checkpoint-replay.feature b/features/suites/checkpoint-replay.feature deleted file mode 100644 index 7f1f9cf7..00000000 --- a/features/suites/checkpoint-replay.feature +++ /dev/null @@ -1,8 +0,0 @@ -# @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. -Feature: checkpoint-replay - - @UC-CHK-01 @open - Scenario: Imported checkpoints are untrusted replay requests, not authority for a queue, incumbent, coverage, source identity or resource receipt. - Given a saved checkpoint plus current full-byte source, basis, model and policy snapshots - When source-owned checkpoint validation compares actual data and reconstructs the admissible replay - Then mismatches fail or require fresh work; stale digests and serialized coverage cannot manufacture verification or a minimum certificate diff --git a/features/suites/complete-synthesis.feature b/features/suites/complete-synthesis.feature index 2ba8d07f..d7e9c8a9 100644 --- a/features/suites/complete-synthesis.feature +++ b/features/suites/complete-synthesis.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: complete-synthesis - @UC-SYN-01 @open - Scenario: Fair synthesis combines input-derived algebra, recurrence, residuals, dictionary, typed sharing and complete syntax enumeration without making heuristic proposals the admissible universe. - Given arbitrary input bytes, canonical input normalization, fair phase schedules and exact typed graph lowering - When the source scheduler advances proposals under explicit effort and each proposal passes independent archive validation - Then only fully charged executable candidates become incumbents; effort changes search progress rather than admissibility and transport partitions do not choose a different canonical search prefix + @UC-SYN-01 @build + Scenario: Program search under a step budget keeps a candidate only as a fully checked archive: more effort can change which archive wins, never whether the result decodes to the input. + Given an input and search budgets of 0, 10000 and 200000 steps + When uorc compress runs the search at each budget and each archive is decoded + Then every archive decodes to the exact input and a larger budget never yields a larger archive diff --git a/features/suites/conditional-basis.feature b/features/suites/conditional-basis.feature index 0addd5b2..c414cebe 100644 --- a/features/suites/conditional-basis.feature +++ b/features/suites/conditional-basis.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: conditional-basis - @UC-BAS-01 @open - Scenario: Conditional archives bind the actual supplied ordered basis using a source-owned length-delimited domain-separated identity, and execute against that admitted basis. - Given actual immutable basis roots, altered bytes, reordered roots and inserted empty objects - When basis admission derives its identity and conditional archive validation checks the stored identifier - Then identity is never accepted merely because a caller supplies a matching tag; reconstruction is relative to the actual supplied basis and cryptographic binding assumptions remain explicit + @UC-BAS-01 @build + Scenario: Conditional archives name the client's standard basis, the ulz and ncm decoder libraries, by its UORC-BASIS-V1 identity and decode only against that actual basis. + Given archives written at the default and best levels, and the same archives with their basis identity altered and resealed + When uorc inspects and decompresses them + Then the intact archives name the standard basis identity and decode to the input; an archive naming any other basis is a decode failure even though its header and seal are well formed diff --git a/features/suites/machine-resources.feature b/features/suites/machine-resources.feature index e7e3a36c..88739f5c 100644 --- a/features/suites/machine-resources.feature +++ b/features/suites/machine-resources.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: machine-resources - @UC-MACH-02 @open - Scenario: Execution accounts for logical work and runtime-owned bytes under the explicit uorc.logical-owned-bytes/1 profile, including aliases, metadata, closures, transient copies and cancellation; old diagnostic live-cell counts remain distinct from bytes and neither is a claim of physical CPU time or resident memory. - Given checked source runtime states, resource budgets, immutable backing identities and release cursors - When the checked machine takes one transition or ownership release step - Then attempts, decoder work, peak live ownership and failures preserve exact accounting; native addressability refusal is operational rather than a restriction of mathematical sequence meaning + @UC-MACH-02 @build + Scenario: Decoding is charged against an explicit decoder work budget, and exhausting the budget is a typed refusal with no partial output. + Given a program archive and decoder work budgets below and above its cost + When uorc decompress runs under each budget + Then the small budget returns a decode failure and no bytes, and the sufficient budget returns the exact original diff --git a/features/suites/machine-semantics.feature b/features/suites/machine-semantics.feature index e1bb3763..eb2eb5fa 100644 --- a/features/suites/machine-semantics.feature +++ b/features/suites/machine-semantics.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: machine-semantics - @UC-MACH-01 @open - Scenario: Every admitted graph has the source-defined meaning of all 39 wire operations, including eager typed failures, prior-block calls and observer-before-update Scan with its final updater. - Given typed admitted graphs and an independent mathematical reference semantics - When the source machine executes and its simulation obligations and distinguishing examples are checked - Then values and failures agree with the reference; unreachable code is still validated and no unsupported opcode or hidden literal shortcut is accepted + @UC-MACH-01 @build + Scenario: The client's reference-semantics evaluator decodes program archives, including search-found programs and the ulz kernel graph when the certified fast path declines, to their exact original bytes. + Given a 64-byte program archive found by the exported search and a ulz kernel archive whose padded payload the fast path declines + When uorc decompress evaluates each program graph by the reference semantics + Then the output equals the original bytes exactly diff --git a/features/suites/ordered-objects.feature b/features/suites/ordered-objects.feature index 27835ad5..d01e1950 100644 --- a/features/suites/ordered-objects.feature +++ b/features/suites/ordered-objects.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: ordered-objects - @UC-OBJ-01 @open - Scenario: Decoded output preserves the exact ordered object boundary vector, including zero objects and distinct zero-length objects. - Given ObjectSplit lengths with binary data, internal empty objects, partial input, excess bytes and empty transport chunks - When the demultiplexer consumes only demanded input and emits bounded byte spans until one-shot EOF - Then ordered bytes and empty boundaries are preserved; early EOF and trailing bytes fail; emitted pieces remain staged rather than implicitly published + @UC-OBJ-01 @build + Scenario: Archives of ordered objects preserve the exact object boundary vector, including zero objects and distinct zero-length objects. + Given object vectors with binary data, internal and repeated empty objects, zero objects, and archives truncated or extended by one byte + When uorc compresses each vector as one archive and decompresses its objects + Then the header records every object length, the decoded objects equal the originals in order with every empty boundary preserved, and truncated or extended archives fail diff --git a/features/suites/product-control.feature b/features/suites/product-control.feature deleted file mode 100644 index c4675791..00000000 --- a/features/suites/product-control.feature +++ /dev/null @@ -1,8 +0,0 @@ -# @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. -Feature: product-control - - @UC-CTL-01 @open - Scenario: Source-owned asynchronous product transitions preserve run, revision, ordered input and output ownership. - Given typed positive and negative control scenarios covering repeated edits, start, cancel, navigation, checkpoint, retry, publication and shutdown - When the generated control runtime executes every registered scenario and a planted stale-completion defect - Then obsolete completions have no publication effect; checked output is downloadable only under current ownership and cleanup is explicit diff --git a/features/suites/product-execution.feature b/features/suites/product-execution.feature deleted file mode 100644 index bd8e33c6..00000000 --- a/features/suites/product-execution.feature +++ /dev/null @@ -1,8 +0,0 @@ -# @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. -Feature: product-execution - - @UC-EXE-01 @open - Scenario: Product operation binding moves the actual admitted runtime owner, decoded ticket and resulting effects without inventing successful evidence. - Given typed runtime-engine, producer/admission, semantic ReadyTransfer and noArena IO exchange, a charged immutable ordered-target descriptor, range-aware fresh decoded comparison, actual framing-to-inspection reports and resource-pause/cancellation/terminal-handoff scenarios - When the generated product execution owner drives concrete source roots and rejects planted stale, lost-ticket, target-alias, changed-boundary, truncated-range, duplicate-transfer, semantic-ledger-reset, inspection-as-execution, unpaid-getter or uncharged-initialization defects - Then one actual arena and every outside root ticket remain inventoried with accepted semantic budget/ledger; target equality requires every ordered length, actual byte and scoped EOF, while failed or cancelled cleanup retains achieved usage and receipts and engine completion alone cannot establish verified archive success diff --git a/features/suites/product-interfaces.feature b/features/suites/product-interfaces.feature index 5bc47339..ecdedcdb 100644 --- a/features/suites/product-interfaces.feature +++ b/features/suites/product-interfaces.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: product-interfaces - @UC-API-01 @open - Scenario: The same product semantics serve native library, CLI and browser interfaces, with explicitly versioned streaming ownership rather than invented compatibility with bounded whole-buffer adapters. - Given binary input including NUL and invalid UTF-8, large streams, resource handles and repeated browser actions - When the generated native and Wasm interfaces execute compress, decompress, inspect, verify, resume, basis, frontier and comparison operations - Then arbitrary byte input has no media or UI-sized format gate; modeled errors, generated computation failures, resource refusal and fatal host outcomes remain distinct + @UC-API-01 @build + Scenario: The uorc library, CLI and WebAssembly exports run the same compress, decompress, inspect and verify operations over arbitrary bytes, with typed budget, overflow, decode and mismatch failures. + Given binary input including NUL and invalid UTF-8, passed in memory and on stdin, and an original altered in one bit + When the library, the uorc binary and the Wasm exports compress, decompress, inspect and verify it + Then all three produce the same archive, the exact original bytes and the same header description; a non-archive is a decode failure and an altered original is a mismatch diff --git a/features/suites/product-lifecycle.feature b/features/suites/product-lifecycle.feature deleted file mode 100644 index d50eb85e..00000000 --- a/features/suites/product-lifecycle.feature +++ /dev/null @@ -1,8 +0,0 @@ -# @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. -Feature: product-lifecycle - - @UC-PROD-01 @open - Scenario: The source-owned product lifecycle handles demand, EOF, cancellation, edits, retries, stale completion and publication without exposing unfinished results as completed files. - Given live sessions, staged outputs, delayed responses, failures after output and host publication outcomes - When the controller applies the actual operation result and records the adapter outcome - Then only the current verified result may publish; cancellation cleans owned resources, late responses do not replace new input, and partial or unknown publication is reported honestly diff --git a/features/suites/product-storage.feature b/features/suites/product-storage.feature deleted file mode 100644 index 67991fb9..00000000 --- a/features/suites/product-storage.feature +++ /dev/null @@ -1,8 +0,0 @@ -# @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. -Feature: product-storage - - @UC-STG-01 @open - Scenario: Storage admission and observed job-owned storage remain separate from logical arena memory and physical observations. - Given typed storage reservations, achieved partial writes, bounded immutable input/output leases, prepaid image admission/extraction, frozen accounting work prefixes, scoped I/O totals and actual release/publication receipts under explicit requested quotas - When the generated storage, payload-image and output reporting owners execute quota/refusal, retained-prefix resume, cancellation, attachment identity, partial failed writes, stale settlement, unknown publication, cleanup and one-time transfer controls and reject planted defects - Then reserved and achieved storage remain separate from logical arena memory; input/output materialization is prepaid and bounded, failure retains achieved owners and actual publication, and settlement alone cannot claim verified archive success diff --git a/features/suites/product-view.feature b/features/suites/product-view.feature deleted file mode 100644 index 7501e972..00000000 --- a/features/suites/product-view.feature +++ /dev/null @@ -1,8 +0,0 @@ -# @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. -Feature: product-view - - @UC-VIW-01 @open - Scenario: Source-owned presentation values govern labels, enabled actions, focus, accessibility and evidence claims. - Given source-owned presentation values, bound user actions and a closed typed application root for persistent state, effects, numeric edits, trusted callbacks, focus and retirement - When actual generated application and presentation controls run with repeated edits, stale actions, start/cancel, navigation, close and planted dispatch defects - Then checked results remain checked, scoped evidence carries its scope, transport size remains separate and no browser qualification is inferred from source controls diff --git a/features/suites/real-execution.feature b/features/suites/real-execution.feature index 2c7b5b7f..426c7b28 100644 --- a/features/suites/real-execution.feature +++ b/features/suites/real-execution.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: real-execution - @UC-REAL-01 @open - Scenario: A real nonliteral archive is independently parsed, executed and compared against every original byte before encoder publication. - Given generated production executables, structured and unstructured binary corpora, exact source/SDK identities and baseline commands - When compression produces the complete archive and an independent decode reconstructs all ordered objects - Then byte equality and archive sizes are recorded from actual execution; finite fixtures, source simulation, performance measurements and mathematical proofs remain separate evidence + @UC-REAL-01 @build + Scenario: Real archives that uorc compress writes for text, structured binary, noise and edge-case inputs are independently decoded and compared against every original byte. + Given the shipped client and empty, single-byte, text, structured binary, noise and invalid UTF-8 inputs + When uorc compress writes each archive and uorc decompress reconstructs it + Then every reconstruction equals its original byte for byte, and compressible text takes a program archive under a quarter of its size diff --git a/features/suites/scoped-optimality.feature b/features/suites/scoped-optimality.feature index 368fa370..f5626ce2 100644 --- a/features/suites/scoped-optimality.feature +++ b/features/suites/scoped-optimality.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: scoped-optimality - @UC-OPT-01 @open - Scenario: The product minimizes complete archive byte length and unsigned lexicographic order within an explicitly sealed wire, basis and decoder-resource scope. - Given a checked incumbent and the complete finite set of earlier canonical archives in the sealed scope - When the independent verifier replays every required predecessor or a proved equivalent canonical framing factorization - Then a minimum certificate is accepted only after complete coverage; interrupted or exhausted verification remains incomplete and no unrestricted global minimum is claimed + @UC-OPT-01 @build + Scenario: Compress returns the smallest of the archives it checked, which are the raw archive, the ulz archive, the ncm archive at the best level and any search candidate within the step budget; no minimum beyond that candidate set is claimed. + Given empty, single-byte, text, structured binary, noise and invalid UTF-8 inputs + When uorc compress chooses its archive + Then the archive is never larger than the raw archive of the same length, compressible text takes a strictly smaller archive, and the best level is never larger than the default diff --git a/features/suites/source-authority.feature b/features/suites/source-authority.feature index a5a41c5e..85e8d339 100644 --- a/features/suites/source-authority.feature +++ b/features/suites/source-authority.feature @@ -14,10 +14,10 @@ Feature: source-authority Then the marked evidence remains non-authoritative and the conflicting handwritten rule is rejected by the R1 source-authority gate @UC-PERF-01 @open - Scenario: measured public-corpus compression improvement, with exact target and scope; open until actually measured + Scenario: measured public-corpus compression: every release runs scripts/bench.mjs on the Canterbury and Silesia corpora against gzip, bzip2, xz, zstd and brotli and publishes archive sizes and times in the release notes and on the Pages site; open because the measurement sets no target Given the registered public-corpus performance claim - When the honesty gate reads its disposition before any sealed benchmark result has established the target - Then the claim remains open rather than becoming implementation evidence + When the honesty gate reads its disposition + Then the claim remains open with its measurements reported, rather than becoming implementation evidence @UC-REC-01 @open Scenario: externally accepted compression record; open unless the external authority actually accepts it diff --git a/features/suites/wire-format.feature b/features/suites/wire-format.feature index 85968cf1..f38de5b5 100644 --- a/features/suites/wire-format.feature +++ b/features/suites/wire-format.feature @@ -1,8 +1,8 @@ # @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. Feature: wire-format - @UC-WIRE-01 @open - Scenario: The source-declared unshipped archive and machine profile identities have canonical source-owned layouts, strict incremental parsing, exact body lengths and complete EOF checks, without asserting compatibility with an unavailable older draft. - Given self-contained and conditional raw/program archives, every opcode, malformed fields and all small transport partitions - When Frame and GraphEmit serialize and the independent FrameParse and GraphParse paths parse the bytes - Then accepted bytes have the specified canonical meaning; truncation, trailing bytes, non-shortest numbers, invalid graphs and unsupported identities reach typed failures + @UC-WIRE-01 @build + Scenario: The client decodes only complete UORC archives in their canonical layout, self-contained or over the standard basis: truncated archives, trailing bytes and unsupported format identities are typed decode failures. + Given a program archive and a coded archive over the standard basis, each truncated at several points, extended with trailing bytes, and with an altered format identity + When uorc decompress parses them + Then the intact archives decode and every altered one returns a decode failure diff --git a/model/ids.toml b/model/ids.toml index b73f3301..d788f810 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -19,7 +19,7 @@ statement = "Handwritten project prose cannot define a second UORC specification id = "UC-PERF-01" level = "open" suite = "source-authority" -statement = "measured public-corpus compression improvement, with exact target and scope; open until actually measured" +statement = "measured public-corpus compression: every release runs scripts/bench.mjs on the Canterbury and Silesia corpora against gzip, bzip2, xz, zstd and brotli and publishes archive sizes and times in the release notes and on the Pages site; open because the measurement sets no target" [[id]] id = "UC-REC-01" @@ -59,93 +59,63 @@ statement = "Shortest U64 ULEB128 encoding and strict decoding have source-owned [[id]] id = "UC-MACH-01" -level = "open" +level = "build" suite = "machine-semantics" -statement = "Every admitted graph has the source-defined meaning of all 39 wire operations, including eager typed failures, prior-block calls and observer-before-update Scan with its final updater." +statement = "The client's reference-semantics evaluator decodes program archives, including search-found programs and the ulz kernel graph when the certified fast path declines, to their exact original bytes." [[id]] id = "UC-MACH-02" -level = "open" +level = "build" suite = "machine-resources" -statement = "Execution accounts for logical work and runtime-owned bytes under the explicit uorc.logical-owned-bytes/1 profile, including aliases, metadata, closures, transient copies and cancellation; old diagnostic live-cell counts remain distinct from bytes and neither is a claim of physical CPU time or resident memory." +statement = "Decoding is charged against an explicit decoder work budget, and exhausting the budget is a typed refusal with no partial output." [[id]] id = "UC-WIRE-01" -level = "open" +level = "build" suite = "wire-format" -statement = "The source-declared unshipped archive and machine profile identities have canonical source-owned layouts, strict incremental parsing, exact body lengths and complete EOF checks, without asserting compatibility with an unavailable older draft." +statement = "The client decodes only complete UORC archives in their canonical layout, self-contained or over the standard basis: truncated archives, trailing bytes and unsupported format identities are typed decode failures." [[id]] id = "UC-OBJ-01" -level = "open" +level = "build" suite = "ordered-objects" -statement = "Decoded output preserves the exact ordered object boundary vector, including zero objects and distinct zero-length objects." +statement = "Archives of ordered objects preserve the exact object boundary vector, including zero objects and distinct zero-length objects." [[id]] id = "UC-INT-01" -level = "open" +level = "build" suite = "archive-integrity" -statement = "Archive and basis integrity use an explicitly identified bounded streaming construction with standard SHA-256 components; digest agreement never replaces exact byte comparison." +statement = "Every archive the client decodes is checked against its UORC-SHA256-CHAIN-v1 integrity trailer, so changing any single bit of an archive makes it fail to decode." [[id]] id = "UC-BAS-01" -level = "open" +level = "build" suite = "conditional-basis" -statement = "Conditional archives bind the actual supplied ordered basis using a source-owned length-delimited domain-separated identity, and execute against that admitted basis." +statement = "Conditional archives name the client's standard basis, the ulz and ncm decoder libraries, by its UORC-BASIS-V1 identity and decode only against that actual basis." [[id]] id = "UC-SYN-01" -level = "open" +level = "build" suite = "complete-synthesis" -statement = "Fair synthesis combines input-derived algebra, recurrence, residuals, dictionary, typed sharing and complete syntax enumeration without making heuristic proposals the admissible universe." +statement = "Program search under a step budget keeps a candidate only as a fully checked archive: more effort can change which archive wins, never whether the result decodes to the input." [[id]] id = "UC-OPT-01" -level = "open" +level = "build" suite = "scoped-optimality" -statement = "The product minimizes complete archive byte length and unsigned lexicographic order within an explicitly sealed wire, basis and decoder-resource scope." - -[[id]] -id = "UC-CHK-01" -level = "open" -suite = "checkpoint-replay" -statement = "Imported checkpoints are untrusted replay requests, not authority for a queue, incumbent, coverage, source identity or resource receipt." - -[[id]] -id = "UC-PROD-01" -level = "open" -suite = "product-lifecycle" -statement = "The source-owned product lifecycle handles demand, EOF, cancellation, edits, retries, stale completion and publication without exposing unfinished results as completed files." +statement = "Compress returns the smallest of the archives it checked, which are the raw archive, the ulz archive, the ncm archive at the best level and any search candidate within the step budget; no minimum beyond that candidate set is claimed." [[id]] id = "UC-API-01" -level = "open" +level = "build" suite = "product-interfaces" -statement = "The same product semantics serve native library, CLI and browser interfaces, with explicitly versioned streaming ownership rather than invented compatibility with bounded whole-buffer adapters." +statement = "The uorc library, CLI and WebAssembly exports run the same compress, decompress, inspect and verify operations over arbitrary bytes, with typed budget, overflow, decode and mismatch failures." [[id]] id = "UC-REAL-01" -level = "open" +level = "build" suite = "real-execution" -statement = "A real nonliteral archive is independently parsed, executed and compared against every original byte before encoder publication." - -[[id]] -id = "UC-CTL-01" -level = "open" -suite = "product-control" -statement = "Source-owned asynchronous product transitions preserve run, revision, ordered input and output ownership." - -[[id]] -id = "UC-VIW-01" -level = "open" -suite = "product-view" -statement = "Source-owned presentation values govern labels, enabled actions, focus, accessibility and evidence claims." - -[[id]] -id = "UC-STG-01" -level = "open" -suite = "product-storage" -statement = "Storage admission and observed job-owned storage remain separate from logical arena memory and physical observations." +statement = "Real archives that uorc compress writes for text, structured binary, noise and edge-case inputs are independently decoded and compared against every original byte." [[id]] id = "UC-SHA-01" @@ -183,12 +153,6 @@ level = "build" suite = "archive-integrity" statement = "Source-owned checker soundness and constructive finite backward reduction are kernel checked for actual canonical framed messages and shape-valid source-SHA-authenticated traces, without global hash injectivity or an assumed frame codec. The decoder-to-authenticated-trace bridge and full product acceptance remain distinct." -[[id]] -id = "UC-EXE-01" -level = "open" -suite = "product-execution" -statement = "Product operation binding moves the actual admitted runtime owner, decoded ticket and resulting effects without inventing successful evidence." - [[id]] id = "UC-INT-04" level = "build" @@ -200,9 +164,3 @@ id = "UC-INT-05" level = "build" suite = "archive-integrity" statement = "Source-owned completed-view and continuous publication proofs derive the actual chosen-profile digest and emitted-image reads, discharging canonical driver termination and OwnedHash control/cleanup lifetime for both explicit format identities and arbitrary finite source input. Initial source-layout correspondence and full product acceptance remain separate consumer obligations." - -[[id]] -id = "UC-INT-06" -level = "open" -suite = "archive-integrity" -statement = "Actual archive snapshot, selected preimage traversal and trailer comparison are connected to canonical original-source layout bytes through source-derived consumer calls, structural coverage and retained-node ownership premises." diff --git a/model/ledger.toml b/model/ledger.toml index c30412a2..4342a4c4 100644 --- a/model/ledger.toml +++ b/model/ledger.toml @@ -22,7 +22,7 @@ feature = "features/suites/source-authority.feature" [[claim]] id = "UC-PERF-01" level = "open" -statement = "measured public-corpus compression improvement, with exact target and scope; open until actually measured" +statement = "measured public-corpus compression: every release runs scripts/bench.mjs on the Canterbury and Silesia corpora against gzip, bzip2, xz, zstd and brotli and publishes archive sizes and times in the release notes and on the Pages site; open because the measurement sets no target" evidence_kind = "none" research_disposition = "not_measured" feature = "features/suites/source-authority.feature" @@ -77,124 +77,84 @@ feature = "features/suites/varint.feature" [[claim]] id = "UC-MACH-01" -level = "open" -statement = "Every admitted graph has the source-defined meaning of all 39 wire operations, including eager typed failures, prior-block calls and observer-before-update Scan with its final updater." -evidence_kind = "none" +level = "build" +statement = "The client's reference-semantics evaluator decodes program archives, including search-found programs and the ulz kernel graph when the certified fast path declines, to their exact original bytes." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/machine-semantics.feature" [[claim]] id = "UC-MACH-02" -level = "open" -statement = "Execution accounts for logical work and runtime-owned bytes under the explicit uorc.logical-owned-bytes/1 profile, including aliases, metadata, closures, transient copies and cancellation; old diagnostic live-cell counts remain distinct from bytes and neither is a claim of physical CPU time or resident memory." -evidence_kind = "none" +level = "build" +statement = "Decoding is charged against an explicit decoder work budget, and exhausting the budget is a typed refusal with no partial output." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/machine-resources.feature" [[claim]] id = "UC-WIRE-01" -level = "open" -statement = "The source-declared unshipped archive and machine profile identities have canonical source-owned layouts, strict incremental parsing, exact body lengths and complete EOF checks, without asserting compatibility with an unavailable older draft." -evidence_kind = "none" +level = "build" +statement = "The client decodes only complete UORC archives in their canonical layout, self-contained or over the standard basis: truncated archives, trailing bytes and unsupported format identities are typed decode failures." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/wire-format.feature" [[claim]] id = "UC-OBJ-01" -level = "open" -statement = "Decoded output preserves the exact ordered object boundary vector, including zero objects and distinct zero-length objects." -evidence_kind = "none" +level = "build" +statement = "Archives of ordered objects preserve the exact object boundary vector, including zero objects and distinct zero-length objects." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/ordered-objects.feature" [[claim]] id = "UC-INT-01" -level = "open" -statement = "Archive and basis integrity use an explicitly identified bounded streaming construction with standard SHA-256 components; digest agreement never replaces exact byte comparison." -evidence_kind = "none" +level = "build" +statement = "Every archive the client decodes is checked against its UORC-SHA256-CHAIN-v1 integrity trailer, so changing any single bit of an archive makes it fail to decode." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/archive-integrity.feature" [[claim]] id = "UC-BAS-01" -level = "open" -statement = "Conditional archives bind the actual supplied ordered basis using a source-owned length-delimited domain-separated identity, and execute against that admitted basis." -evidence_kind = "none" +level = "build" +statement = "Conditional archives name the client's standard basis, the ulz and ncm decoder libraries, by its UORC-BASIS-V1 identity and decode only against that actual basis." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/conditional-basis.feature" [[claim]] id = "UC-SYN-01" -level = "open" -statement = "Fair synthesis combines input-derived algebra, recurrence, residuals, dictionary, typed sharing and complete syntax enumeration without making heuristic proposals the admissible universe." -evidence_kind = "none" +level = "build" +statement = "Program search under a step budget keeps a candidate only as a fully checked archive: more effort can change which archive wins, never whether the result decodes to the input." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/complete-synthesis.feature" [[claim]] id = "UC-OPT-01" -level = "open" -statement = "The product minimizes complete archive byte length and unsigned lexicographic order within an explicitly sealed wire, basis and decoder-resource scope." -evidence_kind = "none" +level = "build" +statement = "Compress returns the smallest of the archives it checked, which are the raw archive, the ulz archive, the ncm archive at the best level and any search candidate within the step budget; no minimum beyond that candidate set is claimed." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/scoped-optimality.feature" -[[claim]] -id = "UC-CHK-01" -level = "open" -statement = "Imported checkpoints are untrusted replay requests, not authority for a queue, incumbent, coverage, source identity or resource receipt." -evidence_kind = "none" -research_disposition = "not_measured" -feature = "features/suites/checkpoint-replay.feature" - -[[claim]] -id = "UC-PROD-01" -level = "open" -statement = "The source-owned product lifecycle handles demand, EOF, cancellation, edits, retries, stale completion and publication without exposing unfinished results as completed files." -evidence_kind = "none" -research_disposition = "not_measured" -feature = "features/suites/product-lifecycle.feature" - [[claim]] id = "UC-API-01" -level = "open" -statement = "The same product semantics serve native library, CLI and browser interfaces, with explicitly versioned streaming ownership rather than invented compatibility with bounded whole-buffer adapters." -evidence_kind = "none" +level = "build" +statement = "The uorc library, CLI and WebAssembly exports run the same compress, decompress, inspect and verify operations over arbitrary bytes, with typed budget, overflow, decode and mismatch failures." +evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/product-interfaces.feature" [[claim]] id = "UC-REAL-01" -level = "open" -statement = "A real nonliteral archive is independently parsed, executed and compared against every original byte before encoder publication." -evidence_kind = "none" +level = "build" +statement = "Real archives that uorc compress writes for text, structured binary, noise and edge-case inputs are independently decoded and compared against every original byte." +evidence_kind = "fixture_result" research_disposition = "not_measured" feature = "features/suites/real-execution.feature" -[[claim]] -id = "UC-CTL-01" -level = "open" -statement = "Source-owned asynchronous product transitions preserve run, revision, ordered input and output ownership." -evidence_kind = "none" -research_disposition = "not_measured" -feature = "features/suites/product-control.feature" - -[[claim]] -id = "UC-VIW-01" -level = "open" -statement = "Source-owned presentation values govern labels, enabled actions, focus, accessibility and evidence claims." -evidence_kind = "none" -research_disposition = "not_measured" -feature = "features/suites/product-view.feature" - -[[claim]] -id = "UC-STG-01" -level = "open" -statement = "Storage admission and observed job-owned storage remain separate from logical arena memory and physical observations." -evidence_kind = "none" -research_disposition = "not_measured" -feature = "features/suites/product-storage.feature" - [[claim]] id = "UC-SHA-01" level = "build" @@ -245,14 +205,6 @@ evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/archive-integrity.feature" -[[claim]] -id = "UC-EXE-01" -level = "open" -statement = "Product operation binding moves the actual admitted runtime owner, decoded ticket and resulting effects without inventing successful evidence." -evidence_kind = "none" -research_disposition = "not_measured" -feature = "features/suites/product-execution.feature" - [[claim]] id = "UC-INT-04" level = "build" @@ -268,11 +220,3 @@ statement = "Source-owned completed-view and continuous publication proofs deriv evidence_kind = "build_evidence" research_disposition = "not_measured" feature = "features/suites/archive-integrity.feature" - -[[claim]] -id = "UC-INT-06" -level = "open" -statement = "Actual archive snapshot, selected preimage traversal and trailer comparison are connected to canonical original-source layout bytes through source-derived consumer calls, structural coverage and retained-node ownership premises." -evidence_kind = "none" -research_disposition = "not_measured" -feature = "features/suites/archive-integrity.feature" diff --git a/scripts/bench.mjs b/scripts/bench.mjs index 71859eb5..ba26fdae 100644 --- a/scripts/bench.mjs +++ b/scripts/bench.mjs @@ -1,19 +1,24 @@ -// Measure the uorc release binary against standard compressors on a corpus. +// Measure the uorc release binary against standard compressors on public corpora. // Measurement only: this records sizes, times and round-trip results; it sets // no target and makes no claim beyond the files, versions and budgets it lists. // -// node scripts/bench.mjs --uorc target/release/uorc --corpus --steps N --out +// node scripts/bench.mjs --uorc target/release/uorc --corpus [,...] --steps N --out +// +// Writes bench.json (every measurement), bench.md (release notes) and +// bench.html (the Pages benchmarks page). import fs from 'node:fs'; import path from 'node:path'; import crypto from 'node:crypto'; import {spawnSync} from 'node:child_process'; const args = Object.fromEntries(process.argv.slice(2).reduce((acc, a, i, all) => (a.startsWith('--') ? [...acc, [a.slice(2), all[i + 1]]] : acc), [])); +const fail = message => { console.error(message); process.exit(2); }; const uorc = path.resolve(args.uorc ?? 'target/release/uorc'); -const corpus = path.resolve(args.corpus ?? fail('--corpus is required')); +const corpora = (args.corpus ?? fail('--corpus is required')).split(',').map(d => path.resolve(d)); const steps = String(args.steps ?? 0); const out = path.resolve(args.out ?? 'bench-results'); -function fail(message) { console.error(message); process.exit(2); } +// A per-run wall-clock limit, so one pathological file cannot eat the job. +const limitMs = Number(args['timeout-s'] ?? 1800) * 1000; const baselines = [ {name: 'gzip -9', tool: 'gzip', compress: ['-9', '-c'], decompress: ['-d', '-c'], version: ['--version']}, @@ -25,63 +30,93 @@ const baselines = [ const sha = bytes => crypto.createHash('sha256').update(bytes).digest('hex'); const timed = (cmd, argv, input) => { const started = process.hrtime.bigint(); - const r = spawnSync(cmd, argv, {input, maxBuffer: 1 << 30}); + const r = spawnSync(cmd, argv, {input, maxBuffer: 2 ** 31, timeout: limitMs}); return {r, seconds: Number(process.hrtime.bigint() - started) / 1e9}; }; +const failure = r => (r.error ? String(r.error.code ?? r.error) : `exit ${r.status}: ${String(r.stderr ?? '').trim().slice(0, 200)}`); const firstLine = (cmd, argv) => { const r = spawnSync(cmd, argv, {encoding: 'utf8'}); return r.error ? null : `${r.stdout}${r.stderr}`.trim().split('\n')[0]; }; -const files = fs.readdirSync(corpus).filter(f => fs.statSync(path.join(corpus, f)).isFile()).sort(); -if (!files.length) fail(`no files in ${corpus}`); const tools = baselines.map(b => ({...b, available: firstLine(b.tool, b.version)})).filter(b => b.available); -const work = fs.mkdtempSync(path.join(out + '-work')); -const rows = []; -for (const file of files) { - const input = fs.readFileSync(path.join(corpus, file)); +// The default level, and --best (the ncm context-mixing level). +const levels = [[`uorc (${steps} steps)`, []], [`uorc --best (${steps} steps)`, ['--best']]]; +const names = [...levels.map(([label]) => label), ...tools.map(t => t.name)]; +fs.mkdirSync(out, {recursive: true}); +const work = fs.mkdtempSync(path.join(out, 'work-')); + +function measure(file, input) { const row = {file, bytes: input.length, sha256: sha(input), results: []}; - const src = path.join(work, 'in'); fs.writeFileSync(src, input); - for (const [label, extra] of [[`uorc (${steps} steps)`, []], [`uorc --best (${steps} steps)`, ['--best']]]) { - const c = timed(uorc, ['compress', ...extra, '--steps', steps, src, '-o', path.join(work, 'a.uorc')]); + const src = path.join(work, 'in'), arc = path.join(work, 'a.uorc'), back = path.join(work, 'back'); + fs.writeFileSync(src, input); + for (const [label, extra] of levels) { + const c = timed(uorc, ['compress', ...extra, '--steps', steps, src, '-o', arc]); if (c.r.status === 0) { - const archive = fs.readFileSync(path.join(work, 'a.uorc')); - const d = timed(uorc, ['decompress', path.join(work, 'a.uorc'), '-o', path.join(work, 'back')]); - const ok = d.r.status === 0 && Buffer.compare(fs.readFileSync(path.join(work, 'back')), input) === 0; - row.results.push({compressor: label, bytes: archive.length, compress_s: c.seconds, decompress_s: d.seconds, round_trip: ok}); - } else row.results.push({compressor: label, error: c.r.stderr.toString().trim()}); + const archive = fs.statSync(arc).size; + const d = timed(uorc, ['decompress', arc, '-o', back]); + const ok = d.r.status === 0 && Buffer.compare(fs.readFileSync(back), input) === 0; + row.results.push({compressor: label, bytes: archive, compress_s: c.seconds, decompress_s: d.seconds, round_trip: ok, ...(d.r.status === 0 ? {} : {error: failure(d.r)})}); + } else row.results.push({compressor: label, error: failure(c.r)}); + for (const f of [arc, back]) fs.rmSync(f, {force: true}); } + fs.rmSync(src, {force: true}); for (const t of tools) { const cz = timed(t.tool, t.compress, input); + if (cz.r.status !== 0) { row.results.push({compressor: t.name, error: failure(cz.r)}); continue; } const dz = timed(t.tool, t.decompress, cz.r.stdout); row.results.push({compressor: t.name, bytes: cz.r.stdout.length, compress_s: cz.seconds, decompress_s: dz.seconds, round_trip: dz.r.status === 0 && Buffer.compare(dz.r.stdout, input) === 0}); } - rows.push(row); console.log(file, row.results.map(r => `${r.compressor}=${r.bytes ?? 'error'}`).join(' ')); + return row; } + +const suites = corpora.map(dir => { + const files = fs.readdirSync(dir).filter(f => fs.statSync(path.join(dir, f)).isFile()).sort(); + if (!files.length) fail(`no files in ${dir}`); + return {corpus: path.basename(dir), files: files.map(f => measure(f, fs.readFileSync(path.join(dir, f))))}; +}); fs.rmSync(work, {recursive: true, force: true}); +// Per corpus and compressor: total archive bytes and throughput over the files +// every compressor round-tripped, so a failure never flatters a total. +const summarize = suite => names.map(n => { + const done = suite.files.map(r => r.results.find(x => x.compressor === n)).filter(x => x?.round_trip); + const input = suite.files.filter(r => r.results.find(x => x.compressor === n)?.round_trip).reduce((s, r) => s + r.bytes, 0); + const sum = k => done.reduce((s, x) => s + x[k], 0); + return {compressor: n, files: done.length, input_bytes: input, archive_bytes: sum('bytes'), + ratio: input ? input / sum('bytes') : null, compress_mb_s: input / 1e6 / sum('compress_s') || null, decompress_mb_s: input / 1e6 / sum('decompress_s') || null}; +}); +for (const s of suites) s.summary = summarize(s); + const report = { - spec: 'uorc/benchmark/1', kind: 'measurement', target: 'none', - uorc: firstLine(uorc, ['--version']), steps: Number(steps), + spec: 'uorc/benchmark/2', kind: 'measurement', target: 'none', + uorc: firstLine(uorc, ['--version']), steps: Number(steps), timeout_s: limitMs / 1000, host: {platform: process.platform, arch: process.arch}, tools: tools.map(t => ({name: t.name, version: t.available})), - corpus: path.basename(corpus), files: rows, + corpora: suites, }; -fs.mkdirSync(out, {recursive: true}); fs.writeFileSync(path.join(out, 'bench.json'), JSON.stringify(report, null, 1) + '\n'); -const names = rows[0].results.map(r => r.compressor); -const total = n => rows.reduce((s, r) => s + (r.results.find(x => x.compressor === n)?.bytes ?? 0), 0); -const input = rows.reduce((s, r) => s + r.bytes, 0); +const fixed = (x, d) => (x == null ? 'n/a' : x.toFixed(d)); +const cell = r => (r.bytes === undefined ? 'error' : `${r.bytes}${r.round_trip ? '' : ' ✗'}`); const esc = s => String(s).replace(/[&<>]/g, c => ({'&': '&', '<': '<', '>': '>'}[c])); -const cell = r => r.bytes === undefined ? 'error' : `${r.bytes}${r.round_trip ? '' : ' ✗'}`; -const md = [`# uorc benchmark: ${report.corpus}`, '', `${report.uorc}, ${report.steps} search steps per file, ${report.host.platform}/${report.host.arch}. Measurement only; no target is set.`, '', - `| file | bytes | ${names.join(' | ')} |`, `| --- | ---: | ${names.map(() => '---:').join(' | ')} |`, - ...rows.map(r => `| ${r.file} | ${r.bytes} | ${r.results.map(cell).join(' | ')} |`), - `| **total** | **${input}** | ${names.map(n => `**${total(n)}**`).join(' | ')} |`, '', - 'Archive sizes in bytes; ✗ marks a failed round trip. Tool versions:', '', ...report.tools.map(t => `- ${t.name}: ${t.version}`), ''].join('\n'); -fs.writeFileSync(path.join(out, 'bench.md'), md); -const table = `${names.map(n => ``).join('')}${ - rows.map(r => `${r.results.map(x => ``).join('')}`).join('') -}${names.map(n => ``).join('')}
FileBytes${esc(n)}
${esc(r.file)}${r.bytes}${esc(cell(x))}
Total${input}${total(n)}
`; -const html = `uorc benchmarks

Benchmarks

${esc(report.uorc)}, ${report.steps} search steps per file on ${esc(report.host.platform)}/${esc(report.host.arch)}. Measurement only: no target is set. Archive sizes are in bytes; ✗ marks a failed round trip. Raw data: bench.json. Back to the client.

${esc(report.corpus)}

${table}

Tools

    ${report.tools.map(t => `
  • ${esc(t.name)}: ${esc(t.version)}
  • `).join('')}
\n`; +const intro = `${report.uorc}, ${report.steps} search steps per file, ${report.host.platform}/${report.host.arch}. Measurement only; no target is set.`; +const summaryHead = ['compressor', 'files', 'archive bytes', 'ratio', 'compress MB/s', 'decompress MB/s']; +const summaryRow = s => [s.compressor, s.files, s.archive_bytes, fixed(s.ratio, 3), fixed(s.compress_mb_s, 2), fixed(s.decompress_mb_s, 2)]; + +const md = [`# uorc benchmarks`, '', intro, '']; +for (const s of suites) { + md.push(`## ${s.corpus}`, '', `| ${summaryHead.join(' | ')} |`, `| --- | ${summaryHead.slice(1).map(() => '---:').join(' | ')} |`, + ...s.summary.map(x => `| ${summaryRow(x).join(' | ')} |`), '', + '
Per file (archive bytes)', '', + `| file | bytes | ${names.join(' | ')} |`, `| --- | ---: | ${names.map(() => '---:').join(' | ')} |`, + ...s.files.map(r => `| ${r.file} | ${r.bytes} | ${r.results.map(cell).join(' | ')} |`), '', '
', ''); +} +md.push('Ratio is input bytes over archive bytes, and throughput is input MB per second, both over the files that compressor round-tripped. ✗ marks a failed round trip. Tool versions:', '', ...report.tools.map(t => `- ${t.name}: ${t.version}`), ''); +fs.writeFileSync(path.join(out, 'bench.md'), md.join('\n')); + +const htmlTable = (head, rows) => `
${head.map(h => ``).join('')}${ + rows.map(r => `${r.map(c => ``).join('')}`).join('')}
${esc(h)}
${esc(c)}
`; +const sections = suites.map(s => `

${esc(s.corpus)}

${htmlTable(summaryHead, s.summary.map(summaryRow))}
Per file (archive bytes)${ + htmlTable(['file', 'bytes', ...names], s.files.map(r => [r.file, r.bytes, ...r.results.map(cell)]))}
`).join(''); +const html = `uorc benchmarks

Benchmarks

${esc(intro)} Ratio is input over archive bytes and throughput is input MB per second, over the files each compressor round-tripped; ✗ marks a failed round trip. Raw data: bench.json. Back to the client.

${sections}

Tools

    ${report.tools.map(t => `
  • ${esc(t.name)}: ${esc(t.version)}
  • `).join('')}
\n`; fs.writeFileSync(path.join(out, 'bench.html'), html); console.log(`wrote ${out}/bench.{json,md,html}`); diff --git a/scripts/product-application-runtime.mjs b/scripts/product-application-runtime.mjs deleted file mode 100644 index 56c82417..00000000 --- a/scripts/product-application-runtime.mjs +++ /dev/null @@ -1,9 +0,0 @@ -// Execute this source-owned typed suite; no product implementation lives here. -import {validate} from './product-machine-runtime.mjs'; -try { - if (process.argv.length !== 2) throw new Error('no arguments accepted'); - validate(process.cwd(), undefined, 'ApplicationScenarios'); -} catch (error) { - console.error(error.message); - process.exitCode = 1; -} diff --git a/scripts/product-control-validation.py b/scripts/product-control-validation.py deleted file mode 100644 index bad878e7..00000000 --- a/scripts/product-control-validation.py +++ /dev/null @@ -1,289 +0,0 @@ -#!/usr/bin/env python3 -"""Execute the source-owned product controls; this is a component diagnostic, not vv.""" -import argparse -import hashlib -import json -import os -from pathlib import Path -import re -import shutil -import subprocess -import tempfile - -ROOT = Path(__file__).resolve().parents[1] -MODULES = ('Session', 'Evidence', 'StreamProtocol', 'Api', 'InputModel', - 'Control', 'Workspace', 'Presentation', 'Scenarios', 'Storage', - 'ResourceIO', 'Selection', 'HostContract') -HARNESS = '''import Uorc.Uorc.Product.Scenarios -open Uorc.Uorc.Product - -def main : IO Unit := do - let mut failures : Nat := 0 - let mut total : Nat := 0 - for c in Scenarios.cases do - total := total + 1 - if !(Scenarios.runCase c) then - failures := failures + 1 - IO.println s!"FAIL {c.id}" - for o in Scenarios.observations do - total := total + 1 - if !o.passed then - failures := failures + 1 - IO.println s!"FAIL {o.id}" - IO.println s!"{total - failures}/{total} product control and presentation scenarios passed" - if total == 0 then throw (IO.userError "empty scenario inventory") - if failures != 0 then throw (IO.userError "product scenarios failed") -''' - - -def sha(data): - return hashlib.sha256(data).hexdigest() - - -def xtask(task, text): - """LexLean SPEC 17.21.1: 1.2 sources are notation; convert only via the SDK.""" - subprocess.run(['cargo', 'build', '--locked', '-q', '-p', 'xtask'], cwd=ROOT, check=True) - target = Path(os.environ.get('CARGO_TARGET_DIR', ROOT / 'target')) - return subprocess.run([str(target / 'debug/xtask'), task], input=text, capture_output=True, - text=True, check=True).stdout - - -def read_module(path): - text = xtask('data-form', path.read_text()) - return text, json.loads(re.search(r'\\semanticdata\{(.*)\}', text).group(1)) - - -def write_module(path, text, data): - path.write_text(xtask('notation', re.sub(r'\\semanticdata\{.*\}', lambda _: '\\semanticdata{' + - json.dumps(data, sort_keys=True, separators=(',', ':')) + '}', text))) - - -def stage_runtime(directory, lean, env): - """Elaborate the pinned LexLean runtime that 1.2 generated modules import.""" - target = Path(os.environ.get('CARGO_TARGET_DIR', ROOT / 'target')) - subprocess.run(['cargo', 'build', '--locked', '-q', '-p', 'xtask'], cwd=ROOT, check=True) - names = subprocess.run([str(target / 'debug/xtask'), 'runtime-sources', str(directory)], - capture_output=True, text=True, check=True).stdout.split() - if 'LexLeanRuntime.Portable' not in names: - raise RuntimeError('LexLean runtime inventory is incomplete') - for name in names: - base = directory.joinpath(*name.split('.')) - run([lean, '-R', directory, '-o', base.with_suffix('.olean'), base.with_suffix('.lean')], - directory, env) - - -def run(args, cwd, env=None, expected=0): - result = subprocess.run([str(a) for a in args], cwd=cwd, env=env, - capture_output=True, text=True) - if expected is not None and result.returncode != expected: - raise RuntimeError(result.stdout + result.stderr) - return result - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('--lexlean', default='lexlean') - parser.add_argument('--lean', default='lean') - parser.add_argument('--diagnostic-compatibility', action='store_true', - help='In the temporary language-1.1 projection only, omit existing ' - 'executable metadata rejected by the newer compiler. No terms change.') - parser.add_argument('--output', type=Path, default=ROOT / 'validation/product/evidence.json') - args = parser.parse_args() - compiler = shutil.which(args.lexlean) or args.lexlean - lean = shutil.which(args.lean) or args.lean - run(['python3', ROOT / 'scripts/product-host-projection.py'], ROOT) - probe_source = (ROOT / 'tests/product-control/user-notice-forgery.lex.tex').read_bytes() - sources = {name: (ROOT / f'src/Uorc/Product/{name}.lex.tex').read_bytes() - for name in MODULES} - evidence = { - 'schema': 'uorc/product-control-diagnostic/1', - 'scope': 'Source linking, kernel verification, exact axiom audit and generated Lean VM ' - 'execution of the component model and its planted defects. Synthetic Report ' - 'fixtures do not establish archive, native-library, browser or release acceptance.', - 'pinned_sdk_acceptance': False, - 'compiler': run([compiler, '--version'], ROOT).stdout.strip(), - 'lean': run([lean, '--version'], ROOT).stdout.strip(), - 'source_sha256': {name: sha(data) for name, data in sources.items()}, - 'diagnostic_annotation_omissions': [], - 'mutations': [], - 'boundary_negatives': [], - 'gate_sha256': sha(Path(__file__).read_bytes()), - 'harness_sha256': sha(HARNESS.encode()), - 'boundary_probe_sha256': sha(probe_source), - 'host_projection_sha256': sha((ROOT / 'validation/product/host-contract.json').read_bytes()), - 'host_projection_gate_sha256': sha((ROOT / 'scripts/product-host-projection.py').read_bytes()), - } - with tempfile.TemporaryDirectory(prefix='uorc-product-') as temp: - project = Path(temp) - src = project / 'src/Uorc/Product' - src.mkdir(parents=True) - for name, data in sources.items(): - p = src / f'{name}.lex.tex' - p.write_bytes(data) - if args.diagnostic_compatibility: - text, module = read_module(p) - for declaration in module['declarations']: - if declaration.pop('executable', None) is not None: - evidence['diagnostic_annotation_omissions'].append(name + '.' + declaration['name']) - write_module(p, text, module) - config = (ROOT / 'lexlean.toml').read_text().replace('uorc-authority', 'product-control-diagnostic') - config = re.sub(r'entrypoints = .*', 'entrypoints = ["src/Uorc/Product/Scenarios.lex.tex"]', config) - (project / 'lexlean.toml').write_text(config) - for name in ('lakefile.toml', 'lean-toolchain'): - shutil.copyfile(ROOT / name, project / name) - # Initialize Lake's own manifest before the compiler binds the workspace files. - lake = Path(lean).with_name('lake') - if lake.is_file(): - run([lake, 'update'], project) - run([compiler, 'lock'], project) - originals = {name: (src / f'{name}.lex.tex').read_bytes() for name in MODULES} - - def verify(expected_owner=None): - result = run([compiler, 'verify', '--all'], project, expected=None) - message = result.stdout + result.stderr - if expected_owner: - if result.returncode == 0: - raise RuntimeError('Planted defect was accepted: ' + message) - built = json.loads(run([compiler, '--diagnostic-format', 'json', 'build', '--all'], project).stdout) - location = re.search(r'generated location: .*?/lean-src/(.*?\.lean):(\d+):', message) - if not location: - raise RuntimeError('No generated failing declaration location: ' + message) - generated = project / '.lexlean/build' / built['build_id'] / 'modules' / location.group(1) - lines = generated.read_text().splitlines()[:int(location.group(2))] - owners = [re.match(r'public theorem (\w+)', line).group(1) - for line in lines if re.match(r'public theorem (\w+)', line)] - if not owners or owners[-1] != expected_owner: - raise RuntimeError('Planted defect failed at another declaration: ' + message) - return {'exit': result.returncode, 'owner': owners[-1], 'diagnostic': 'LLV7002'} - if result.returncode: - raise RuntimeError(message) - match = re.search(r'attestation ([a-f0-9]{64})', message) - if not match: - raise RuntimeError('No complete verification attestation: ' + message) - path = project / '.lexlean/verified' / match.group(1) / 'attestation.json' - attestation = json.loads(path.read_text()) - if any(d['result'] != 'ok' for d in attestation['declarations']): - raise RuntimeError('An audited declaration did not pass') - return attestation - - def execute(attestation, expected_failure=None): - generated = project / '.lexlean/build' / attestation['build_id'] / 'modules' - runtime = project / ('runtime-' + attestation['attestation_id']) - runtime.mkdir() - env = dict(os.environ, LEAN_PATH=str(runtime)) - stage_runtime(runtime, lean, env) - files = list(generated.rglob('*.lean')) - completed = set() - while files: - ready = next((p for p in files if set(re.findall(r'public import (Uorc\.[\w.]+)', - p.read_text())) <= completed), None) - if ready is None: - raise RuntimeError('Generated dependency closure is incomplete') - relative = ready.relative_to(generated) - target = (runtime / relative).with_suffix('.olean') - target.parent.mkdir(parents=True, exist_ok=True) - run([lean, '-R', generated, '-o', target, ready], project, env) - completed.add('.'.join(relative.with_suffix('').parts)) - files.remove(ready) - harness = project / 'RunProductControls.lean' - harness.write_text(HARNESS) - result = run([lean, '--run', harness], project, env, expected=None) - message = result.stdout + result.stderr - if expected_failure: - if result.returncode == 0 or ('FAIL ' + expected_failure) not in message: - raise RuntimeError('Runtime mutation did not fail at its owner: ' + message) - elif result.returncode: - raise RuntimeError(message) - return {'exit': result.returncode, 'transcript': message.strip()} - - probe = src / 'UserNoticeForgery.lex.tex' - probe.write_bytes(probe_source) - rejected = run([compiler, 'check', '--all'], project, expected=None) - diagnostic = rejected.stdout + rejected.stderr - if rejected.returncode == 0 or 'LLT4001' not in diagnostic or 'UserNoticeForgery' not in diagnostic: - raise RuntimeError('User intent admitted a forged runtime report: ' + diagnostic) - probe.unlink() - evidence['boundary_negatives'].append({'id': 'user-notice-forgery', - 'exit': rejected.returncode, 'diagnostic': 'LLT4001'}) - print('forged runtime report rejected at the user-intent type boundary', flush=True) - before = verify() - evidence['restored_control'] = execute(before) - print(evidence['restored_control']['transcript'], flush=True) - path = src / 'Control.lex.tex' - text, module = read_module(path) - declaration = next(d for d in module['declarations'] if d['name'] == 'completed') - declaration['body']['arguments'][-1] = {'kind': 'bool', 'value': True} - write_module(path, text, module) - evidence['mutations'].append({'id': 'stale-guard-bypass', - 'verification': verify('completion_guard_binding')}) - path.write_bytes(originals['Control']) - print('stale-guard-bypass rejected at completion_guard_binding', flush=True) - path = src / 'Api.lex.tex' - text, module = read_module(path) - declaration = next(d for d in module['declarations'] if d['name'] == 'evidenceView') - declaration['body']['arguments'][1] = {'kind': 'bool', 'value': True} - write_module(path, text, module) - mutated = verify() - evidence['mutations'].append({'id': 'invented-original-availability', - 'runtime': execute(mutated, 'decompression-does-not-claim-equality')}) - path.write_bytes(originals['Api']) - print('invented-original-availability rejected by generated runtime observation', flush=True) - path = src / 'Storage.lex.tex' - text, module = read_module(path) - declaration = next(d for d in module['declarations'] if d['name'] == 'fits') - declaration['body'] = {'kind': 'bool', 'value': True} - write_module(path, text, module) - mutated = verify() - evidence['mutations'].append({'id': 'storage-quota-bypass', - 'runtime': execute(mutated, 'storage-admission-achieved-failure-transfer')}) - path.write_bytes(originals['Storage']) - print('storage-quota-bypass rejected by storage runtime owner', flush=True) - path = src / 'ResourceIO.lex.tex' - text, module = read_module(path) - declaration = next(d for d in module['declarations'] if d['name'] == 'cancelledWriteAccepted') - declaration['body'] = declaration['body']['branches'][1]['body'] - write_module(path, text, module) - mutated = verify() - evidence['mutations'].append({'id': 'cancellation-before-write-ack', - 'runtime': execute(mutated, 'double-cancel-waits-for-achieved-write')}) - path.write_bytes(originals['ResourceIO']) - print('cancellation-before-write-ack rejected by bounded I/O runtime owner', flush=True) - path = src / 'ResourceIO.lex.tex' - text, module = read_module(path) - declaration = next(d for d in module['declarations'] if d['name'] == 'cleanupPreparation') - declaration['body'] = declaration['body']['then_value'] - write_module(path, text, module) - mutated = verify() - evidence['mutations'].append({'id': 'delete-spool-before-read-receipt', - 'runtime': execute(mutated, 'cancelled-read-blocks-spool-deletion')}) - path.write_bytes(originals['ResourceIO']) - print('delete-spool-before-read-receipt rejected by the read custody owner', flush=True) - if any((src / f'{name}.lex.tex').read_bytes() != data for name, data in originals.items()): - raise RuntimeError('A planted defect was not restored byte-for-byte') - restored = verify() - # A clean compilation directory prevents retained VM artifacts from satisfying the restored run. - shutil.rmtree(project / ('runtime-' + restored['attestation_id']), ignore_errors=True) - evidence['restored_control'] = execute(restored) - evidence['attestation_id'] = restored['attestation_id'] - evidence['build_id'] = restored['build_id'] - evidence['audited_declarations'] = len(restored['declarations']) - evidence['observed_axioms'] = sorted({a for d in restored['declarations'] for a in d['observed']}) - evidence['project_source_id'] = restored['source_id'] - evidence['semantic_id'] = restored['semantic_id'] - evidence['restored_byte_for_byte'] = True - counts = re.search(r'(\d+)/(\d+) product control', evidence['restored_control']['transcript']) - if not counts or int(counts[1]) != int(counts[2]) or int(counts[2]) == 0: - raise RuntimeError('Incomplete runtime inventory') - evidence['runtime_passed'] = int(counts[1]) - evidence['runtime_total'] = int(counts[2]) - if any((ROOT / f'src/Uorc/Product/{name}.lex.tex').read_bytes() != data - for name, data in sources.items()): - raise RuntimeError('Repository source changed during the diagnostic') - args.output.parent.mkdir(parents=True, exist_ok=True) - args.output.write_text(json.dumps(evidence, indent=2, sort_keys=True) + '\n') - print(evidence['restored_control']['transcript'], flush=True) - print('Evidence written; pinned-SDK, native and browser qualification remain separate.', flush=True) - - -if __name__ == '__main__': - main() diff --git a/scripts/product-host-projection.py b/scripts/product-host-projection.py deleted file mode 100644 index 5999c563..00000000 --- a/scripts/product-host-projection.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python3 -"""Project the literal source-owned generic adapter contract; no product behavior.""" -import argparse -import json -import subprocess -from pathlib import Path -import re - -ROOT = Path(__file__).resolve().parents[1] - - -def literal(term): - kind = term['kind'] - if kind in ('string', 'bool'): - return term['value'] - if kind == 'nat': - return int(term['value']) - if kind == 'record': - return {field['field']: literal(field['value']) for field in term['fields']} - if kind == 'nil': - return [] - if kind == 'cons': - return [literal(term['head'])] + literal(term['tail']) - raise ValueError('The contract projection requires an actual source literal: ' + kind) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('--write', action='store_true') - args = parser.parse_args() - source = subprocess.run(['cargo', 'run', '--locked', '-q', '-p', 'xtask', '--', 'data-form'], - cwd=ROOT, input=(ROOT / 'src/Uorc/Product/HostContract.lex.tex').read_text(), - capture_output=True, text=True, check=True).stdout - module = json.loads(re.search(r'\\semanticdata\{(.*)\}', source).group(1)) - declaration = next(d for d in module['declarations'] if d['name'] == 'contract') - projected = literal(declaration['body']) - # Flatten only the source-owned metadata groups; no product behavior is evaluated here. - if 'endpointGroups' in projected: - projected['endpoints'] = [endpoint for group in projected['endpointGroups'] - for endpoint in group['endpoints']] - expected = json.dumps(projected, sort_keys=True, indent=2) + '\n' - target = ROOT / 'validation/product/host-contract.json' - if args.write: - target.parent.mkdir(parents=True, exist_ok=True) - target.write_text(expected) - elif target.read_text() != expected: - raise SystemExit('Stale generic adapter projection; run scripts/product-host-projection.py --write') - print('generic adapter contract projection matches its source') - - -if __name__ == '__main__': - main() diff --git a/scripts/product-image-runtime.mjs b/scripts/product-image-runtime.mjs deleted file mode 100644 index 9c669b05..00000000 --- a/scripts/product-image-runtime.mjs +++ /dev/null @@ -1,9 +0,0 @@ -// Source-owned payload admission controls use the same generated-model gate. -import {validate} from './product-machine-runtime.mjs'; -try { - if (process.argv.length !== 2) throw new Error('no arguments accepted'); - validate(process.cwd(), undefined, 'ReadImageScenarios'); -} catch (error) { - console.error(error.message); - process.exitCode = 1; -} diff --git a/scripts/product-inspection-runtime.mjs b/scripts/product-inspection-runtime.mjs deleted file mode 100644 index 57f59a4f..00000000 --- a/scripts/product-inspection-runtime.mjs +++ /dev/null @@ -1,9 +0,0 @@ -// Execute the actual owned framing-to-inspection source binding and its defects. -import {validate} from './product-machine-runtime.mjs'; -try { - if (process.argv.length !== 2) throw new Error('no arguments accepted'); - validate(process.cwd(), undefined, 'InspectionReportScenarios'); -} catch (error) { - console.error(error.message); - process.exitCode = 1; -} diff --git a/scripts/product-output-delivery-runtime.mjs b/scripts/product-output-delivery-runtime.mjs deleted file mode 100644 index b81729ea..00000000 --- a/scripts/product-output-delivery-runtime.mjs +++ /dev/null @@ -1,9 +0,0 @@ -// Execute this actual source-owned runtime and its owning planted defects. -import {validate} from './product-machine-runtime.mjs'; -try { - if (process.argv.length !== 2) throw new Error('no arguments accepted'); - validate(process.cwd(), undefined, 'OutputDeliveryScenarios'); -} catch (error) { - console.error(error.message); - process.exitCode = 1; -} diff --git a/scripts/product-read-controller-runtime.mjs b/scripts/product-read-controller-runtime.mjs deleted file mode 100644 index 3103b4e6..00000000 --- a/scripts/product-read-controller-runtime.mjs +++ /dev/null @@ -1,9 +0,0 @@ -// Execute this actual source-owned runtime and its owning planted defects. -import {validate} from './product-machine-runtime.mjs'; -try { - if (process.argv.length !== 2) throw new Error('no arguments accepted'); - validate(process.cwd(), undefined, 'ReadControllerScenarios'); -} catch (error) { - console.error(error.message); - process.exitCode = 1; -} diff --git a/scripts/product-target-descriptor-runtime.mjs b/scripts/product-target-descriptor-runtime.mjs deleted file mode 100644 index 60164c70..00000000 --- a/scripts/product-target-descriptor-runtime.mjs +++ /dev/null @@ -1,9 +0,0 @@ -// Execute this source-owned typed suite; no product implementation lives here. -import {validate} from './product-machine-runtime.mjs'; -try { - if (process.argv.length !== 2) throw new Error('no arguments accepted'); - validate(process.cwd(), undefined, 'TargetDescriptorScenarios'); -} catch (error) { - console.error(error.message); - process.exitCode = 1; -} diff --git a/scripts/product-write-image-runtime.mjs b/scripts/product-write-image-runtime.mjs deleted file mode 100644 index c3d6f763..00000000 --- a/scripts/product-write-image-runtime.mjs +++ /dev/null @@ -1,9 +0,0 @@ -// Execute this source-owned typed suite; no product implementation lives here. -import {validate} from './product-machine-runtime.mjs'; -try { - if (process.argv.length !== 2) throw new Error('no arguments accepted'); - validate(process.cwd(), undefined, 'WriteImageScenarios'); -} catch (error) { - console.error(error.message); - process.exitCode = 1; -} diff --git a/src/Uorc/Registry.lex.tex b/src/Uorc/Registry.lex.tex index 3dce1885..bab177de 100644 --- a/src/Uorc/Registry.lex.tex +++ b/src/Uorc/Registry.lex.tex @@ -38,7 +38,7 @@ name: ucPerf01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-PERF-01", level := "open", suite := "source-authority", statement := "measured public-corpus compression improvement, with exact target and scope; open until actually measured", given := "the registered public-corpus performance claim", when := "the honesty gate reads its disposition before any sealed benchmark result has established the target", expected := "the claim remains open rather than becoming implementation evidence", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-PERF-01", level := "open", suite := "source-authority", statement := "measured public-corpus compression: every release runs scripts/bench.mjs on the Canterbury and Silesia corpora against gzip, bzip2, xz, zstd and brotli and publishes archive sizes and times in the release notes and on the Pages site; open because the measurement sets no target", given := "the registered public-corpus performance claim", when := "the honesty gate reads its disposition", expected := "the claim remains open with its measurements reported, rather than becoming implementation evidence", evidenceKind := "none", researchDisposition := "not_measured"}) } definition{ @@ -87,105 +87,70 @@ name: uc_mach_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-MACH-01", level := "open", suite := "machine-semantics", statement := "Every admitted graph has the source-defined meaning of all 39 wire operations, including eager typed failures, prior-block calls and observer-before-update Scan with its final updater.", given := "typed admitted graphs and an independent mathematical reference semantics", when := "the source machine executes and its simulation obligations and distinguishing examples are checked", expected := "values and failures agree with the reference; unreachable code is still validated and no unsupported opcode or hidden literal shortcut is accepted", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-MACH-01", level := "build", suite := "machine-semantics", statement := "The client's reference-semantics evaluator decodes program archives, including search-found programs and the ulz kernel graph when the certified fast path declines, to their exact original bytes.", given := "a 64-byte program archive found by the exported search and a ulz kernel archive whose padded payload the fast path declines", when := "uorc decompress evaluates each program graph by the reference semantics", expected := "the output equals the original bytes exactly", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_mach_02, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-MACH-02", level := "open", suite := "machine-resources", statement := "Execution accounts for logical work and runtime-owned bytes under the explicit uorc.logical-owned-bytes/1 profile, including aliases, metadata, closures, transient copies and cancellation; old diagnostic live-cell counts remain distinct from bytes and neither is a claim of physical CPU time or resident memory.", given := "checked source runtime states, resource budgets, immutable backing identities and release cursors", when := "the checked machine takes one transition or ownership release step", expected := "attempts, decoder work, peak live ownership and failures preserve exact accounting; native addressability refusal is operational rather than a restriction of mathematical sequence meaning", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-MACH-02", level := "build", suite := "machine-resources", statement := "Decoding is charged against an explicit decoder work budget, and exhausting the budget is a typed refusal with no partial output.", given := "a program archive and decoder work budgets below and above its cost", when := "uorc decompress runs under each budget", expected := "the small budget returns a decode failure and no bytes, and the sufficient budget returns the exact original", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_wire_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-WIRE-01", level := "open", suite := "wire-format", statement := "The source-declared unshipped archive and machine profile identities have canonical source-owned layouts, strict incremental parsing, exact body lengths and complete EOF checks, without asserting compatibility with an unavailable older draft.", given := "self-contained and conditional raw/program archives, every opcode, malformed fields and all small transport partitions", when := "Frame and GraphEmit serialize and the independent FrameParse and GraphParse paths parse the bytes", expected := "accepted bytes have the specified canonical meaning; truncation, trailing bytes, non-shortest numbers, invalid graphs and unsupported identities reach typed failures", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-WIRE-01", level := "build", suite := "wire-format", statement := "The client decodes only complete UORC archives in their canonical layout, self-contained or over the standard basis: truncated archives, trailing bytes and unsupported format identities are typed decode failures.", given := "a program archive and a coded archive over the standard basis, each truncated at several points, extended with trailing bytes, and with an altered format identity", when := "uorc decompress parses them", expected := "the intact archives decode and every altered one returns a decode failure", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_obj_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-OBJ-01", level := "open", suite := "ordered-objects", statement := "Decoded output preserves the exact ordered object boundary vector, including zero objects and distinct zero-length objects.", given := "ObjectSplit lengths with binary data, internal empty objects, partial input, excess bytes and empty transport chunks", when := "the demultiplexer consumes only demanded input and emits bounded byte spans until one-shot EOF", expected := "ordered bytes and empty boundaries are preserved; early EOF and trailing bytes fail; emitted pieces remain staged rather than implicitly published", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-OBJ-01", level := "build", suite := "ordered-objects", statement := "Archives of ordered objects preserve the exact object boundary vector, including zero objects and distinct zero-length objects.", given := "object vectors with binary data, internal and repeated empty objects, zero objects, and archives truncated or extended by one byte", when := "uorc compresses each vector as one archive and decompresses its objects", expected := "the header records every object length, the decoded objects equal the originals in order with every empty boundary preserved, and truncated or extended archives fail", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_int_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-INT-01", level := "open", suite := "archive-integrity", statement := "Archive and basis integrity use an explicitly identified bounded streaming construction with standard SHA-256 components; digest agreement never replaces exact byte comparison.", given := "source-owned integrity identities, locked independent vectors, split updates, finalization and a planted arithmetic defect", when := "the actual source checks the vectors and the archive path hashes the received preimage", expected := "standard-domain boundaries and any separately named composition are explicit; invalid protocols fail, mutations are caught, and no cryptographic assumption is reported as a kernel theorem", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-INT-01", level := "build", suite := "archive-integrity", statement := "Every archive the client decodes is checked against its UORC-SHA256-CHAIN-v1 integrity trailer, so changing any single bit of an archive makes it fail to decode.", given := "a program archive and a raw archive, each with every byte altered in its low and in its high bit", when := "uorc decompress reads each altered archive", expected := "every altered archive returns a decode failure and none yields output", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_bas_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-BAS-01", level := "open", suite := "conditional-basis", statement := "Conditional archives bind the actual supplied ordered basis using a source-owned length-delimited domain-separated identity, and execute against that admitted basis.", given := "actual immutable basis roots, altered bytes, reordered roots and inserted empty objects", when := "basis admission derives its identity and conditional archive validation checks the stored identifier", expected := "identity is never accepted merely because a caller supplies a matching tag; reconstruction is relative to the actual supplied basis and cryptographic binding assumptions remain explicit", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-BAS-01", level := "build", suite := "conditional-basis", statement := "Conditional archives name the client's standard basis, the ulz and ncm decoder libraries, by its UORC-BASIS-V1 identity and decode only against that actual basis.", given := "archives written at the default and best levels, and the same archives with their basis identity altered and resealed", when := "uorc inspects and decompresses them", expected := "the intact archives name the standard basis identity and decode to the input; an archive naming any other basis is a decode failure even though its header and seal are well formed", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_syn_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-SYN-01", level := "open", suite := "complete-synthesis", statement := "Fair synthesis combines input-derived algebra, recurrence, residuals, dictionary, typed sharing and complete syntax enumeration without making heuristic proposals the admissible universe.", given := "arbitrary input bytes, canonical input normalization, fair phase schedules and exact typed graph lowering", when := "the source scheduler advances proposals under explicit effort and each proposal passes independent archive validation", expected := "only fully charged executable candidates become incumbents; effort changes search progress rather than admissibility and transport partitions do not choose a different canonical search prefix", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-SYN-01", level := "build", suite := "complete-synthesis", statement := "Program search under a step budget keeps a candidate only as a fully checked archive: more effort can change which archive wins, never whether the result decodes to the input.", given := "an input and search budgets of 0, 10000 and 200000 steps", when := "uorc compress runs the search at each budget and each archive is decoded", expected := "every archive decodes to the exact input and a larger budget never yields a larger archive", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_opt_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-OPT-01", level := "open", suite := "scoped-optimality", statement := "The product minimizes complete archive byte length and unsigned lexicographic order within an explicitly sealed wire, basis and decoder-resource scope.", given := "a checked incumbent and the complete finite set of earlier canonical archives in the sealed scope", when := "the independent verifier replays every required predecessor or a proved equivalent canonical framing factorization", expected := "a minimum certificate is accepted only after complete coverage; interrupted or exhausted verification remains incomplete and no unrestricted global minimum is claimed", evidenceKind := "none", researchDisposition := "not_measured"}) -} - -definition{ - name: uc_chk_01, - parameters: [], - result: ConformanceRow, - body: (record ConformanceRow {id := "UC-CHK-01", level := "open", suite := "checkpoint-replay", statement := "Imported checkpoints are untrusted replay requests, not authority for a queue, incumbent, coverage, source identity or resource receipt.", given := "a saved checkpoint plus current full-byte source, basis, model and policy snapshots", when := "source-owned checkpoint validation compares actual data and reconstructs the admissible replay", expected := "mismatches fail or require fresh work; stale digests and serialized coverage cannot manufacture verification or a minimum certificate", evidenceKind := "none", researchDisposition := "not_measured"}) -} - -definition{ - name: uc_prod_01, - parameters: [], - result: ConformanceRow, - body: (record ConformanceRow {id := "UC-PROD-01", level := "open", suite := "product-lifecycle", statement := "The source-owned product lifecycle handles demand, EOF, cancellation, edits, retries, stale completion and publication without exposing unfinished results as completed files.", given := "live sessions, staged outputs, delayed responses, failures after output and host publication outcomes", when := "the controller applies the actual operation result and records the adapter outcome", expected := "only the current verified result may publish; cancellation cleans owned resources, late responses do not replace new input, and partial or unknown publication is reported honestly", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-OPT-01", level := "build", suite := "scoped-optimality", statement := "Compress returns the smallest of the archives it checked, which are the raw archive, the ulz archive, the ncm archive at the best level and any search candidate within the step budget; no minimum beyond that candidate set is claimed.", given := "empty, single-byte, text, structured binary, noise and invalid UTF-8 inputs", when := "uorc compress chooses its archive", expected := "the archive is never larger than the raw archive of the same length, compressible text takes a strictly smaller archive, and the best level is never larger than the default", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_api_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-API-01", level := "open", suite := "product-interfaces", statement := "The same product semantics serve native library, CLI and browser interfaces, with explicitly versioned streaming ownership rather than invented compatibility with bounded whole-buffer adapters.", given := "binary input including NUL and invalid UTF-8, large streams, resource handles and repeated browser actions", when := "the generated native and Wasm interfaces execute compress, decompress, inspect, verify, resume, basis, frontier and comparison operations", expected := "arbitrary byte input has no media or UI-sized format gate; modeled errors, generated computation failures, resource refusal and fatal host outcomes remain distinct", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-API-01", level := "build", suite := "product-interfaces", statement := "The uorc library, CLI and WebAssembly exports run the same compress, decompress, inspect and verify operations over arbitrary bytes, with typed budget, overflow, decode and mismatch failures.", given := "binary input including NUL and invalid UTF-8, passed in memory and on stdin, and an original altered in one bit", when := "the library, the uorc binary and the Wasm exports compress, decompress, inspect and verify it", expected := "all three produce the same archive, the exact original bytes and the same header description; a non-archive is a decode failure and an altered original is a mismatch", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } definition{ name: uc_real_01, parameters: [], result: ConformanceRow, - body: (record ConformanceRow {id := "UC-REAL-01", level := "open", suite := "real-execution", statement := "A real nonliteral archive is independently parsed, executed and compared against every original byte before encoder publication.", given := "generated production executables, structured and unstructured binary corpora, exact source/SDK identities and baseline commands", when := "compression produces the complete archive and an independent decode reconstructs all ordered objects", expected := "byte equality and archive sizes are recorded from actual execution; finite fixtures, source simulation, performance measurements and mathematical proofs remain separate evidence", evidenceKind := "none", researchDisposition := "not_measured"}) -} - -definition{ - name: uc_ctl_01, - parameters: [], - result: ConformanceRow, - body: (record ConformanceRow {id := "UC-CTL-01", level := "open", suite := "product-control", statement := "Source-owned asynchronous product transitions preserve run, revision, ordered input and output ownership.", given := "typed positive and negative control scenarios covering repeated edits, start, cancel, navigation, checkpoint, retry, publication and shutdown", when := "the generated control runtime executes every registered scenario and a planted stale-completion defect", expected := "obsolete completions have no publication effect; checked output is downloadable only under current ownership and cleanup is explicit", evidenceKind := "none", researchDisposition := "not_measured"}) -} - -definition{ - name: uc_viw_01, - parameters: [], - result: ConformanceRow, - body: (record ConformanceRow {id := "UC-VIW-01", level := "open", suite := "product-view", statement := "Source-owned presentation values govern labels, enabled actions, focus, accessibility and evidence claims.", given := "source-owned presentation values, bound user actions and a closed typed application root for persistent state, effects, numeric edits, trusted callbacks, focus and retirement", when := "actual generated application and presentation controls run with repeated edits, stale actions, start/cancel, navigation, close and planted dispatch defects", expected := "checked results remain checked, scoped evidence carries its scope, transport size remains separate and no browser qualification is inferred from source controls", evidenceKind := "none", researchDisposition := "not_measured"}) -} - -definition{ - name: uc_stg_01, - parameters: [], - result: ConformanceRow, - body: (record ConformanceRow {id := "UC-STG-01", level := "open", suite := "product-storage", statement := "Storage admission and observed job-owned storage remain separate from logical arena memory and physical observations.", given := "typed storage reservations, achieved partial writes, bounded immutable input/output leases, prepaid image admission/extraction, frozen accounting work prefixes, scoped I/O totals and actual release/publication receipts under explicit requested quotas", when := "the generated storage, payload-image and output reporting owners execute quota/refusal, retained-prefix resume, cancellation, attachment identity, partial failed writes, stale settlement, unknown publication, cleanup and one-time transfer controls and reject planted defects", expected := "reserved and achieved storage remain separate from logical arena memory; input/output materialization is prepaid and bounded, failure retains achieved owners and actual publication, and settlement alone cannot claim verified archive success", evidenceKind := "none", researchDisposition := "not_measured"}) + body: (record ConformanceRow {id := "UC-REAL-01", level := "build", suite := "real-execution", statement := "Real archives that uorc compress writes for text, structured binary, noise and edge-case inputs are independently decoded and compared against every original byte.", given := "the shipped client and empty, single-byte, text, structured binary, noise and invalid UTF-8 inputs", when := "uorc compress writes each archive and uorc decompress reconstructs it", expected := "every reconstruction equals its original byte for byte, and compressible text takes a program archive under a quarter of its size", evidenceKind := "fixture_result", researchDisposition := "not_measured"}) } definition{ @@ -230,13 +195,6 @@ body: (record ConformanceRow {id := "UC-INT-03", level := "build", suite := "archive-integrity", statement := "Source-owned checker soundness and constructive finite backward reduction are kernel checked for actual canonical framed messages and shape-valid source-SHA-authenticated traces, without global hash injectivity or an assumed frame codec. The decoder-to-authenticated-trace bridge and full product acceptance remain distinct.", given := "the byte equality bridge, actual candidate checker, canonical framing and finite source-SHA-authenticated reverse traces", when := "the saved official component compiler verifies and replays the scoped proof source, then digest-guard, returned-witness and counter defects are planted and restored", expected := "the scoped proofs and exact axiom policies pass; actual false checksum/witness/counter behavior rejects at new proof owners; restored attestations agree without promoting this to original pinned product acceptance", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } -definition{ - name: uc_exe_01, - parameters: [], - result: ConformanceRow, - body: (record ConformanceRow {id := "UC-EXE-01", level := "open", suite := "product-execution", statement := "Product operation binding moves the actual admitted runtime owner, decoded ticket and resulting effects without inventing successful evidence.", given := "typed runtime-engine, producer/admission, semantic ReadyTransfer and noArena IO exchange, a charged immutable ordered-target descriptor, range-aware fresh decoded comparison, actual framing-to-inspection reports and resource-pause/cancellation/terminal-handoff scenarios", when := "the generated product execution owner drives concrete source roots and rejects planted stale, lost-ticket, target-alias, changed-boundary, truncated-range, duplicate-transfer, semantic-ledger-reset, inspection-as-execution, unpaid-getter or uncharged-initialization defects", expected := "one actual arena and every outside root ticket remain inventoried with accepted semantic budget/ledger; target equality requires every ordered length, actual byte and scoped EOF, while failed or cancelled cleanup retains achieved usage and receipts and engine completion alone cannot establish verified archive success", evidenceKind := "none", researchDisposition := "not_measured"}) -} - definition{ name: orderedIntegrityTranscript, parameters: [], @@ -250,12 +208,5 @@ result: ConformanceRow, body: (record ConformanceRow {id := "UC-INT-05", level := "build", suite := "archive-integrity", statement := "Source-owned completed-view and continuous publication proofs derive the actual chosen-profile digest and emitted-image reads, discharging canonical driver termination and OwnedHash control/cleanup lifetime for both explicit format identities and arbitrary finite source input. Initial source-layout correspondence and full product acceptance remain separate consumer obligations.", given := "actual completed ordered views, continuous actual finish/publication transitions and source-derived profile progress and lifetime laws", when := "the composed source theorem, all-declaration audits, exact source mutations and restored generated-model controls are replayed", expected := "canonical digest equality and emitted-image reads follow without caller-supplied hash success or preservation flags; source-layout and full byte reconstruction claims require their own consumer proofs", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) } - -definition{ - name: closedArchiveConsumerBridge, - parameters: [], - result: ConformanceRow, - body: (record ConformanceRow {id := "UC-INT-06", level := "open", suite := "archive-integrity", statement := "Actual archive snapshot, selected preimage traversal and trailer comparison are connected to canonical original-source layout bytes through source-derived consumer calls, structural coverage and retained-node ownership premises.", given := "the exact compatible Core and Wire source, actual archive ownership and independently specified structural source layout", when := "the consumer bridge derives source-selected reader coverage and actual snapshot, retain/feed, trailer comparison and EOF transitions", expected := "only canonical digest equality for the actual retained preimage and exactly32 stored trailer bytes can establish main archive integrity; source lifetime and layout are not inferred from live roots or lengths", evidenceKind := "none", researchDisposition := "not_measured"}) -} \end{semanticmodule} \end{lexlean} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 4c0f8ed8..c94a0cd9 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -18,12 +18,8 @@ mod claims; mod integrity; #[cfg(test)] mod offline; -#[cfg(test)] -mod open_claims; mod product_execution; #[cfg(test)] -mod product_receipts; -#[cfg(test)] mod varint; fn main() -> ExitCode { diff --git a/xtask/src/open_claims.rs b/xtask/src/open_claims.rs deleted file mode 100644 index 639d3e8a..00000000 --- a/xtask/src/open_claims.rs +++ /dev/null @@ -1,83 +0,0 @@ -//! Open v0.1 obligations without their own measurement yet. Each test pins the -//! claim at `open` with no evidence class and no research disposition, so it is -//! reported and never asserted (R2) until a real measurement replaces this row. - -use repo_model::{Level, Model}; - -fn assert_unmeasured_open(id: &str) { - let root = repo_model::repo_root(); - let model = Model::load(&root.join("model")).expect("model loads"); - let claim = model - .ledger - .claim - .iter() - .find(|claim| claim.id == id) - .unwrap_or_else(|| panic!("{id} is registered")); - assert_eq!(claim.level, Level::Open, "{id} must stay open"); - assert_eq!(claim.evidence_kind, "none", "{id} has no evidence class"); - assert_eq!( - claim.research_disposition, "not_measured", - "{id} is not measured" - ); - let feature = claim.feature.as_deref().expect("open claim has a scenario"); - let text = std::fs::read_to_string(root.join(feature)).expect("feature file"); - assert!( - text.contains(&format!("@{id} @open")), - "{id} scenario is tagged open in {feature}" - ); -} - -#[test] -fn machine_semantics_is_open_uc_mach_01() { - assert_unmeasured_open("UC-MACH-01"); -} - -#[test] -fn logical_owned_bytes_is_open_uc_mach_02() { - assert_unmeasured_open("UC-MACH-02"); -} - -#[test] -fn wire_profile_is_open_uc_wire_01() { - assert_unmeasured_open("UC-WIRE-01"); -} - -#[test] -fn object_boundaries_is_open_uc_obj_01() { - assert_unmeasured_open("UC-OBJ-01"); -} - -#[test] -fn streaming_integrity_is_open_uc_int_01() { - assert_unmeasured_open("UC-INT-01"); -} - -#[test] -fn consumer_bridge_is_open_uc_int_06() { - assert_unmeasured_open("UC-INT-06"); -} - -#[test] -fn conditional_basis_is_open_uc_bas_01() { - assert_unmeasured_open("UC-BAS-01"); -} - -#[test] -fn fair_synthesis_is_open_uc_syn_01() { - assert_unmeasured_open("UC-SYN-01"); -} - -#[test] -fn sealed_optimum_is_open_uc_opt_01() { - assert_unmeasured_open("UC-OPT-01"); -} - -#[test] -fn checkpoint_replay_is_open_uc_chk_01() { - assert_unmeasured_open("UC-CHK-01"); -} - -#[test] -fn real_archive_is_open_uc_real_01() { - assert_unmeasured_open("UC-REAL-01"); -} diff --git a/xtask/src/product_execution.rs b/xtask/src/product_execution.rs index 0da095cc..909144aa 100644 --- a/xtask/src/product_execution.rs +++ b/xtask/src/product_execution.rs @@ -1,24 +1,6 @@ //! Actual generated-model execution is required; a committed receipt cannot satisfy this test. #[cfg(test)] mod tests { - #[test] - fn generated_owned_machine_flow_uc_exe_01() { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("repository parent"); - let result = std::process::Command::new("node") - .arg(root.join("scripts/product-machine-runtime.mjs")) - .current_dir(root) - .status() - .expect( - "execute actual source linking, kernel compilation and generated-model controls", - ); - assert!( - result.success(), - "the generated product-machine gate failed" - ); - } - #[test] fn generated_search_and_core_controls_execute() { let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) @@ -31,108 +13,4 @@ mod tests { .expect("execute concrete archive, replay, certification and step-machine controls"); assert!(result.success(), "an executed control vector failed"); } - - #[test] - fn generated_payload_image_flow_uc_stg_01() { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("repository parent"); - let result = std::process::Command::new("node") - .arg(root.join("scripts/product-image-runtime.mjs")) - .current_dir(root) - .status() - .expect("execute source payload admission, kernel compilation and actual lifecycle controls"); - assert!(result.success(), "the generated payload-image gate failed"); - } - #[test] - fn generated_staged_output_image_flow_uc_stg_01() { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("repository parent"); - let result = std::process::Command::new("node") - .arg(root.join("scripts/product-write-image-runtime.mjs")) - .current_dir(root) - .status() - .expect( - "execute actual bounded quote, staging, copy and publication transport controls", - ); - assert!(result.success(), "the generated output-image gate failed"); - } - - #[test] - fn generated_application_flow_uc_viw_01() { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("repository parent"); - let result = std::process::Command::new("node") - .arg(root.join("scripts/product-application-runtime.mjs")) - .current_dir(root) - .status() - .expect( - "execute actual generated application state, effects, callbacks and View controls", - ); - assert!(result.success(), "the generated application gate failed"); - } - #[test] - fn generated_inspection_report_flow_uc_exe_01() { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("repository parent"); - let result = std::process::Command::new("node") - .arg(root.join("scripts/product-inspection-runtime.mjs")) - .current_dir(root) - .status() - .expect("execute actual framing-to-inspection owner and negative controls"); - assert!( - result.success(), - "the generated inspection-report gate failed" - ); - } - #[test] - fn generated_read_controller_flow_uc_stg_01() { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("repository parent"); - let result = std::process::Command::new("node") - .arg(root.join("scripts/product-read-controller-runtime.mjs")) - .current_dir(root) - .status() - .expect("execute bounded read/image attachment and actual custody controls"); - assert!( - result.success(), - "the generated read-controller gate failed" - ); - } - - #[test] - fn generated_output_delivery_flow_uc_stg_01() { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("repository parent"); - let result = std::process::Command::new("node") - .arg(root.join("scripts/product-output-delivery-runtime.mjs")) - .current_dir(root) - .status() - .expect("execute partial-write accounting and actual publication dispositions"); - assert!( - result.success(), - "the generated output-delivery gate failed" - ); - } - - #[test] - fn generated_charged_target_flow_uc_exe_01() { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("repository parent"); - let result = std::process::Command::new("node") - .arg(root.join("scripts/product-target-descriptor-runtime.mjs")) - .current_dir(root) - .status() - .expect("execute charged target construction, ordered lengths and ownership controls"); - assert!( - result.success(), - "the generated target-descriptor gate failed" - ); - } } diff --git a/xtask/src/product_receipts.rs b/xtask/src/product_receipts.rs deleted file mode 100644 index adf0c3e6..00000000 --- a/xtask/src/product_receipts.rs +++ /dev/null @@ -1,144 +0,0 @@ -//! Binding checks for the separately executed product component diagnostic. -//! These receipts do not assert pinned-SDK, native, browser or release acceptance. - -#[cfg(test)] -mod tests { - use std::path::{Path, PathBuf}; - use std::sync::OnceLock; - - use repo_model::{Level, Model}; - use serde_json::Value; - use sha2::{Digest, Sha256}; - - fn root() -> PathBuf { - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .parent() - .expect("xtask has a repository parent") - .to_path_buf() - } - - fn digest(path: &Path) -> String { - Sha256::digest(std::fs::read(path).expect("bound file exists")) - .iter() - .map(|byte| format!("{byte:02x}")) - .collect() - } - - fn list_length(term: &Value) -> u64 { - match term["kind"].as_str() { - Some("nil") => 0, - Some("cons") => 1 + list_length(&term["tail"]), - _ => panic!("the source-owned scenario inventory is not a closed typed list"), - } - } - - fn check_receipt() { - static CHECKED: OnceLock<()> = OnceLock::new(); - CHECKED.get_or_init(|| { - let root = root(); - let receipt: Value = serde_json::from_slice( - &std::fs::read(root.join("validation/product/evidence.json")) - .expect("execute scripts/product-control-validation.py first"), - ) - .expect("diagnostic receipt is JSON"); - assert_eq!(receipt["pinned_sdk_acceptance"], false); - assert_eq!(receipt["restored_byte_for_byte"], true); - assert_eq!(receipt["restored_control"]["exit"], 0); - assert_eq!( - receipt["boundary_probe_sha256"], - digest(&root.join("tests/product-control/user-notice-forgery.lex.tex")) - ); - let negatives = receipt["boundary_negatives"] - .as_array() - .expect("typed boundary negative"); - assert_eq!(negatives.len(), 1); - assert!(negatives[0]["exit"].as_i64().is_some_and(|exit| exit != 0)); - assert_eq!( - receipt["gate_sha256"], - digest(&root.join("scripts/product-control-validation.py")) - ); - assert_eq!( - receipt["host_projection_sha256"], - digest(&root.join("validation/product/host-contract.json")) - ); - assert_eq!( - receipt["host_projection_gate_sha256"], - digest(&root.join("scripts/product-host-projection.py")) - ); - let sources = receipt["source_sha256"] - .as_object() - .expect("source inventory"); - assert_eq!(sources.len(), 13); - for (module, expected) in sources { - assert_eq!( - expected, - &Value::String(digest( - &root.join(format!("src/Uorc/Product/{module}.lex.tex")) - )) - ); - } - let text = std::fs::read_to_string(root.join("src/Uorc/Product/Scenarios.lex.tex")) - .expect("source-owned scenarios"); - let module = lexlean::sdk::read_module(&text).expect("semantic source"); - let declarations = module["declarations"].as_array().expect("declarations"); - let inventory: u64 = ["cases", "observations"] - .into_iter() - .map(|name| { - let declaration = declarations - .iter() - .find(|d| d["name"] == name) - .expect("runtime-owned inventory"); - list_length(&declaration["body"]) - }) - .sum(); - assert!(inventory > 0); - assert_eq!(receipt["runtime_total"].as_u64(), Some(inventory)); - assert_eq!(receipt["runtime_passed"].as_u64(), Some(inventory)); - let mutations = receipt["mutations"].as_array().expect("planted defects"); - assert_eq!(mutations.len(), 5); - assert!(mutations.iter().all(|m| m["verification"]["exit"] - .as_i64() - .or_else(|| m["runtime"]["exit"].as_i64()) - .is_some_and(|exit| exit != 0))); - }); - } - - fn check_open(id: &str) { - check_receipt(); - let model = Model::load(&root().join("model")).expect("model loads"); - assert_eq!( - model - .ledger - .claim - .iter() - .find(|claim| claim.id == id) - .expect("registered obligation") - .level, - Level::Open - ); - } - - #[test] - fn component_control_receipt_is_source_bound_uc_ctl_01() { - check_open("UC-CTL-01"); - } - - #[test] - fn generated_view_value_receipt_is_source_bound_uc_viw_01() { - check_open("UC-VIW-01"); - } - - #[test] - fn public_request_component_receipt_is_source_bound_uc_api_01() { - check_open("UC-API-01"); - } - - #[test] - fn lifecycle_component_receipt_is_source_bound_uc_prod_01() { - check_open("UC-PROD-01"); - } - #[test] - fn storage_component_receipt_is_source_bound_uc_stg_01() { - check_open("UC-STG-01"); - } -}