diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d4aa830..b2f00022 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -379,7 +379,8 @@ jobs: rm -rf "dist/$name" done # The site is a browser closure v2: the page, the brand files, provenance. - node scripts/site.mjs site --wasm build/wasm/uorc.wasm --version "$TAG" --bench bench + # model.json beside it: the theorems, claims and engine state the page shows. + node scripts/site.mjs site --wasm build/wasm/uorc.wasm --version "$TAG" --bench bench --frontier claims/frontier.toml --model-notes model.md name="uorc-${TAG}-wasm" mkdir -p "dist/$name" cp site/uorc_bg.wasm "dist/$name/uorc.wasm" @@ -390,6 +391,7 @@ jobs: Cargo.toml Cargo.lock rust-toolchain.toml crates/uorc crates/uorc-wasm generated/rust LICENSE-APACHE LICENSE-MIT cp bench/bench.json "dist/uorc-${TAG}-bench.json" cp claims/frontier.toml "dist/uorc-${TAG}-frontier.toml" + cp site/model.json "dist/uorc-${TAG}-model.json" (cd dist && sha256sum uorc-*-wasm.tar.gz uorc-*-src.tar.gz *.json *.toml > SHA256SUMS-wasm-src) ls -la dist - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 @@ -405,7 +407,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail - { printf 'uorc %s\n\n' "$TAG"; printf 'Client: https://%s.github.io/%s/\n\n' "${GITHUB_REPOSITORY_OWNER,,}" "${GITHUB_REPOSITORY#*/}"; cat claims/frontier/frontier.md; echo; cat bench/bench.md; } > notes.md + { printf 'uorc %s\n\n' "$TAG"; printf 'Client: https://%s.github.io/%s/\n\n' "${GITHUB_REPOSITORY_OWNER,,}" "${GITHUB_REPOSITORY#*/}"; cat claims/frontier/frontier.md; echo; cat model.md; echo; cat bench/bench.md; } > notes.md if gh release view "$TAG" >/dev/null 2>&1; then gh release upload "$TAG" dist/* --clobber else diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 9ba5c330..2d1ddbcf 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -87,6 +87,7 @@ The three honesty levels (R2): | ID | Level | Statement | | --- | --- | --- | | `UC-WEB-01` | `build` | The Pages client is generated from and conforms to its Prism product model in Uorc.Page: stakeholders, features with their calls and acceptance cases, journeys, the page's UML state machine, operations, fields, controls, examples, error hints, sections, usage, links and quality measures. The generated page holds exactly the modeled elements, and a real browser walks every journey, takes every modeled transition, checks every control's enabled state in every state it reaches and holds every gated quality measure. | +| `UC-WEB-02` | `build` | The product shows the codec as a point of its modelled space: uorc inspect, the library's Info JSON and the Pages client name each frame's codec point (basis, ncm profile word, consolidated model state, lanes and its κ) and the exact steps its decode takes, as Uorc.Performance defines them, from the header alone; the page's model view shows the release's performance theorems, its closed claims with codec point, corpus κ, bytes, steps and the factory's decision, and the engine's tick, rule30 register and weights, exactly as the release publishes them in model.json. | ## performance-theorems @@ -196,3 +197,4 @@ The three honesty levels (R2): | `UC-PERF-07` | `build` | `kernel_theorem` | `not_measured` | A trial abandoned at a bound is modelled as a trial of at most the bound's bytes. For every list of trials and every raw length, the portfolio of trials abandoned at the raw length settles to the same size as the portfolio of complete trials (boundedPortfolioSettlesTheSame), and a trial no smaller than one already kept changes neither the kept bytes nor the kept steps (skippedTrial theorems): a search that stops a candidate once it cannot win, or skips one known to be no smaller, writes an archive of the same size for fewer compress steps. | | `UC-PERF-08` | `build` | `kernel_theorem` | `not_measured` | Choosing by fewer bytes and then fewer steps, from the raw frame and any list of trials, keeps a trial that is no later in that order than every trial in the list and than the raw frame (chosenIsLeast, chosenIsNoWorseThanRaw), has exactly the size the bytes-only rule settles to (chosenKeepsTheSize), and is dominated by no trial it is no later than (leastIsUndominated); a trial no earlier than the kept one changes nothing (excludedTrial theorems). The rule lowers decode steps on byte ties at no cost in size. The released client breaks byte ties by schedule order until its model export adopts this rule. | | `UC-PERF-09` | `build` | `kernel_theorem` | `not_measured` | The potential of a codec point is its bytes plus its steps. Consolidating a candidate into an incumbent lowers the potential by exactly the candidate's gain (consolidationSpendsItsGain), which is positive exactly when the candidate dominates, and over any sequence of candidates the potential never rises (potentialNeverRises). The potential is a natural number, so an engine that consolidates only dominating candidates never regresses and consolidates at most as many times as its first potential. | +| `UC-WEB-02` | `build` | `build_evidence` | `not_measured` | The product shows the codec as a point of its modelled space: uorc inspect, the library's Info JSON and the Pages client name each frame's codec point (basis, ncm profile word, consolidated model state, lanes and its κ) and the exact steps its decode takes, as Uorc.Performance defines them, from the header alone; the page's model view shows the release's performance theorems, its closed claims with codec point, corpus κ, bytes, steps and the factory's decision, and the engine's tick, rule30 register and weights, exactly as the release publishes them in model.json. | diff --git a/crates/model/src/page.rs b/crates/model/src/page.rs index 69a0187c..091f7567 100644 --- a/crates/model/src/page.rs +++ b/crates/model/src/page.rs @@ -77,7 +77,14 @@ pub const ERROR_CODES: &[&str] = &[ "budget", "overflow", "decode", "mismatch", "stopped", "load", ]; /// The tables the page draws. -pub const TABLES: &[&str] = &["inspect", "examples"]; +pub const TABLES: &[&str] = &["inspect", "examples", "theorems", "claims", "weights"]; +/// The tables of the model view, each filled from the release's `model.json`, +/// with the label of its heading. +const MODEL_TABLES: &[(&str, &str)] = &[ + ("theorems", "theorems"), + ("claims", "claims"), + ("weights", "engine"), +]; /// One row: the definition's name and its record's fields as JSON. #[derive(Debug, Clone, PartialEq)] @@ -435,6 +442,11 @@ impl PageModel { ))); } } + for table in TABLES { + if !self.of("Column").iter().any(|c| c.str("table") == *table) { + return Err(inconsistent(format!("table `{table}` has no column"))); + } + } let codes = unique("ErrorHint", "code")?; if codes != ERROR_CODES.iter().map(ToString::to_string).collect() { return Err(inconsistent(format!( @@ -666,6 +678,39 @@ impl PageModel { } h.push_str("\n\n"); + // What the codec claims: the release's theorems, closed claims and + // engine state, which app.js reads from the published model.json. + let _ = write!( + h, + "
\n

{}

\n

{}

\n", + esc(labels.str("unpublished")), + esc(labels.str("model")), + esc(labels.str("modelHelp")) + ); + for (table, heading) in MODEL_TABLES { + let _ = writeln!( + h, + "

{}

", + esc(labels.str(heading)) + ); + if *table == "weights" { + h.push_str("

\n"); + } + let _ = write!( + h, + "
" + ); + for column in self + .sorted("Column") + .into_iter() + .filter(|c| c.str("table") == *table) + { + let _ = write!(h, "", esc(column.str("label"))); + } + h.push_str("
{}
\n"); + } + h.push_str("
\n"); + // What the page does, and usage elsewhere. for section in self.sorted("Section") { let _ = write!( @@ -764,6 +809,45 @@ mod tests { assert!(page.contains("id=\"page-model\"")); } + /// The model view: one table per model table with the model's columns, + /// the engine line, and the inspect table carries the codec point columns. + #[test] + fn the_model_view_holds_every_model_table_uc_web_02() { + let model = PageModel::load(&root()).expect("the page model checks"); + let page = model.render(); + assert!(page.contains("
{}", + esc(column.str("label")) + ))); + } + } + let keys: BTreeSet<&str> = model + .of("Column") + .iter() + .filter(|c| c.str("table") == "inspect") + .map(|c| c.str("key")) + .collect(); + for key in [ + "codec_point", + "steps", + "state", + "lanes", + "ncm_profile", + "claims", + ] { + assert!(keys.contains(key), "inspect shows no {key}"); + } + } + /// Each Prism check rejects its planted defect. #[test] fn planted_model_defects_are_rejected_uc_web_01() { @@ -811,6 +895,12 @@ mod tests { ("uncovered error", |m| { m.rows.get_mut("ErrorHint").expect("rows").pop(); }), + ("table without columns", |m| { + m.rows + .get_mut("Column") + .expect("rows") + .retain(|c| c.str("table") != "weights"); + }), ("remote link", |m| { set(m, "Link", 0, "href", Value::from("https://example.com/")) }), diff --git a/crates/uorc/src/bin/uorc.rs b/crates/uorc/src/bin/uorc.rs index b3c1de63..8397b1ea 100644 --- a/crates/uorc/src/bin/uorc.rs +++ b/crates/uorc/src/bin/uorc.rs @@ -43,7 +43,8 @@ restore keeps the files it completed). An existing output is never replaced unless --force is given. inspect reads every frame header and checks each integrity seal without -decoding. verify decodes without keeping the output and checks integrity and +decoding, and names each frame's codec point (basis, profile word, model +state, lanes, and its κ) and the exact steps its decode takes. verify decodes without keeping the output and checks integrity and declared lengths, and, given an original, that the archive reproduces it byte for byte. All commands stream, so memory stays bounded whatever the size. @@ -758,10 +759,38 @@ fn describe(info: &uorc::Info) -> String { } }, ); + let point = uorc::performance::CodecPoint::of(info); + let hex = |b: &[u8]| b.iter().map(|x| format!("{x:02x}")).collect::(); + let codec = format!( + "profile word {}\n\ + model state {}\n\ + lanes {}\n\ + steps {}\n\ + codec point {}", + info.ncm_profile.map_or_else( + || "none".to_owned(), + |p| match info.representation { + uorc::Representation::NcmX86 => format!("0x{p:05x} x86"), + _ => format!("0x{p:05x}"), + } + ), + if point.state == [0; 32] { + "none".to_owned() + } else { + hex(&point.state) + }, + point.lanes, + uorc::performance::frame_steps(info).map_or_else( + || "not modelled for this representation".to_owned(), + |s| s.to_string() + ), + hex(&point.kappa()), + ); format!( "format {} (machine profile {})\n\ scope {scope}\n\ representation {}\n\ + {codec}\n\ objects {} ({} bytes)\n\ body {} bytes\n\ archive {} bytes\n\ diff --git a/crates/uorc/src/frame.rs b/crates/uorc/src/frame.rs index c3fa2689..7f88b16c 100644 --- a/crates/uorc/src/frame.rs +++ b/crates/uorc/src/frame.rs @@ -101,11 +101,13 @@ impl Info { /// One JSON object describing the archive (no external JSON dependency). pub fn to_json(&self) -> String { + let point = crate::performance::CodecPoint::of(self); let lengths: Vec = self.object_lengths.iter().map(u64::to_string).collect(); format!( "{{\"format\":{},\"profile\":{},\"scope\":\"{}\",\"basis\":{},\"representation\":\"{}\",\"ncm_profile\":{},\"window\":{},\ \"objects\":{},\"object_lengths\":[{}],\"output_bytes\":{},\"body_bytes\":{},\ - \"archive_bytes\":{},\"integrity\":\"{}\",\"digest\":\"{}\",\"integrity_ok\":{},\"steps\":{}}}", + \"archive_bytes\":{},\"integrity\":\"{}\",\"digest\":\"{}\",\"integrity_ok\":{},\ + \"state\":{},\"lanes\":{},\"steps\":{},\"codec_point\":\"{}\"}}", self.format, self.profile, if self.basis.is_some() { "conditional" } else { "self-contained" }, @@ -122,7 +124,15 @@ impl Info { self.integrity_profile(), self.digest_hex(), self.integrity_ok, - crate::performance::frame_steps(self).map_or_else(|| "null".to_owned(), |n| n.to_string()), + if point.state == [0; 32] { + "null".to_owned() + } else { + format!("\"{}\"", hex(&point.state)) + }, + point.lanes, + crate::performance::frame_steps(self) + .map_or_else(|| "null".to_owned(), |s| s.to_string()), + hex(&point.kappa()), ) } } diff --git a/crates/uorc/tests/cli.rs b/crates/uorc/tests/cli.rs index 65ebf0dd..9bc4b629 100644 --- a/crates/uorc/tests/cli.rs +++ b/crates/uorc/tests/cli.rs @@ -108,6 +108,52 @@ fn inspect_reads_the_header_without_decoding() { assert_eq!(code(&uorc(&["inspect", s(&input)])), 4); } +/// UC-WEB-02: inspect names each frame's codec point and the exact steps its +/// decode takes, as `uorc::performance` reads them from the header, in JSON +/// and in text, for an ncm frame and a raw frame. +#[test] +fn inspect_names_each_frames_codec_point_uc_web_02() { + let dir = scratch("inspect-point"); + let text: Vec = TEXT.iter().copied().cycle().take(20_000).collect(); + let mut x = 0x9e37_79b9_7f4a_7c15u64; + let noise: Vec = (0..4000) + .map(|_| { + x ^= x << 13; + x ^= x >> 7; + x ^= x << 17; + (x >> 56) as u8 + }) + .collect(); + for (name, data) in [("t.txt", &text), ("n.bin", &noise)] { + let input = dir.join(name); + fs::write(&input, data).unwrap(); + assert_eq!(code(&uorc(&["compress", s(&input)])), 0); + let archive = dir.join(format!("{name}.uorc")); + let shown = uorc(&["inspect", "--json", s(&archive)]); + assert_eq!(code(&shown), 0, "{shown:?}"); + let json = String::from_utf8(shown.stdout).unwrap(); + let text = String::from_utf8(uorc(&["inspect", s(&archive)]).stdout).unwrap(); + let coding = if name == "t.txt" { "ncm" } else { "raw" }; + assert!( + json.contains(&format!("\"representation\":\"{coding}\"")), + "{json}" + ); + for frame in uorc::frames(&fs::read(&archive).unwrap()).unwrap() { + let info = uorc::inspect(frame).unwrap(); + let point = uorc::performance::CodecPoint::of(&info); + let kappa: String = point.kappa().iter().map(|b| format!("{b:02x}")).collect(); + let steps = uorc::performance::frame_steps(&info).expect("modelled steps"); + assert!( + json.contains(&format!("\"steps\":{steps},\"codec_point\":\"{kappa}\"")), + "{json}" + ); + assert!(json.contains("\"state\":null,\"lanes\":1"), "{json}"); + assert!(text.contains(&format!("codec point {kappa}")), "{text}"); + assert!(text.contains(&format!("steps {steps}")), "{text}"); + } + } +} + #[test] fn verify_checks_integrity_and_the_original() { let dir = scratch("verify"); diff --git a/docs/verification/pages-client.md b/docs/verification/pages-client.md index 0ff180ee..8d4b9ea0 100644 --- a/docs/verification/pages-client.md +++ b/docs/verification/pages-client.md @@ -1,5 +1,5 @@ -# Pages client against its product model (UC-WEB-01) +# Pages client against its product model (UC-WEB-01, UC-WEB-02) `src/Uorc/Page.lex.tex` is the authority. This file records what was found on the v0.3 page, the evidence the gate produces and the planted defects that show @@ -119,3 +119,61 @@ stack the exported reference code needs is part of every figure. Node (same V8) on 2 MB of repository text: 0.21 MB/s both ways without SIMD128, 0.29 MB/s with it, against 0.53 MB/s for one native core. Random input compresses at 0.18 MB/s before being stored raw. + +## v0.5: the codec point, the claims and the engine (UC-WEB-02) + +The v0.5 Prism model states the codec as a point of a modelled space and +records claims about it (`Uorc.Performance`, `frontier.toml`, +`model/engine.toml`). The product now shows that model wherever it shows an +archive: + +- `uorc::Info::to_json` (and so `uorc inspect --json`, the wasm `inspect` and + the page) gives each frame's `state`, `lanes`, `steps` and `codec_point` + from `uorc::performance`: the step count is exact and read from the header + alone (raw: one per byte, reference: none, ncm: eight bits times the inputs + the profile word keeps, per byte), and the codec point κ is SHA-256 over + `uorc/codec-point/1`, the basis, the profile word, the state κ and the lane + count. `uorc inspect` prints the same lines in text. +- The page's inspect table adds the profile word, model state, lanes, steps, + codec point κ and the recorded claims that name that point. +- `scripts/site.mjs` publishes `model.json` beside the closure (as it does the + bench page): the ledger's `UC-PERF-*` rows, the claims of `frontier.toml` + and the engine state of `model/engine.toml`. Its reader refuses any TOML it + cannot read faithfully, so a register the page would misreport fails the + build. The release passes `--frontier claims/frontier.toml`, the register + the factory decided for the tag, so the page lists the same claims as the + release's `frontier.md` notes and `uorc--frontier.toml`. The page's + model view (`readModel`) shows the three tables and the engine line; the + release attaches `model.json` and adds the performance rows and engine line + to the notes after `frontier.md`. +- The factory obligation `pages` keys on the three model files, so a new + claim or engine tick re-runs the browser acceptance and nothing else. + +Gates: + +- `inspect_names_each_frames_codec_point_uc_web_02` (crates/uorc/tests/cli.rs): + for an ncm and a raw frame, the JSON and text inspect equal the library's + `CodecPoint::of(..).kappa()` and `frame_steps`. +- `the_model_view_holds_every_model_table_uc_web_02` (crates/model): the page + holds each model table with the model's columns and the inspect columns. +- `model.json projects the theorems, claims and engine state` + (scripts/site.test.mjs): the projection of fixture files, integers past + 2^53 kept exact as strings, unreadable TOML refused. +- Browser: `inspect-codec-point` compares every frame of a three-frame stream + with the library's inspect in the same page, against a register that claims + the first frame's point (served under `/claimed/`); `model-theorems`, + `model-claims` and `model-engine` compare the model view with the published + `model.json`. Gated measures `differingCodecPoints` and + `differingModelValues`, both 0. + +Local run (4 vCPU, headless Chromium): `22 cases, 11 transitions, 10 measures`, +both new measures 0. + +| Plant (built `app.js` edited) | Diagnostic | +| --- | --- | +| The inspect table reports no claims for any frame | `judgeFormat: inspect rows [...] differ from the library [...]` | +| The model view's empty-table note dropped | `judgeFormat: claims rows [[""]] differ from model.json [["None recorded in this release."]]` | + +Restored: the unmodified site passes. Measured in that run: an 8 MiB ncm frame +under profile word 0x7e1ff costs 1,342,177,280 steps (160 per byte), and each +reference frame of the stream costs 0. diff --git a/factory/graph.json b/factory/graph.json index 4b955451..fe10bab9 100644 --- a/factory/graph.json +++ b/factory/graph.json @@ -17,7 +17,7 @@ {"name": "integrity-ubuntu-24.04", "kind": "hermetic", "environment": "ubuntu-24.04", "run": "just integrity", "inputs": ["&lexlean", "&xtask", "&scripts", "closure:Uorc.Integrity.*,Uorc.Wire.ArchiveIntegrity,Uorc.Wire.OwnedRead", "validation/integrity/", "standards/", "standards.lock"], "needs": [], "workflow": "bootstrap.yml", "job": "template-gate"}, {"name": "offline", "kind": "fetch", "environment": "ubuntu-24.04", "run": "node scripts/offline-validation.mjs acquire, isolated first and second-distinct-root, compare-offline", "inputs": ["&formal"], "needs": [], "workflow": "offline-validation.yml", "job": "offline-compare"}, {"name": "export", "kind": "fetch", "environment": "host", "run": "node scripts/client-export.mjs", "inputs": ["closure:Uorc.Client@client/src,src", "lexlean.toml", "lakefile.toml", "lake-manifest.json", "lean-toolchain", "scripts/client-export.mjs", "scripts/semantic-source.mjs"], "needs": [], "record": "generated/rust/factory.identity"}, - {"name": "pages", "kind": "fetch", "environment": "ubuntu-24.04", "run": "cargo build --locked --release -p uorc-wasm --target wasm32-unknown-unknown && node scripts/site.mjs && node scripts/page-acceptance.mjs", "inputs": ["&client", "crates/uorc-wasm/", "web/", "vendor/hologram-brand/", "scripts/site.mjs", "scripts/page-acceptance.mjs", ".github/workflows/pages-client.yml"], "needs": [], "workflow": "pages-client.yml", "job": "acceptance"}, + {"name": "pages", "kind": "fetch", "environment": "ubuntu-24.04", "run": "cargo build --locked --release -p uorc-wasm --target wasm32-unknown-unknown && node scripts/site.mjs && node scripts/page-acceptance.mjs", "inputs": ["&client", "crates/uorc-wasm/", "web/", "vendor/hologram-brand/", "scripts/site.mjs", "scripts/page-acceptance.mjs", ".github/workflows/pages-client.yml", "model/ledger.toml", "frontier.toml", "model/engine.toml"], "needs": [], "workflow": "pages-client.yml", "job": "acceptance"}, {"name": "gate", "kind": "gate", "environment": "-", "run": "-", "inputs": [], "needs": ["rest-ubuntu-24.04", "rest-ubuntu-24.04-arm", "artifacts-ubuntu-24.04", "claims-ubuntu-24.04", "varint-ubuntu-24.04", "reproducibility-ubuntu-24.04", "integrity-ubuntu-24.04", "pages"], "workflow": "release.yml", "job": "factory"}, {"name": "native-x86_64-unknown-linux-gnu", "kind": "fetch", "environment": "ubuntu-24.04", "run": "cargo test --locked --release -p uorc && cargo build --locked --release -p uorc --target x86_64-unknown-linux-gnu", "inputs": ["&client"], "needs": [], "workflow": "release.yml", "job": "native", "evidence": "factory-native-x86_64-unknown-linux-gnu"}, {"name": "native-aarch64-unknown-linux-gnu", "kind": "fetch", "environment": "ubuntu-24.04-arm", "run": "cargo test --locked --release -p uorc && cargo build --locked --release -p uorc --target aarch64-unknown-linux-gnu", "inputs": ["&client"], "needs": [], "workflow": "release.yml", "job": "native", "evidence": "factory-native-aarch64-unknown-linux-gnu"}, diff --git a/features/suites/pages-client.feature b/features/suites/pages-client.feature index 4eec5bb7..e5341dd2 100644 --- a/features/suites/pages-client.feature +++ b/features/suites/pages-client.feature @@ -6,3 +6,9 @@ Feature: pages-client Given the Uorc.Page module, the generated web/index.html and the site built from the release wasm When the model gate checks and renders the model and the browser acceptance drives the built site in headless Chromium Then every Prism check holds, the committed page equals the rendered model, every acceptance case passes, every transition is taken and every gated measure is within its threshold + + @UC-WEB-02 @build + Scenario: The product shows the codec as a point of its modelled space: uorc inspect, the library's Info JSON and the Pages client name each frame's codec point (basis, ncm profile word, consolidated model state, lanes and its κ) and the exact steps its decode takes, as Uorc.Performance defines them, from the header alone; the page's model view shows the release's performance theorems, its closed claims with codec point, corpus κ, bytes, steps and the factory's decision, and the engine's tick, rule30 register and weights, exactly as the release publishes them in model.json. + Given an archive written by uorc, the Uorc.Page module and the site built with model.json from the claim ledger, frontier.toml and model/engine.toml + When uorc inspect reads the archive and the browser acceptance inspects it on the page and reads the model view + Then the codec point κ and steps equal the library's for every frame, and every theorem, claim and engine value on the page equals model.json diff --git a/model/ids.toml b/model/ids.toml index 097dad41..8997065d 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -230,3 +230,9 @@ id = "UC-PERF-09" level = "build" suite = "performance-theorems" statement = "The potential of a codec point is its bytes plus its steps. Consolidating a candidate into an incumbent lowers the potential by exactly the candidate's gain (consolidationSpendsItsGain), which is positive exactly when the candidate dominates, and over any sequence of candidates the potential never rises (potentialNeverRises). The potential is a natural number, so an engine that consolidates only dominating candidates never regresses and consolidates at most as many times as its first potential." + +[[id]] +id = "UC-WEB-02" +level = "build" +suite = "pages-client" +statement = "The product shows the codec as a point of its modelled space: uorc inspect, the library's Info JSON and the Pages client name each frame's codec point (basis, ncm profile word, consolidated model state, lanes and its κ) and the exact steps its decode takes, as Uorc.Performance defines them, from the header alone; the page's model view shows the release's performance theorems, its closed claims with codec point, corpus κ, bytes, steps and the factory's decision, and the engine's tick, rule30 register and weights, exactly as the release publishes them in model.json." diff --git a/model/ledger.toml b/model/ledger.toml index 1cb454d3..8c7c8eb9 100644 --- a/model/ledger.toml +++ b/model/ledger.toml @@ -308,3 +308,11 @@ statement = "The potential of a codec point is its bytes plus its steps. Consoli evidence_kind = "kernel_theorem" research_disposition = "not_measured" feature = "features/suites/performance-theorems.feature" + +[[claim]] +id = "UC-WEB-02" +level = "build" +statement = "The product shows the codec as a point of its modelled space: uorc inspect, the library's Info JSON and the Pages client name each frame's codec point (basis, ncm profile word, consolidated model state, lanes and its κ) and the exact steps its decode takes, as Uorc.Performance defines them, from the header alone; the page's model view shows the release's performance theorems, its closed claims with codec point, corpus κ, bytes, steps and the factory's decision, and the engine's tick, rule30 register and weights, exactly as the release publishes them in model.json." +evidence_kind = "build_evidence" +research_disposition = "not_measured" +feature = "features/suites/pages-client.feature" diff --git a/scripts/page-acceptance.mjs b/scripts/page-acceptance.mjs index 7a286fa7..de252a39 100644 --- a/scripts/page-acceptance.mjs +++ b/scripts/page-acceptance.mjs @@ -53,7 +53,12 @@ const server = http.createServer((req, res) => { let url = decodeURIComponent(req.url.split('?')[0]); const broken = url.startsWith('/no-wasm/'); if (broken) url = url.slice('/no-wasm'.length); + // The same site with a register whose claims name the codec points the + // acceptance has just written, so the inspect table must find them. + const claimed = url.startsWith('/claimed/'); + if (claimed) url = url.slice('/claimed'.length); const name = url === '/' ? 'index.html' : url.slice(1); + if (claimed && name === 'model.json') { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify(claimedModel)); return; } const p = path.join(site, name); if (name.includes('/') || !fs.existsSync(p) || (broken && name.endsWith('.wasm'))) { res.writeHead(404); res.end(); return; } res.writeHead(200, { 'content-type': types[path.extname(name)] ?? 'application/octet-stream' }); @@ -62,6 +67,9 @@ const server = http.createServer((req, res) => { await new Promise((r) => server.listen(0, '127.0.0.1', r)); const origin = `http://127.0.0.1:${server.address().port}`; +const published = JSON.parse(fs.readFileSync(path.join(site, 'model.json'), 'utf8')); +let claimedModel = published; + // Chromium over the DevTools protocol. const profile = fs.mkdtempSync(path.join(os.tmpdir(), 'uorc-chrome-')); const browser = spawn(chrome, ['--headless=new', '--no-sandbox', '--disable-gpu', '--no-first-run', '--remote-debugging-port=0', `--user-data-dir=${profile}`, 'about:blank'], { stdio: ['ignore', 'ignore', 'pipe'] }); @@ -333,6 +341,38 @@ const cases = { expect(JSON.stringify(head) === JSON.stringify(columns), 'inspect columns differ from the model'); expect(rows.length === 3 && rows[2][1] === 'reference' && rows.every((row) => row[5] === 'intact'), `inspect rows ${JSON.stringify(rows)}`); }, + // Each frame's codec point, steps and claims on the page equal what the + // library reads from the header and what the register says about the point. + async 'inspect-codec-point'() { + await need('compress-matches-library'); + const library = await evaluate(`(async () => { + const { load } = await import('./uorc.js'); + const u = await load('./uorc_bg.wasm'); + return u.inspect(new Uint8Array(${JSON.stringify([...fs.readFileSync(saved.frames)])})); + })()`); + expect(library.length === 3 && library.every((f) => /^[0-9a-f]{64}$/.test(f.codec_point)), `library inspect ${JSON.stringify(library.map((f) => f.codec_point))}`); + expect(library[2].steps === 0 && library[0].steps > 0, `reference frames cost no steps: ${JSON.stringify(library.map((f) => f.steps))}`); + claimedModel = { ...published, claims: [{ id: 'acceptance', form: 'closed', codec: library[0].codec_point, corpus: '00', bytes: library[0].archive_bytes, steps: library[0].steps, status: 'proved' }] }; + await open(`${origin}/claimed/`); + await tab('inspect'); + await setFiles('field-archive', [saved.frames]); + const r = await runAndWait(); + expect(r.state === 'done', `inspect: ${await text('status')}`); + const columns = model.Column.filter((c) => c.table === 'inspect').sort((a, b) => a.order - b.order); + const at = (key) => columns.findIndex((c) => c.key === key); + const rows = await evaluate("[...document.querySelectorAll('#result tbody tr')].map((tr) => [...tr.cells].map((c) => c.textContent))"); + let differing = 0; + library.forEach((f, i) => { + const row = rows[i] ?? []; + const claims = library[0].codec_point === f.codec_point ? '1 proved' : 'none'; + if (row[at('codec_point')] !== f.codec_point || row[at('steps')] !== f.steps.toLocaleString('en-US') + || row[at('lanes')] !== String(f.lanes) || row[at('state')] !== (f.state ?? 'none') + || row[at('ncm_profile')] !== (f.ncm_profile == null ? 'none' : `${f.ncm_profile}${f.representation === 'ncm-x86' ? ' x86' : ''}`) || row[at('claims')] !== claims) differing += 1; + }); + raise('differingCodecPoints', differing + Math.abs(rows.length - library.length)); + expect(gates.differingCodecPoints === 0, `inspect rows ${JSON.stringify(rows)} differ from the library ${JSON.stringify(library)}`); + await open(); + }, async 'verify-archive'() { await need('compress-file'); await tab('verify'); @@ -354,6 +394,17 @@ const cases = { const r = await runAndWait(); expect(r.state === 'failed', `verify against another file: ${await text('status')}`); }, + async 'model-theorems'() { await modelTable('theorems', published.theorems); }, + async 'model-claims'() { await modelTable('claims', published.claims); }, + async 'model-engine'() { + await modelTable('weights', published.engine.weights); + const e = published.engine; + const line = await text('model-engine'); + const want = e.tick == null ? await evaluate("document.getElementById('model').dataset.empty") + : `Tick ${e.tick.toLocaleString('en-US')}, rule30 register ${e.rule30}, ${e.strategies.toLocaleString('en-US')} strategies in the portfolio.`; + raise('differingModelValues', (gates.differingModelValues ?? 0) + (line === want ? 0 : 1)); + expect(line === want, `engine line ${line} differs from model.json (${want})`); + }, async 'cancel-running'() { await tab('compress'); await setFiles('field-files', [inputs.frames]); @@ -410,6 +461,24 @@ const cases = { expect(await evaluate("[...document.querySelectorAll('button, input')].every((e) => e.disabled)"), 'a control is enabled without the client'); }, }; +// A model view table against model.json: the model's columns, and one row +// per published row with every value as published (or the empty note). +async function modelTable(kind, published) { + await waitFor(`document.querySelector('#model-${kind} tbody').rows.length > 0`, 10000); + const columns = model.Column.filter((c) => c.table === kind).sort((a, b) => a.order - b.order); + const head = await evaluate(`[...document.querySelectorAll('#model-${kind} thead th')].map((th) => th.textContent)`); + expect(JSON.stringify(head) === JSON.stringify(columns.map((c) => c.label)), `${kind} columns differ from the model`); + const rows = await evaluate(`[...document.querySelectorAll('#model-${kind} tbody tr')].map((tr) => [...tr.cells].map((c) => c.textContent))`); + const show = (v) => (typeof v === 'number' ? v.toLocaleString('en-US') : String(v ?? '')); + const want = published.length ? published.map((row) => columns.map((c) => show(row[c.key]))) + : [[await evaluate("document.getElementById('model').dataset.empty")]]; + let differing = 0; + want.forEach((row, i) => row.forEach((v, j) => { if ((rows[i] ?? [])[j] !== v) differing += 1; })); + differing += Math.abs(rows.length - want.length); + raise('differingModelValues', (gates.differingModelValues ?? 0) + differing); + expect(differing === 0, `${kind} rows ${JSON.stringify(rows)} differ from model.json ${JSON.stringify(want)}`); +} + const done = new Set(); async function need(name) { if (done.has(name)) return; diff --git a/scripts/site.mjs b/scripts/site.mjs index fd6dae1f..10a47ae2 100644 --- a/scripts/site.mjs +++ b/scripts/site.mjs @@ -7,9 +7,12 @@ // names the SHA-256 of every other closure file. The brand files are the // vendored `hologram-brand` dependency (vendor/hologram-brand, byte-identical to // PrismPM's at 898dcdf, held by its MANIFEST.sha256). The release's benchmark -// page (bench.html, bench.json, bench.md) is published beside the closure. +// page (bench.html, bench.json, bench.md) is published beside the closure, and +// so is model.json: the release's performance theorems (the UC-PERF rows of the +// claim ledger), its closed claims (frontier.toml) and its engine state +// (model/engine.toml), which the page's model view shows. // -// node scripts/site.mjs --wasm --version [--bench ] +// node scripts/site.mjs --wasm --version [--bench ] [--frontier ] [--model-notes ] import crypto from 'node:crypto'; import fs from 'node:fs'; import path from 'node:path'; @@ -32,6 +35,90 @@ export const BRAND_FILES = { }; export const PAGE_FILES = ['index.html', 'app.css', 'app.js', `${STEM}.js`]; export const BENCH_FILES = ['bench.html', 'bench.json', 'bench.md']; +/** Published beside the closure from the repository's own model files. */ +export const MODEL_FILE = 'model.json'; +const BESIDE = [...BENCH_FILES, MODEL_FILE]; + +/** + * The TOML the model files use: tables, arrays of tables, and keys holding + * strings, integers, Booleans or one-line arrays of them. Anything else is + * refused, so a file the page cannot read faithfully fails the build. + */ +export function readToml(text, name = 'toml') { + const root = {}; + let at = root; + const scalar = (raw, line) => { + const v = raw.trim(); + if (v.startsWith('"')) { + const m = v.match(/^"((?:[^"\\]|\\.)*)"$/); + if (!m) throw new Error(`${name}:${line}: unreadable string ${v}`); + return JSON.parse(`"${m[1]}"`); + } + if (v === 'true' || v === 'false') return v === 'true'; + if (/^[+-]?(0x[0-9a-fA-F_]+|[0-9][0-9_]*)$/.test(v)) { + const n = BigInt(v.replace(/_/g, '')); + return n <= BigInt(Number.MAX_SAFE_INTEGER) && n >= -BigInt(Number.MAX_SAFE_INTEGER) ? Number(n) : n.toString(); + } + if (v.startsWith('[') && v.endsWith(']')) { + const inner = v.slice(1, -1).trim(); + if (!inner) return []; + return (inner.match(/"(?:[^"\\]|\\.)*"|[^,]+/g) ?? []).map((x) => x.trim()).filter((x) => x).map((x) => scalar(x, line)); + } + throw new Error(`${name}:${line}: unsupported value ${v}`); + }; + const strip = (l) => { let q = false; for (let i = 0; i < l.length; i += 1) { if (l[i] === '"' && l[i - 1] !== '\\') q = !q; if (l[i] === '#' && !q) return l.slice(0, i); } return l; }; + text.split('\n').forEach((rawLine, i) => { + const l = strip(rawLine).trim(); + if (!l) return; + let m; + if ((m = l.match(/^\[\[([A-Za-z0-9_.-]+)\]\]$/))) { + const keys = m[1].split('.'); + let t = root; + // [[a.b]] appends to b of the last [[a]] table. + for (const k of keys.slice(0, -1)) { t = t[k] ??= {}; if (Array.isArray(t)) t = t.at(-1); } + const last = keys.at(-1); + (t[last] ??= []).push((at = {})); + } else if ((m = l.match(/^\[([A-Za-z0-9_.-]+)\]$/))) { + at = root; + for (const k of m[1].split('.')) { at = at[k] ??= {}; if (Array.isArray(at)) at = at.at(-1); } + } else if ((m = l.match(/^([A-Za-z0-9_-]+|"[^"]+")\s*=\s*(.+)$/))) { + at[m[1].replace(/^"|"$/g, '')] = scalar(m[2], i + 1); + } else throw new Error(`${name}:${i + 1}: unsupported line ${l}`); + }); + return root; +} + +/** + * model.json: the theorems (the ledger's UC-PERF rows), the claims of + * frontier.toml and the engine state of model/engine.toml, as the page shows + * them. A file that does not exist yet contributes nothing. + */ +export function modelState(root = ROOT, { frontier } = {}) { + const read = (rel) => (fs.existsSync(path.join(root, rel)) ? readToml(fs.readFileSync(path.join(root, rel), 'utf8'), rel) : {}); + const ledger = read('model/ledger.toml').claim ?? []; + const theorems = ledger.filter((c) => c.id.startsWith('UC-PERF-')) + .map((c) => ({ id: c.id, statement: c.statement, evidence: c.evidence_kind })); + const register = frontier ? readToml(fs.readFileSync(frontier, 'utf8'), frontier) : read('frontier.toml'); + const claims = (register.claim ?? []).map((c) => ({ + id: c.id, form: c.form, codec: c.codec ?? c.candidate ?? '', candidate: c.candidate ?? null, incumbent: c.incumbent ?? null, + family: c.family ?? null, corpus: c.corpus ?? c.family ?? '', bytes: c.bytes ?? null, steps: c.steps ?? null, status: c.status, + })); + // model/engine.toml (uorc/engine/1): [[weight]] names a [[strategy]] by + // index (its point profile word, bit 31 the x86 filter); [[generator]] + // weights order the engine's search. + const engine = read('model/engine.toml'); + const strategies = engine.strategy ?? []; + const weights = [ + ...(engine.weight ?? []).map((w) => ({ strategy: strategies[w.strategy]?.word ?? String(w.strategy), family: w.family, weight: w.value })), + ...(engine.generator ?? []).map((g) => ({ strategy: `generator ${g.generator}`, family: g.family, weight: g.value })), + ]; + return { + schema: 'uorc/model-state/1', + theorems, + claims, + engine: { tick: engine.tick ?? null, rule30: engine.rule30_state ?? null, strategies: strategies.length, weights }, + }; +} /** The closure v2 file names: the six-file page and the ten brand files. */ export function closureV2() { @@ -70,7 +157,7 @@ export function references(text) { } /** Builds the site into `out` and returns its provenance. */ -export function build(out, { wasm, version, bench }) { +export function build(out, { wasm, version, bench, frontier }) { fs.rmSync(out, { recursive: true, force: true }); fs.mkdirSync(out, { recursive: true }); const files = new Map(); @@ -89,6 +176,8 @@ export function build(out, { wasm, version, bench }) { files.set('provenance.json', Buffer.from(`${JSON.stringify(provenance, null, 2)}\n`)); const site = new Set([...files.keys()]); if (bench) for (const name of BENCH_FILES) { files.set(name, fs.readFileSync(path.join(bench, name))); site.add(name); } + files.set(MODEL_FILE, Buffer.from(`${JSON.stringify(modelState(ROOT, { frontier }), null, 2)}\n`)); + site.add(MODEL_FILE); check(files, site); for (const [name, bytes] of files) fs.writeFileSync(path.join(out, name), bytes); return provenance; @@ -96,7 +185,7 @@ export function build(out, { wasm, version, bench }) { /** Refuses a site that is not closure v2, or whose pages load anything remote or outside it. */ export function check(files, site = new Set(files.keys())) { - const closure = [...files.keys()].filter((name) => !BENCH_FILES.includes(name)).sort(); + const closure = [...files.keys()].filter((name) => !BESIDE.includes(name)).sort(); if (JSON.stringify(closure) !== JSON.stringify(closureV2())) throw new Error(`not closure v2: ${closure.join(', ')}`); for (const name of files.keys()) if (name.includes('/')) throw new Error(`not flat: ${name}`); for (const name of [...PAGE_FILES, ...BENCH_FILES.filter((n) => n.endsWith('.html'))]) { @@ -113,13 +202,25 @@ export function check(files, site = new Set(files.keys())) { if (Object.keys(provenance.files).length !== closure.length - 1) throw new Error('provenance.json names a file outside the closure'); } +/** The release notes' account of model.json, in Markdown. */ +export function modelNotes(m) { + const count = (status) => m.claims.filter((c) => c.status === status).length; + const lines = ['## The model on the page', '']; + lines.push(m.theorems.length ? `Performance rows: ${m.theorems.map((t) => `${t.id} (${t.evidence})`).join(', ')}.` : 'Performance rows: none recorded.'); + lines.push('', `Claims: ${m.claims.length} recorded, ${count('proved')} proved, ${count('refuted')} refuted (listed above).`); + lines.push('', m.engine.tick == null ? 'Engine: no tick recorded.' : `Engine: tick ${m.engine.tick}, rule30 register ${m.engine.rule30}, ${m.engine.strategies} strategies in the portfolio, ${m.engine.weights.length} weights.`); + lines.push('', 'The full register is model.json, on the Pages site and attached to this release.', ''); + return lines.join('\n'); +} + if (process.argv[1] === fileURLToPath(import.meta.url)) { const [out, ...rest] = process.argv.slice(2); const opt = (key) => { const i = rest.indexOf(key); return i < 0 ? undefined : rest[i + 1]; }; if (!out || !opt('--wasm') || !opt('--version')) { - console.error('usage: node scripts/site.mjs --wasm --version [--bench ]'); + console.error('usage: node scripts/site.mjs --wasm --version [--bench ] [--frontier ] [--model-notes ]'); process.exit(2); } - const p = build(out, { wasm: opt('--wasm'), version: opt('--version'), bench: opt('--bench') }); + const p = build(out, { wasm: opt('--wasm'), version: opt('--version'), bench: opt('--bench'), frontier: opt('--frontier') }); + if (opt('--model-notes')) fs.writeFileSync(opt('--model-notes'), modelNotes(JSON.parse(fs.readFileSync(path.join(out, MODEL_FILE), 'utf8')))); console.log(`site: closure v2, ${Object.keys(p.files).length + 1} files, ${p.application} ${p.version}`); } diff --git a/scripts/site.test.mjs b/scripts/site.test.mjs index 6126f846..708d07b9 100644 --- a/scripts/site.test.mjs +++ b/scripts/site.test.mjs @@ -8,7 +8,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { test } from 'node:test'; -import { build, check, closureV2, references, webManifest } from './site.mjs'; +import { build, check, closureV2, modelState, readToml, references, webManifest } from './site.mjs'; const scratch = () => fs.mkdtempSync(path.join(os.tmpdir(), 'uorc-site-')); const sha256 = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex'); @@ -31,7 +31,8 @@ test('the site is exactly closure v2 plus the bench page, flat', () => { const provenance = build(out, { wasm, version: 'v0.0.0-test', bench }); const names = fs.readdirSync(out).sort(); assert.equal(closureV2().length, 16); - assert.deepEqual(names, [...closureV2(), 'bench.html', 'bench.json', 'bench.md'].sort()); + assert.deepEqual(names, [...closureV2(), 'bench.html', 'bench.json', 'bench.md', 'model.json'].sort()); + assert.deepEqual(JSON.parse(fs.readFileSync(path.join(out, 'model.json'))), modelState()); for (const name of Object.keys(provenance.files)) { assert.equal(provenance.files[name], sha256(fs.readFileSync(path.join(out, name))), name); } @@ -73,3 +74,25 @@ test('a site that is not closure v2 is refused', () => { test('the web app manifest is the bytes PrismPM writes', () => { assert.equal(webManifest('A').toString(), '{"name":"A","short_name":"A","start_url":"./","scope":"./","display":"standalone","background_color":"#151312","theme_color":"#151312","icons":[{"src":"icon.svg","sizes":"any","type":"image/svg+xml","purpose":"any"},{"src":"icon-512.png","sizes":"512x512","type":"image/png","purpose":"any maskable"}]}\n'); }); + +// UC-WEB-02: model.json carries the ledger's UC-PERF rows, frontier.toml's +// claims and model/engine.toml's state, and a TOML the page cannot read +// faithfully fails the build. +test('model.json projects the theorems, claims and engine state', () => { + const root = scratch(); + fs.mkdirSync(path.join(root, 'model')); + fs.writeFileSync(path.join(root, 'model/ledger.toml'), '[[claim]]\nid = "UC-PERF-02"\nstatement = "an archive never exceeds its input plus a constant"\nevidence_kind = "kernel_theorem"\n\n[[claim]]\nid = "UC-WEB-01"\nstatement = "x"\nevidence_kind = "build_evidence"\n'); + fs.writeFileSync(path.join(root, 'frontier.toml'), '# claims\n[[claim]]\nid = "c1"\nform = "closed"\ncodec = "ab"\ncorpus = "cd"\nbytes = 1_000\nsteps = 9007199254740993\nstatus = "proved"\n\n[[claim.members]]\nname = "a"\nbytes = 3\n\n[[claim]]\nid = "c2"\nform = "closed"\nstatus = "refuted"\n'); + fs.writeFileSync(path.join(root, 'model/engine.toml'), 'spec = "uorc/engine/1"\ntick = 3\nrule30_state = "0x0123"\n\n[[strategy]]\nword = "0x800fffff"\nstate = 0\n\n[[weight]]\nstrategy = 0\nfamily = "text"\nvalue = 12\n\n[[generator]]\ngenerator = "x86"\nfamily = "tiny"\nvalue = 8\n'); + const m = modelState(root); + assert.deepEqual(m.theorems, [{ id: 'UC-PERF-02', statement: 'an archive never exceeds its input plus a constant', evidence: 'kernel_theorem' }]); + assert.equal(m.claims.length, 2); + assert.equal(m.claims[1].status, 'refuted'); + assert.equal(m.claims[0].bytes, 1000); + assert.equal(m.claims[0].steps, '9007199254740993'); + assert.equal(m.claims[0].status, 'proved'); + assert.deepEqual(m.engine, { tick: 3, rule30: '0x0123', strategies: 1, weights: [{ strategy: '0x800fffff', family: 'text', weight: 12 }, { strategy: 'generator x86', family: 'tiny', weight: 8 }] }); + assert.deepEqual(modelState(scratch()), { schema: 'uorc/model-state/1', theorems: [], claims: [], engine: { tick: null, rule30: null, strategies: 0, weights: [] } }); + assert.throws(() => readToml('a = 1.5\n', 'bad.toml'), /bad.toml:1/); + assert.throws(() => readToml('a = { b = 1 }\n', 'bad.toml'), /unsupported/); +}); diff --git a/src/Uorc/Page.lex.tex b/src/Uorc/Page.lex.tex index 26a712a0..8b0f11eb 100644 --- a/src/Uorc/Page.lex.tex +++ b/src/Uorc/Page.lex.tex @@ -37,7 +37,13 @@ {name: download, type: String}, {name: restored, type: String}, {name: cancelled, type: String}, - {name: memory, type: String} + {name: memory, type: String}, + {name: model, type: String}, + {name: modelHelp, type: String}, + {name: theorems, type: String}, + {name: claims, type: String}, + {name: engine, type: String}, + {name: unpublished, type: String} ] } @@ -234,7 +240,7 @@ name: labels, parameters: [], result: Labels, - body: (record Labels {skipToWorkbench := "Skip to the workbench", workbench := "Use uorc here", operations := "Operation", examples := "Examples", examplesHelp := "Each example compresses a built-in input in this page, decompresses the archive again and checks that the bytes are identical.", usage := "Use uorc elsewhere", links := "More", noscript := "This page runs the uorc client with JavaScript and WebAssembly; enable JavaScript to use it.", version := "Release", progress := "Progress", download := "Save", restored := "Restored files", cancelled := "Cancelled. Ready.", memory := "WebAssembly memory"}) + body: (record Labels {skipToWorkbench := "Skip to the workbench", workbench := "Use uorc here", operations := "Operation", examples := "Examples", examplesHelp := "Each example compresses a built-in input in this page, decompresses the archive again and checks that the bytes are identical.", usage := "Use uorc elsewhere", links := "More", noscript := "This page runs the uorc client with JavaScript and WebAssembly; enable JavaScript to use it.", version := "Release", progress := "Progress", download := "Save", restored := "Restored files", cancelled := "Cancelled. Ready.", memory := "WebAssembly memory", model := "What the codec claims", modelHelp := "The statements this release makes about its own performance, as the factory decided them: theorems checked for every input, exact sizes and step counts on named corpora, and the state of the engine that searches the codec space. Each codec point and corpus is named by its κ, a SHA-256 identity.", theorems := "Performance theorems and measurements", claims := "Closed claims", engine := "Engine", unpublished := "None recorded in this release."}) } definition{ @@ -276,7 +282,7 @@ name: inspectArchive, parameters: [], result: Feature, - body: (record Feature {statement := "Read every archive header and integrity seal of a stream without decoding it, as a table.", calls := (cons "uorc.inspect" (nil String)), acceptance := (cons "inspect-archive" (nil String))}) + body: (record Feature {statement := "Read every archive header and integrity seal of a stream without decoding it, as a table with each frame's codec point: its strategy, profile word, model state, lanes, exact step count and κ, and the recorded claims that name it.", calls := (cons "uorc.inspect" (nil String)), acceptance := (cons "inspect-archive" (cons "inspect-codec-point" (nil String)))}) } definition{ @@ -300,6 +306,13 @@ body: (record Feature {statement := "Run built-in inputs through compress and decompress and show their sizes, times and whether the round trip is identical.", calls := (cons "uorc.compress" (cons "uorc.decompress" (nil String))), acceptance := (cons "examples-round-trip" (nil String))}) } +definition{ + name: readModel, + parameters: [], + result: Feature, + body: (record Feature {statement := "Show what this release claims about its own performance, as the factory decided it: the theorems checked for every input, each closed claim with its codec point, corpus, exact bytes and steps and whether it was proved or refuted, and the engine's state with its tick, rule30 register and weights.", calls := (cons "model.json" (nil String)), acceptance := (cons "model-theorems" (cons "model-claims" (cons "model-engine" (nil String))))}) +} + definition{ name: explainFailures, parameters: [], @@ -325,7 +338,7 @@ name: judgeFormat, parameters: [], result: Journey, - body: (record Journey {actor := "Uorc.Page::evaluator", steps := (cons "Uorc.Page::runExamples" (cons "Uorc.Page::inspectArchive" (cons "Uorc.Page::verifyArchive" (cons "Uorc.Page::explainFailures" (nil String)))))}) + body: (record Journey {actor := "Uorc.Page::evaluator", steps := (cons "Uorc.Page::runExamples" (cons "Uorc.Page::readModel" (cons "Uorc.Page::inspectArchive" (cons "Uorc.Page::verifyArchive" (cons "Uorc.Page::explainFailures" (nil String))))))}) } definition{ @@ -622,6 +635,132 @@ body: (record Column {table := "inspect", order := 6, key := "integrity_ok", label := "Integrity seal"}) } +definition{ + name: columnProfile, + parameters: [], + result: Column, + body: (record Column {table := "inspect", order := 7, key := "ncm_profile", label := "Profile word"}) +} + +definition{ + name: columnState, + parameters: [], + result: Column, + body: (record Column {table := "inspect", order := 8, key := "state", label := "Model state"}) +} + +definition{ + name: columnLanes, + parameters: [], + result: Column, + body: (record Column {table := "inspect", order := 9, key := "lanes", label := "Lanes"}) +} + +definition{ + name: columnSteps, + parameters: [], + result: Column, + body: (record Column {table := "inspect", order := 10, key := "steps", label := "Steps"}) +} + +definition{ + name: columnCodecPoint, + parameters: [], + result: Column, + body: (record Column {table := "inspect", order := 11, key := "codec_point", label := "Codec point κ"}) +} + +definition{ + name: columnClaims, + parameters: [], + result: Column, + body: (record Column {table := "inspect", order := 12, key := "claims", label := "Claims"}) +} + +definition{ + name: columnTheoremId, + parameters: [], + result: Column, + body: (record Column {table := "theorems", order := 1, key := "id", label := "Claim"}) +} + +definition{ + name: columnTheoremStatement, + parameters: [], + result: Column, + body: (record Column {table := "theorems", order := 2, key := "statement", label := "Statement"}) +} + +definition{ + name: columnTheoremEvidence, + parameters: [], + result: Column, + body: (record Column {table := "theorems", order := 3, key := "evidence", label := "Evidence"}) +} + +definition{ + name: columnClaimForm, + parameters: [], + result: Column, + body: (record Column {table := "claims", order := 1, key := "form", label := "Form"}) +} + +definition{ + name: columnClaimCodec, + parameters: [], + result: Column, + body: (record Column {table := "claims", order := 2, key := "codec", label := "Codec point κ"}) +} + +definition{ + name: columnClaimCorpus, + parameters: [], + result: Column, + body: (record Column {table := "claims", order := 3, key := "corpus", label := "Corpus κ"}) +} + +definition{ + name: columnClaimBytes, + parameters: [], + result: Column, + body: (record Column {table := "claims", order := 4, key := "bytes", label := "Bytes"}) +} + +definition{ + name: columnClaimSteps, + parameters: [], + result: Column, + body: (record Column {table := "claims", order := 5, key := "steps", label := "Steps"}) +} + +definition{ + name: columnClaimStatus, + parameters: [], + result: Column, + body: (record Column {table := "claims", order := 6, key := "status", label := "Decided"}) +} + +definition{ + name: columnWeightStrategy, + parameters: [], + result: Column, + body: (record Column {table := "weights", order := 1, key := "strategy", label := "Strategy"}) +} + +definition{ + name: columnWeightFamily, + parameters: [], + result: Column, + body: (record Column {table := "weights", order := 2, key := "family", label := "Family"}) +} + +definition{ + name: columnWeightValue, + parameters: [], + result: Column, + body: (record Column {table := "weights", order := 3, key := "weight", label := "Weight"}) +} + definition{ name: columnExampleInput, parameters: [], @@ -710,21 +849,21 @@ name: usageCommandLine, parameters: [], result: Usage, - body: (record Usage {order := 1, title := "Command line", language := "shell", code := (cons "uorc compress --stats notes.txt # writes notes.txt.uorc" (cons "uorc decompress notes.txt.uorc -o notes.restored.txt" (cons "cat data.bin | uorc compress - > data.uorc # any size: streams through 8 MiB frames" (cons "uorc compress --threads 4 big.tar # frames compress in parallel" (cons "uorc decompress --threads 4 big.tar.uorc # blocks of frames decode in parallel" (cons "uorc compress photos/ # writes photos.uorc (a whole tree)" (cons "uorc decompress photos.uorc -o restore/ # --resume finishes an interrupted restore" (cons "uorc inspect notes.txt.uorc # header and integrity, no decoding" (cons "uorc verify notes.txt.uorc notes.txt # decode, check, compare" (cons "# Outputs are written to a temporary file and renamed into place; --force replaces." (cons "# Exit status: 0 ok, 2 usage, 3 I/O, 4 invalid archive or integrity, 5 step budget," (cons "# 6 overflow, 7 differs from the original." (nil String)))))))))))))}) + body: (record Usage {order := 1, title := "Command line", language := "shell", code := (cons "uorc compress --stats notes.txt # writes notes.txt.uorc" (cons "uorc decompress notes.txt.uorc -o notes.restored.txt" (cons "cat data.bin | uorc compress - > data.uorc # any size: streams through 8 MiB frames" (cons "uorc compress --threads 4 big.tar # frames compress in parallel" (cons "uorc decompress --threads 4 big.tar.uorc # blocks of frames decode in parallel" (cons "uorc compress photos/ # writes photos.uorc (a whole tree)" (cons "uorc decompress photos.uorc -o restore/ # --resume finishes an interrupted restore" (cons "uorc inspect notes.txt.uorc # per frame: header, integrity, codec point and steps; no decoding" (cons "uorc verify notes.txt.uorc notes.txt # decode, check, compare" (cons "# Outputs are written to a temporary file and renamed into place; --force replaces." (cons "# Exit status: 0 ok, 2 usage, 3 I/O, 4 invalid archive or integrity, 5 step budget," (cons "# 6 overflow, 7 differs from the original." (nil String)))))))))))))}) } definition{ name: usageRust, parameters: [], result: Usage, - body: (record Usage {order := 2, title := "Rust library", language := "rust", code := (cons "let archive = uorc::compress(&bytes, uorc::DEFAULT_STEPS)?;" (cons "let original = uorc::decompress(&archive, uorc::DEFAULT_DECODE_WORK)?;" (cons "assert_eq!(original, bytes);" (cons "let info = uorc::inspect(&archive)?; // header + integrity, no decode" (cons "uorc::verify(&archive, Some(&bytes), uorc::DEFAULT_DECODE_WORK)?;" (cons "let many = uorc::compress_objects(&[a, b, c], uorc::DEFAULT_STEPS)?;" (cons "let parts = uorc::decompress_objects(&many, uorc::DEFAULT_DECODE_WORK)?;" (cons "// Or stream between any reader and writer, with bounded memory:" (cons "uorc::compress_stream(reader, writer, uorc::DEFAULT_STEPS, uorc::default_threads())?;" (nil String))))))))))}) + body: (record Usage {order := 2, title := "Rust library", language := "rust", code := (cons "let archive = uorc::compress(&bytes, uorc::DEFAULT_STEPS)?;" (cons "let original = uorc::decompress(&archive, uorc::DEFAULT_DECODE_WORK)?;" (cons "assert_eq!(original, bytes);" (cons "let info = uorc::inspect(&archive)?; // header + integrity, no decode" (cons "let point = uorc::performance::CodecPoint::of(&info); // basis, profile, state, lanes; point.kappa()" (cons "uorc::verify(&archive, Some(&bytes), uorc::DEFAULT_DECODE_WORK)?;" (cons "let many = uorc::compress_objects(&[a, b, c], uorc::DEFAULT_STEPS)?;" (cons "let parts = uorc::decompress_objects(&many, uorc::DEFAULT_DECODE_WORK)?;" (cons "// Or stream between any reader and writer, with bounded memory:" (cons "uorc::compress_stream(reader, writer, uorc::DEFAULT_STEPS, uorc::default_threads())?;" (nil String)))))))))))}) } definition{ name: usageJavaScript, parameters: [], result: Usage, - body: (record Usage {order := 3, title := "JavaScript (this page's module)", language := "javascript", code := (cons "import { load } from \"./uorc.js\";" (cons "const uorc = await load(\"./uorc_bg.wasm\");" (cons "const archive = uorc.compress(new TextEncoder().encode(\"hello hello hello\"));" (cons "const original = uorc.decompress(archive);" (cons "uorc.inspect(archive); // [{ representation, object_lengths, integrity_ok, ... }]" (cons "uorc.verify(archive, original); // throws if it does not reproduce original" (cons "const bundle = uorc.compressFiles([{ path: \"a.txt\", data }, { path: \"d\", kind: \"directory\" }]);" (cons "const files = uorc.decompressFiles(bundle); // [{ path, kind, data }]" (cons "// Files of any size, one frame in memory at a time:" (cons "const blob = await uorc.compressBlob(file);" (cons "const back = await uorc.decompressBlob(blob);" (cons "// Folders of any size, the same way:" (cons "const tree = await uorc.compressTreeBlob([{ path: \"d\", kind: \"directory\" }, { path: \"d/a.txt\", blob: file }]);" (cons "const entries = await uorc.decompressTreeBlob(tree); // [{ path, kind, blob }]" (nil String)))))))))))))))}) + body: (record Usage {order := 3, title := "JavaScript (this page's module)", language := "javascript", code := (cons "import { load } from \"./uorc.js\";" (cons "const uorc = await load(\"./uorc_bg.wasm\");" (cons "const archive = uorc.compress(new TextEncoder().encode(\"hello hello hello\"));" (cons "const original = uorc.decompress(archive);" (cons "uorc.inspect(archive); // [{ representation, codec_point, steps, integrity_ok, ... }]" (cons "uorc.verify(archive, original); // throws if it does not reproduce original" (cons "const bundle = uorc.compressFiles([{ path: \"a.txt\", data }, { path: \"d\", kind: \"directory\" }]);" (cons "const files = uorc.decompressFiles(bundle); // [{ path, kind, data }]" (cons "// Files of any size, one frame in memory at a time:" (cons "const blob = await uorc.compressBlob(file);" (cons "const back = await uorc.decompressBlob(blob);" (cons "// Folders of any size, the same way:" (cons "const tree = await uorc.compressTreeBlob([{ path: \"d\", kind: \"directory\" }, { path: \"d/a.txt\", blob: file }]);" (cons "const entries = await uorc.decompressTreeBlob(tree); // [{ path, kind, blob }]" (nil String)))))))))))))))}) } definition{ @@ -825,6 +964,13 @@ body: (record QualityMeasure {requirement := "Uorc.Page::progressWithinFrame", quantity := "longest time the progress bar stands still while an operation runs", unit := "ms", threshold := 2000, disposition := "gate"}) } +definition{ + name: faithfulModel, + parameters: [], + result: QualityRequirement, + body: (record QualityRequirement {characteristic := "functional suitability", subcharacteristic := "functional correctness", text := "The page shows each frame's codec point and step count exactly as the uorc library reads them, and every theorem, claim and engine value exactly as the release publishes them."}) +} + definition{ name: longestPageTask, parameters: [], @@ -867,6 +1013,20 @@ body: (record QualityMeasure {requirement := "Uorc.Page::statusMessages", quantity := "controls without an accessible name", unit := "controls", threshold := 0, disposition := "gate"}) } +definition{ + name: differingCodecPoints, + parameters: [], + result: QualityMeasure, + body: (record QualityMeasure {requirement := "Uorc.Page::faithfulModel", quantity := "frames whose codec point, steps or claims on the page differ from the library's inspect and the published register", unit := "frames", threshold := 0, disposition := "gate"}) +} + +definition{ + name: differingModelValues, + parameters: [], + result: QualityMeasure, + body: (record QualityMeasure {requirement := "Uorc.Page::faithfulModel", quantity := "theorems, claims and engine values on the page that differ from the published model.json", unit := "values", threshold := 0, disposition := "gate"}) +} + definition{ name: compressThroughput, parameters: [], diff --git a/src/Uorc/Registry.lex.tex b/src/Uorc/Registry.lex.tex index 4902ce9f..356575b8 100644 --- a/src/Uorc/Registry.lex.tex +++ b/src/Uorc/Registry.lex.tex @@ -285,5 +285,12 @@ result: ConformanceRow, body: (record ConformanceRow {id := "UC-PERF-09", level := "build", suite := "performance-theorems", statement := "The potential of a codec point is its bytes plus its steps. Consolidating a candidate into an incumbent lowers the potential by exactly the candidate's gain (consolidationSpendsItsGain), which is positive exactly when the candidate dominates, and over any sequence of candidates the potential never rises (potentialNeverRises). The potential is a natural number, so an engine that consolidates only dominating candidates never regresses and consolidates at most as many times as its first potential.", given := "the Uorc.Performance module and the native consolidation in uorc::performance", when := "the locked SDK verifies the module and the native test consolidates every pair and sequence of small trials", expected := "the potential theorems are kernel-checked and every native consolidation lowers bytes plus steps by exactly its gain", evidenceKind := "kernel_theorem", researchDisposition := "not_measured"}) } + +definition{ + name: pagesModelState, + parameters: [], + result: ConformanceRow, + body: (record ConformanceRow {id := "UC-WEB-02", level := "build", suite := "pages-client", statement := "The product shows the codec as a point of its modelled space: uorc inspect, the library's Info JSON and the Pages client name each frame's codec point (basis, ncm profile word, consolidated model state, lanes and its κ) and the exact steps its decode takes, as Uorc.Performance defines them, from the header alone; the page's model view shows the release's performance theorems, its closed claims with codec point, corpus κ, bytes, steps and the factory's decision, and the engine's tick, rule30 register and weights, exactly as the release publishes them in model.json.", given := "an archive written by uorc, the Uorc.Page module and the site built with model.json from the claim ledger, frontier.toml and model/engine.toml", when := "uorc inspect reads the archive and the browser acceptance inspects it on the page and reads the model view", expected := "the codec point κ and steps equal the library's for every frame, and every theorem, claim and engine value on the page equals model.json", evidenceKind := "build_evidence", researchDisposition := "not_measured"}) +} \end{semanticmodule} \end{lexlean} diff --git a/web/app.js b/web/app.js index e75f1bdd..3450006d 100644 --- a/web/app.js +++ b/web/app.js @@ -223,7 +223,7 @@ function runOperation() { const bytes = result.files.reduce((n, f) => n + f.blob.size, 0); return `${fmt(result.input)} → ${fmt(bytes)} bytes in ${fmt(result.files.length)} file(s), in ${seconds(took)}.`; } - const rows = result.rows.map((row, i) => ({ ...row, index: i + 1, integrity_ok: row.integrity_ok ? "intact" : "broken" })); + const rows = result.rows.map((row, i) => frameRow(row, i)); showResult(result, [table("inspect", rows)]); if (result.kind === "table") { const ok = result.rows.every((r) => r.integrity_ok); @@ -235,6 +235,55 @@ function runOperation() { }); } +// One inspect row: the library's header reading, with the frame's codec point +// as the uorc library names it and the published claims that name that point. +function frameRow(row, i) { + return { + ...row, + index: i + 1, + integrity_ok: row.integrity_ok ? "intact" : "broken", + ncm_profile: row.ncm_profile == null ? "none" : `${row.ncm_profile}${row.representation === "ncm-x86" ? " x86" : ""}`, + state: row.state ?? "none", + steps: row.steps == null ? "not modelled" : fmt(row.steps), + claims: claimsNaming(row.codec_point), + }; +} + +// The release's theorems, claims and engine state (model.json, published +// beside the page from the repository's register and engine files). +let published = { theorems: [], claims: [], engine: { tick: null, weights: [] } }; +function claimsNaming(point) { + const named = published.claims.filter((c) => c.codec === point || c.candidate === point || c.incumbent === point); + if (!named.length) return "none"; + const count = (status) => named.filter((c) => c.status === status).length; + return ["proved", "refuted", "open"].filter((s) => count(s)).map((s) => `${fmt(count(s))} ${s}`).join(", "); +} +function fillModel(m) { + published = m; + const empty = $("model").dataset.empty; + const fill = (kind, rows) => { + const body = $(`model-${kind}`).tBodies[0]; + const columns = byOrder(model.Column.filter((c) => c.table === kind)); + body.replaceChildren(); + if (!rows.length) { + const cell = body.insertRow().insertCell(); + cell.colSpan = columns.length; + cell.textContent = empty; + return; + } + for (const row of rows) { + const tr = body.insertRow(); + for (const c of columns) tr.insertCell().textContent = typeof row[c.key] === "number" ? fmt(row[c.key]) : String(row[c.key] ?? ""); + } + }; + fill("theorems", m.theorems); + fill("claims", m.claims); + fill("weights", m.engine.weights); + $("model-engine").textContent = m.engine.tick == null + ? empty + : `Tick ${fmt(m.engine.tick)}, rule30 register ${m.engine.rule30}, ${fmt(m.engine.strategies)} strategies in the portfolio.`; +} + function runExample(example) { const seed = `${one("Workbench").purpose} ${one("Workbench").guidance.join(" ")} `; run({ op: "example", input: example.input, bytes: example.bytes, seed }, `${example.label}`, (result) => { @@ -279,5 +328,9 @@ fetch("provenance.json").then((r) => (r.ok ? r.json() : {})).then((p) => { if (p.version) $("version").textContent = `${$("version").dataset.label} ${p.version}`; }).catch(() => {}); +fetch("model.json").then((r) => (r.ok ? r.json() : Promise.reject(new Error(`model.json: ${r.status}`)))).then(fillModel).catch(() => { + fillModel(published); +}); + render(); start(() => fire("loaded")); diff --git a/web/index.html b/web/index.html index d8be1efa..5d860662 100644 --- a/web/index.html +++ b/web/index.html @@ -67,6 +67,17 @@

Examples

InputBytesArchive bytesRound tripSeconds
+
+

What the codec claims

+

The statements this release makes about its own performance, as the factory decided them: theorems checked for every input, exact sizes and step counts on named corpora, and the state of the engine that searches the codec space. Each codec point and corpus is named by its κ, a SHA-256 identity.

+

Performance theorems and measurements

+
ClaimStatementEvidence
+

Closed claims

+
FormCodec point κCorpus κBytesStepsDecided
+

Engine

+

+
StrategyFamilyWeight
+

What the page does

uorc is Universal Object Reference Compression. Each archive is an exact executable object reference: it carries the program that rebuilds the original, and an integrity seal over itself.

@@ -83,7 +94,7 @@

Command line

uorc decompress --threads 4 big.tar.uorc # blocks of frames decode in parallel uorc compress photos/ # writes photos.uorc (a whole tree) uorc decompress photos.uorc -o restore/ # --resume finishes an interrupted restore -uorc inspect notes.txt.uorc # header and integrity, no decoding +uorc inspect notes.txt.uorc # per frame: header, integrity, codec point and steps; no decoding uorc verify notes.txt.uorc notes.txt # decode, check, compare # Outputs are written to a temporary file and renamed into place; --force replaces. # Exit status: 0 ok, 2 usage, 3 I/O, 4 invalid archive or integrity, 5 step budget, @@ -93,6 +104,7 @@

Rust library

let original = uorc::decompress(&archive, uorc::DEFAULT_DECODE_WORK)?; assert_eq!(original, bytes); let info = uorc::inspect(&archive)?; // header + integrity, no decode +let point = uorc::performance::CodecPoint::of(&info); // basis, profile, state, lanes; point.kappa() uorc::verify(&archive, Some(&bytes), uorc::DEFAULT_DECODE_WORK)?; let many = uorc::compress_objects(&[a, b, c], uorc::DEFAULT_STEPS)?; let parts = uorc::decompress_objects(&many, uorc::DEFAULT_DECODE_WORK)?; @@ -103,7 +115,7 @@

JavaScript (this page's module)

const uorc = await load("./uorc_bg.wasm"); const archive = uorc.compress(new TextEncoder().encode("hello hello hello")); const original = uorc.decompress(archive); -uorc.inspect(archive); // [{ representation, object_lengths, integrity_ok, ... }] +uorc.inspect(archive); // [{ representation, codec_point, steps, integrity_ok, ... }] uorc.verify(archive, original); // throws if it does not reproduce original const bundle = uorc.compressFiles([{ path: "a.txt", data }, { path: "d", kind: "directory" }]); const files = uorc.decompressFiles(bundle); // [{ path, kind, data }] @@ -123,7 +135,7 @@
- +