diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a3deca9..fb946f78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -293,7 +293,7 @@ jobs: - name: Package the binaries, the source bundle, the wasm bundle and the site run: | set -euo pipefail - mkdir -p dist site + mkdir -p dist for target in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu; do name="uorc-${TAG}-${target}" mkdir -p "dist/$name" @@ -303,13 +303,12 @@ jobs: (cd dist && sha256sum "$name.tar.gz" > "$name.tar.gz.sha256") rm -rf "dist/$name" done - cp web/* site/ - cp build/wasm/uorc.wasm site/uorc.wasm - cp bench/bench.html bench/bench.json bench/bench.md site/ - printf '%s\n' "$TAG" > site/version.txt + # 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 name="uorc-${TAG}-wasm" mkdir -p "dist/$name" - cp site/uorc.wasm site/uorc.js LICENSE-APACHE LICENSE-MIT "dist/$name/" + cp site/uorc_bg.wasm "dist/$name/uorc.wasm" + cp site/uorc.js LICENSE-APACHE LICENSE-MIT "dist/$name/" tar -C dist -czf "dist/$name.tar.gz" "$name" rm -rf "dist/$name" git archive --format=tar.gz --prefix="uorc-${TAG}-src/" -o "dist/uorc-${TAG}-src.tar.gz" HEAD \ diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 82998755..d1c3a099 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -64,6 +64,12 @@ The three honesty levels (R2): | --- | --- | --- | | `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. | +## neuromorphic-standard + +| ID | Level | Statement | +| --- | --- | --- | +| `UC-NEU-01` | `build` | The ncm coder's plasticity is stated as the Prism neuromorphic standard in Uorc.Neuromorphic, with kernel-checked bounds: every mixer weight stays within plus or minus 2^22 under the bounded Hebbian rule, potentiation never lowers and depression never raises a weight, the plasticity lies between 24 and 128 per 65536 (128 at the first byte, 24 in the limit), one bit's weight change is at most 16376 and every product fits a 32-bit lane, a context slot never steps past its gap to the coded bit and consolidates at count 127, and every probability-map point stays within 16 bits; the native coder reads the model's constants. | + ## ordered-objects | ID | Level | Statement | @@ -154,3 +160,4 @@ The three honesty levels (R2): | `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-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-NEU-01` | `build` | `kernel_theorem` | `not_measured` | The ncm coder's plasticity is stated as the Prism neuromorphic standard in Uorc.Neuromorphic, with kernel-checked bounds: every mixer weight stays within plus or minus 2^22 under the bounded Hebbian rule, potentiation never lowers and depression never raises a weight, the plasticity lies between 24 and 128 per 65536 (128 at the first byte, 24 in the limit), one bit's weight change is at most 16376 and every product fits a 32-bit lane, a context slot never steps past its gap to the coded bit and consolidates at count 127, and every probability-map point stays within 16 bits; the native coder reads the model's constants. | diff --git a/Justfile b/Justfile index 9b124e38..e37efc6c 100644 --- a/Justfile +++ b/Justfile @@ -56,6 +56,7 @@ lint: # runtimes (tens of minutes) and is its own recipe, `formal-tests`. test: cargo test --locked --workspace --exclude xtask + node --test scripts/site.test.mjs # The xtask suite: product-runtime, integrity, claims and offline harnesses. formal-tests: diff --git a/crates/uorc/src/ncm.rs b/crates/uorc/src/ncm.rs index e084bb6a..7e10f621 100644 --- a/crates/uorc/src/ncm.rs +++ b/crates/uorc/src/ncm.rs @@ -20,6 +20,55 @@ //! probability, which drives a 32-bit binary arithmetic coder. //! //! A payload is the input length (4 bytes, big-endian) and the coder output. +//! +//! The plasticity of every learning part (mixer weights, context slots and +//! the probability maps) is the one the Prism model `Uorc.Neuromorphic` +//! (`src/Uorc/Neuromorphic.lex.tex`) states, with its bounds kernel-checked +//! there; [`standard`] holds its constants. + +/// ncm's plasticity as `Uorc.Neuromorphic` states it. A test holds every +/// constant here equal to the model's, and the coder reads them from here. +pub mod standard { + /// The mixers. + pub const MIXERS: usize = 3; + /// Inputs per mixer: the hashed contexts, the match model's two, a bias. + pub const MIXER_INPUTS: usize = super::NIN; + /// Hashed contexts, each a slot that adapts toward the coded bit. + pub const CONTEXTS: usize = super::NC; + /// Every mixer weight stays within this bound (`hebbianBoundsHold`). + pub const WEIGHT_LIMIT: i32 = 1 << 22; + /// A fresh weight: 1/4 in 16-bit fixed point. + pub const WEIGHT_INITIAL: i32 = 1 << 14; + /// A mixer input's magnitude bound (stretched probabilities, vote, bias). + pub const INPUT_LIMIT: i32 = 2047; + /// A mixer error's magnitude bound (12-bit probabilities). + pub const ERROR_LIMIT: i32 = 4096; + /// A weight learns `x * err * plasticity / 2^PLASTICITY_SHIFT` per bit. + pub const PLASTICITY_SHIFT: u32 = 16; + /// The plasticity's floor, approached as the input is seen. + pub const PLASTICITY_FLOOR: i64 = 24; + /// The plasticity above the floor at the first byte. + pub const PLASTICITY_GAIN: i64 = 104; + /// Bytes after which the plasticity above the floor has halved. + pub const PLASTICITY_HALF_LIFE: i64 = 4096; + /// A weight's largest change in one bit (`laneFitHolds`). + pub const STEP_LIMIT: i32 = 16376; + /// A slot's count saturates here: the slot is consolidated. + pub const COUNT_LIMIT: u8 = 127; + /// A slot adapts by `RATE_NUMERATOR / (2 * count + 3)` / 65536 of its gap. + pub const RATE_NUMERATOR: i32 = 131_072; + /// A probability map point moves 1/2^REFINEMENT_SHIFT of its gap. + pub const REFINEMENT_SHIFT: i32 = 6; + + /// The mixers' plasticity after `pos` coded bytes, in 1/65536 per unit + /// of `x * err`: 128 at the start, decaying toward 24 (`plasticity`). + #[must_use] + pub fn plasticity(pos: u32) -> i32 { + (PLASTICITY_FLOOR + + PLASTICITY_GAIN * PLASTICITY_HALF_LIFE / (PLASTICITY_HALF_LIFE + i64::from(pos))) + as i32 + } +} const NC: usize = 17; const NIN: usize = NC + 3; @@ -31,10 +80,10 @@ const SQT: [i32; 33] = [ 1, 2, 3, 6, 10, 16, 27, 45, 73, 120, 194, 310, 488, 747, 1101, 1546, 2047, 2549, 2994, 3348, 3607, 3785, 3901, 3975, 4022, 4050, 4068, 4079, 4085, 4089, 4092, 4093, 4094, ]; -const WEIGHT_LIMIT: i32 = 1 << 22; +const WEIGHT_LIMIT: i32 = standard::WEIGHT_LIMIT; /// Adaptive probability map rows: 33 interpolation points over the stretch domain. const APM_ROW: usize = 33; -const APM_RATE: i32 = 6; +const APM_RATE: i32 = standard::REFINEMENT_SHIFT; const APM2_BITS: u32 = 16; fn squash(d: i32) -> i32 { @@ -68,7 +117,7 @@ fn tables() -> &'static Tables { } let mut rate = [0i32; 128]; for (c, r) in rate.iter_mut().enumerate() { - *r = 131_072 / (2 * c as i32 + 3); + *r = standard::RATE_NUMERATOR / (2 * c as i32 + 3); } Tables { stretch, rate } }) @@ -232,7 +281,7 @@ fn adapt(p: &mut u16, n: &mut u8, y: bool, rate: &[i32; 128]) { let pv = i32::from(*p); let t = if y { 65535 } else { 0 }; *p = (pv + (((i64::from(t - pv)) * i64::from(r)) >> 16) as i32) as u16; - if *n < 127 { + if *n < standard::COUNT_LIMIT { *n += 1; } } @@ -624,12 +673,11 @@ impl Model { if self.mlen > 0 { adapt(&mut self.msp[self.mi], &mut self.msn[self.mi], y, rate); } - // plasticity: 24 + 104 * 4096 / (4096 + pos), in 1/65536 per unit of x * err - let lr = 24 + (104 * 4096 / (4096 + u64::from(self.pos))) as i64; + let lr = standard::plasticity(self.pos); let yb = i32::from(y) << 12; - // |err| <= 4096 and lr <= 128, so err * lr < 2^20 and x * err * lr - // (|x| <= 2047) stays inside i32: the kernels learn in 32-bit lanes. - let lr = lr as i32; + // |err| <= 4096 and lr <= 128, so err * lr <= 2^19 and x * err * lr + // (|x| <= 2047) stays inside i32 (`laneFitHolds`): the kernels learn + // in 32-bit lanes. let e = [ (yb - self.pm1) * lr, (yb - self.pm2) * lr, @@ -678,7 +726,7 @@ impl Model { fn weights(rows: usize) -> Vec { let mut w = vec![0; rows * NINP]; for r in w.chunks_exact_mut(NINP) { - r[..NIN].fill(1 << 14); + r[..NIN].fill(standard::WEIGHT_INITIAL); } w } diff --git a/crates/uorc/tests/neuromorphic.rs b/crates/uorc/tests/neuromorphic.rs new file mode 100644 index 00000000..a6b836c0 --- /dev/null +++ b/crates/uorc/tests/neuromorphic.rs @@ -0,0 +1,152 @@ +//! UC-NEU-01: the native ncm coder's plasticity is the one the Prism model +//! `Uorc.Neuromorphic` states. The model's bounds are kernel-checked by +//! `lexlean verify`; this test holds the native constants equal to the +//! model's and the model's theorem inventory complete, so neither can drift. + +use std::collections::BTreeMap; +use std::path::PathBuf; +use uorc::ncm::standard; + +fn module() -> String { + let path = + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../src/Uorc/Neuromorphic.lex.tex"); + std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display())) +} + +/// The value of each `field: value` pair of a declaration, in either the +/// one-line or the multi-line canonical layout. +fn field<'a>(decl: &'a str, key: &str) -> Option<&'a str> { + let at = decl.find(&format!("{key}: "))? + key.len() + 2; + let rest = &decl[at..]; + let end = rest.find([',', '}', '\n']).unwrap_or(rest.len()); + Some(rest[..end].trim()) +} + +/// Every parameterless `Nat` definition whose body is a literal. +fn constants(source: &str) -> BTreeMap { + let mut out = BTreeMap::new(); + for decl in source.split("definition{").skip(1) { + // a declaration ends at the blank line before the next + let decl = decl.split("\n\n").next().unwrap_or(decl); + let (Some(name), Some(result), Some(body)) = ( + field(decl, "name"), + field(decl, "result"), + field(decl, "body"), + ) else { + continue; + }; + if decl.contains("parameters: [],") && result == "Nat" { + if let Ok(v) = body.parse() { + out.insert(name.to_string(), v); + } + } + } + out +} + +fn theorems(source: &str) -> Vec { + source + .split("theorem{") + .skip(1) + .filter_map(|decl| field(decl, "name").map(str::to_string)) + .collect() +} + +#[test] +fn native_plasticity_constants_are_the_models_uc_neu_01() { + let c = constants(&module()); + let model = |name: &str| { + *c.get(name) + .unwrap_or_else(|| panic!("model constant {name}")) + }; + let native: [(&str, i64); 18] = [ + ("mixerCount", standard::MIXERS as i64), + ("mixerInputs", standard::MIXER_INPUTS as i64), + ("slotContexts", standard::CONTEXTS as i64), + ("weightLimit", standard::WEIGHT_LIMIT.into()), + ("weightSpan", (2 * standard::WEIGHT_LIMIT).into()), + ("weightInitial", standard::WEIGHT_INITIAL.into()), + ("inputLimit", standard::INPUT_LIMIT.into()), + ("errorLimit", standard::ERROR_LIMIT.into()), + ("plasticityScale", 1 << standard::PLASTICITY_SHIFT), + ("plasticityFloor", standard::PLASTICITY_FLOOR), + ("plasticityGain", standard::PLASTICITY_GAIN), + ("plasticityHalfLife", standard::PLASTICITY_HALF_LIFE), + ("plasticityCeiling", standard::plasticity(0).into()), + ("stepLimit", standard::STEP_LIMIT.into()), + ("countLimit", standard::COUNT_LIMIT.into()), + ("rateNumerator", standard::RATE_NUMERATOR.into()), + ("refinementShift", standard::REFINEMENT_SHIFT.into()), + // the APM target the coder learns toward: 2^16 + 2^shift - 2 + ( + "refinementTarget", + (1 << 16) + (1 << standard::REFINEMENT_SHIFT) - 2, + ), + ]; + for (name, value) in native { + assert_eq!(model(name), value, "{name}"); + } + // The slot rates the model bounds are the native table's. + let rate = |count: i64| i64::from(standard::RATE_NUMERATOR) / (2 * count + 3); + assert_eq!(model("rateCeiling"), rate(0)); + assert_eq!(model("rateFloor"), rate(standard::COUNT_LIMIT.into())); +} + +#[test] +fn native_plasticity_meets_the_models_vectors_and_bounds_uc_neu_01() { + // the closed vectors the model proves with `decide` + for (pos, lr) in [ + (0, 128), + (4096, 76), + (421_888, 25), + (421_889, 24), + (u32::MAX, 24), + ] { + assert_eq!(standard::plasticity(pos), lr, "plasticity({pos})"); + } + // The share above the floor is the quotient `plasticityBoundsHold` + // bounds: share * (4096 + pos) <= 104 * 4096, so 24 <= lr <= 128. + let mut pos = 0u32; + loop { + let share = i64::from(standard::plasticity(pos)) - standard::PLASTICITY_FLOOR; + let d = standard::PLASTICITY_HALF_LIFE + i64::from(pos); + assert!(share * d <= standard::PLASTICITY_GAIN * standard::PLASTICITY_HALF_LIFE); + assert!((0..=104).contains(&share)); + match pos.checked_add(1 + pos / 64) { + Some(next) => pos = next, + None => break, + } + } + // `laneFitHolds`: the largest product and step, in the native lanes. + let top = i64::from(standard::INPUT_LIMIT) + * i64::from(standard::ERROR_LIMIT) + * i64::from(standard::plasticity(0)); + assert_eq!(top, 1_073_217_536); + assert!(top <= i64::from(i32::MAX)); + assert_eq!( + (top + (1 << standard::PLASTICITY_SHIFT) - 1) >> standard::PLASTICITY_SHIFT, + i64::from(standard::STEP_LIMIT) + ); +} + +#[test] +fn the_model_proves_every_stated_bound_uc_neu_01() { + let names = theorems(&module()); + for name in [ + "scaleIsMultiply", + "hebbianBoundsHold", + "potentiationNeverLowersHolds", + "depressionNeverRaisesHolds", + "plasticityBoundsHold", + "plasticityAt0", + "plasticityAt421889", + "laneFitHolds", + "slotRatesBoundedHolds", + "slotRateAtConsolidation", + "slotCountBoundHolds", + "slotStepWithinGapHolds", + "refinementBoundsHold", + ] { + assert!(names.iter().any(|n| n == name), "theorem {name}"); + } +} diff --git a/factory/graph.json b/factory/graph.json index 265a4f00..9e898698 100644 --- a/factory/graph.json +++ b/factory/graph.json @@ -1,7 +1,7 @@ { "schema": "uorc/factory-graph/1", "sets": { - "formal": ["", "!client/", "!crates/uorc/", "!crates/uorc-wasm/", "!generated/", "!web/", "!Cargo.toml", "!Cargo.lock", "!README.md", "!scripts/bench.mjs", "!scripts/client-export.mjs", "!factory/", "!scripts/factory.", "!.github/workflows/release.yml", "!.github/workflows/pages.yml", "!.github/workflows/factory.yml"], + "formal": ["", "!client/", "!crates/uorc/", "!crates/uorc-wasm/", "!generated/", "!web/", "!vendor/hologram-brand/", "!scripts/site.", "!Cargo.toml", "!Cargo.lock", "!README.md", "!scripts/bench.mjs", "!scripts/client-export.mjs", "!factory/", "!scripts/factory.", "!.github/workflows/release.yml", "!.github/workflows/pages.yml", "!.github/workflows/factory.yml"], "client": ["Cargo.toml", "Cargo.lock", "rust-toolchain.toml", ".cargo/", "crates/uorc/", "generated/rust/", ".github/workflows/release.yml"] }, "obligations": [ diff --git a/features/suites/neuromorphic-standard.feature b/features/suites/neuromorphic-standard.feature new file mode 100644 index 00000000..defacd70 --- /dev/null +++ b/features/suites/neuromorphic-standard.feature @@ -0,0 +1,8 @@ +# @generated from src/Uorc/Registry.lex.tex by `cargo xtask check-model --write`. +Feature: neuromorphic-standard + + @UC-NEU-01 @build + Scenario: The ncm coder's plasticity is stated as the Prism neuromorphic standard in Uorc.Neuromorphic, with kernel-checked bounds: every mixer weight stays within plus or minus 2^22 under the bounded Hebbian rule, potentiation never lowers and depression never raises a weight, the plasticity lies between 24 and 128 per 65536 (128 at the first byte, 24 in the limit), one bit's weight change is at most 16376 and every product fits a 32-bit lane, a context slot never steps past its gap to the coded bit and consolidates at count 127, and every probability-map point stays within 16 bits; the native coder reads the model's constants. + Given the Uorc.Neuromorphic module and the native ncm coder's plasticity constants + When the locked SDK verifies the module and the native test reads the module's constants and theorem inventory + Then every bound theorem is kernel-checked and every native plasticity constant equals the model's diff --git a/model/ids.toml b/model/ids.toml index d1cefb12..b6a17d04 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -164,3 +164,9 @@ 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-NEU-01" +level = "build" +suite = "neuromorphic-standard" +statement = "The ncm coder's plasticity is stated as the Prism neuromorphic standard in Uorc.Neuromorphic, with kernel-checked bounds: every mixer weight stays within plus or minus 2^22 under the bounded Hebbian rule, potentiation never lowers and depression never raises a weight, the plasticity lies between 24 and 128 per 65536 (128 at the first byte, 24 in the limit), one bit's weight change is at most 16376 and every product fits a 32-bit lane, a context slot never steps past its gap to the coded bit and consolidates at count 127, and every probability-map point stays within 16 bits; the native coder reads the model's constants." diff --git a/model/ledger.toml b/model/ledger.toml index a29d4fd0..cf47135b 100644 --- a/model/ledger.toml +++ b/model/ledger.toml @@ -220,3 +220,11 @@ 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-NEU-01" +level = "build" +statement = "The ncm coder's plasticity is stated as the Prism neuromorphic standard in Uorc.Neuromorphic, with kernel-checked bounds: every mixer weight stays within plus or minus 2^22 under the bounded Hebbian rule, potentiation never lowers and depression never raises a weight, the plasticity lies between 24 and 128 per 65536 (128 at the first byte, 24 in the limit), one bit's weight change is at most 16376 and every product fits a 32-bit lane, a context slot never steps past its gap to the coded bit and consolidates at count 127, and every probability-map point stays within 16 bits; the native coder reads the model's constants." +evidence_kind = "kernel_theorem" +research_disposition = "not_measured" +feature = "features/suites/neuromorphic-standard.feature" diff --git a/scripts/bench.mjs b/scripts/bench.mjs index e96896e2..b466ff3f 100644 --- a/scripts/bench.mjs +++ b/scripts/bench.mjs @@ -158,6 +158,6 @@ const htmlTable = (head, rows) => `
${h rows.map(r => `${r.map(c => ``).join('')}`).join('')}
${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)}

${esc(ceiling)}

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; zpaq and 7z archive bytes include their container headers. Raw data: bench.json. Back to the client.

${sections}

Tools

    ${report.tools.map(t => `
  • ${esc(t.name)}: ${esc(t.version)}
  • `).join('')}
\n`; +const html = `uorc benchmarks

Benchmarks

${esc(intro)}

${esc(ceiling)}

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; zpaq and 7z archive bytes include their container headers. 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/site.mjs b/scripts/site.mjs new file mode 100644 index 00000000..fd6dae1f --- /dev/null +++ b/scripts/site.mjs @@ -0,0 +1,125 @@ +#!/usr/bin/env node +// Assembles the Pages site as a Prism browser closure v2 (PrismPM SPEC §1.2.1): +// the six-file page (index.html, app.css, app.js, uorc.js, uorc_bg.wasm, +// provenance.json) and the ten Hologram brand files beside it (five web fonts, +// their two OFL licences, icon.svg, icon-512.png and manifest.webmanifest), all +// flat and same-origin, with no remote font, image or script. provenance.json +// 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. +// +// node scripts/site.mjs --wasm --version [--bench ] +import crypto from 'node:crypto'; +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const BRAND = path.join(ROOT, 'vendor/hologram-brand'); +export const NAME = 'uorc'; +export const STEM = 'uorc'; +export const BRAND_FILES = { + 'Archivo-SemiBold.woff2': 'fonts/Archivo-SemiBold.woff2', + 'Geist-Medium.woff2': 'fonts/Geist-Medium.woff2', + 'Geist-Regular.woff2': 'fonts/Geist-Regular.woff2', + 'Geist-SemiBold.woff2': 'fonts/Geist-SemiBold.woff2', + 'GeistMono-Regular.woff2': 'fonts/GeistMono-Regular.woff2', + 'OFL-Archivo.txt': 'fonts/OFL-Archivo.txt', + 'OFL-Geist.txt': 'fonts/OFL-Geist.txt', + 'icon-512.png': 'icon-512.png', + 'icon.svg': 'icon.svg', +}; +export const PAGE_FILES = ['index.html', 'app.css', 'app.js', `${STEM}.js`]; +export const BENCH_FILES = ['bench.html', 'bench.json', 'bench.md']; + +/** The closure v2 file names: the six-file page and the ten brand files. */ +export function closureV2() { + return [...PAGE_FILES, `${STEM}_bg.wasm`, 'provenance.json', ...Object.keys(BRAND_FILES), 'manifest.webmanifest'].sort(); +} + +const sha256 = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex'); + +/** The web app manifest: the bytes PrismPM's brand::web_manifest writes for `name`. */ +export function webManifest(name) { + const n = JSON.stringify(name); + return Buffer.from(`{"name":${n},"short_name":${n},"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`); +} + +/** The vendored brand files, each checked against the vendor manifest. */ +function brandFiles() { + const manifest = new Map( + fs.readFileSync(path.join(BRAND, 'MANIFEST.sha256'), 'utf8').trim().split('\n') + .map((line) => line.split(/\s+/)).map(([digest, file]) => [file, digest]), + ); + return Object.entries(BRAND_FILES).map(([name, source]) => { + const bytes = fs.readFileSync(path.join(BRAND, source)); + if (manifest.get(source) !== sha256(bytes)) throw new Error(`vendor/hologram-brand/${source} differs from its MANIFEST.sha256`); + return [name, bytes]; + }); +} + +/** Every same-origin reference a page file makes, and every remote one. */ +export function references(text) { + const refs = [...text.matchAll(/(?:href|src)="([^"]+)"|url\(([^)]+)\)|(?:load|fetch|import)\(\s*"([^"]+)"|from "([^"]+)"/g)] + .map((m) => (m[1] ?? m[2] ?? m[3] ?? m[4]).replace(/^["']|["']$/g, '')); + return { + local: refs.filter((r) => !/^[a-z]+:/i.test(r) && !r.startsWith('#')).map((r) => r.replace(/^\.\//, '')).filter((r) => r !== ''), + remote: refs.filter((r) => /^[a-z]+:/i.test(r)), + }; +} + +/** Builds the site into `out` and returns its provenance. */ +export function build(out, { wasm, version, bench }) { + fs.rmSync(out, { recursive: true, force: true }); + fs.mkdirSync(out, { recursive: true }); + const files = new Map(); + for (const name of PAGE_FILES) files.set(name, fs.readFileSync(path.join(ROOT, 'web', name))); + files.set(`${STEM}_bg.wasm`, fs.readFileSync(wasm)); + for (const [name, bytes] of brandFiles()) files.set(name, bytes); + files.set('manifest.webmanifest', webManifest(NAME)); + const provenance = { + schema: 'uorc/browser-provenance/2', + closure: 'prism/browser-closure/2', + application: NAME, + version, + wasm_sha256: sha256(files.get(`${STEM}_bg.wasm`)), + files: Object.fromEntries([...files].sort(([a], [b]) => (a < b ? -1 : 1)).map(([name, bytes]) => [name, sha256(bytes)])), + }; + 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); } + check(files, site); + for (const [name, bytes] of files) fs.writeFileSync(path.join(out, name), bytes); + return provenance; +} + +/** 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(); + 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'))]) { + if (!files.has(name)) continue; + const { local, remote } = references(files.get(name).toString('utf8')); + const loads = remote.filter((r) => !/^https:\/\/github\.com\//.test(r)); + if (loads.length) throw new Error(`${name} references ${loads.join(', ')}`); + for (const ref of local) if (!site.has(ref)) throw new Error(`${name} references ${ref}, which the site does not hold`); + } + const provenance = JSON.parse(files.get('provenance.json')); + for (const name of closure.filter((n) => n !== 'provenance.json')) { + if (provenance.files[name] !== sha256(files.get(name))) throw new Error(`provenance.json misnames ${name}`); + } + if (Object.keys(provenance.files).length !== closure.length - 1) throw new Error('provenance.json names a file outside the closure'); +} + +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 ]'); + process.exit(2); + } + const p = build(out, { wasm: opt('--wasm'), version: opt('--version'), bench: opt('--bench') }); + 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 new file mode 100644 index 00000000..4e6892ee --- /dev/null +++ b/scripts/site.test.mjs @@ -0,0 +1,74 @@ +// The Pages site is a browser closure v2: built from web/ and the vendored +// brand files, it holds exactly the sixteen closure files (plus the bench +// page), flat, with provenance.json naming every other file's SHA-256 and no +// page loading anything remote or outside the site. +import assert from 'node:assert/strict'; +import crypto from 'node:crypto'; +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'; + +const scratch = () => fs.mkdtempSync(path.join(os.tmpdir(), 'uorc-site-')); +const sha256 = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex'); + +function fixture() { + const dir = scratch(); + const wasm = path.join(dir, 'uorc_wasm.wasm'); + fs.writeFileSync(wasm, Buffer.from([0, 0x61, 0x73, 0x6d, 1, 0, 0, 0])); + const bench = path.join(dir, 'bench'); + fs.mkdirSync(bench); + fs.writeFileSync(path.join(bench, 'bench.html'), 'raw client'); + fs.writeFileSync(path.join(bench, 'bench.json'), '{}\n'); + fs.writeFileSync(path.join(bench, 'bench.md'), '# bench\n'); + return { dir, wasm, bench }; +} + +test('the site is exactly closure v2 plus the bench page, flat', () => { + const { dir, wasm, bench } = fixture(); + const out = path.join(dir, 'site'); + 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()); + for (const name of Object.keys(provenance.files)) { + assert.equal(provenance.files[name], sha256(fs.readFileSync(path.join(out, name))), name); + } + assert.equal(JSON.parse(fs.readFileSync(path.join(out, 'provenance.json'))).version, 'v0.0.0-test'); + const manifest = JSON.parse(fs.readFileSync(path.join(out, 'manifest.webmanifest'))); + assert.equal(manifest.name, 'uorc'); + assert.equal(manifest.display, 'standalone'); + for (const icon of manifest.icons) assert.ok(names.includes(icon.src), icon.src); +}); + +test('the page loads only same-origin closure files', () => { + const { local, remote } = references(fs.readFileSync(new URL('../web/index.html', import.meta.url), 'utf8') + + fs.readFileSync(new URL('../web/app.css', import.meta.url), 'utf8') + + fs.readFileSync(new URL('../web/app.js', import.meta.url), 'utf8')); + for (const name of ['manifest.webmanifest', 'icon.svg', 'icon-512.png', 'Geist-Regular.woff2', 'uorc_bg.wasm', 'provenance.json']) { + assert.ok(local.includes(name), name); + } + assert.ok(remote.every((r) => r.startsWith('https://github.com/')), remote.join(', ')); +}); + +test('a site that is not closure v2 is refused', () => { + const { dir, wasm, bench } = fixture(); + const out = path.join(dir, 'site'); + build(out, { wasm, version: 'v', bench }); + const files = new Map(fs.readdirSync(out).map((n) => [n, fs.readFileSync(path.join(out, n))])); + const without = new Map(files); without.delete('icon.svg'); + assert.throws(() => check(without), /not closure v2/); + const extra = new Map(files); extra.set('extra.js', Buffer.from('')); + assert.throws(() => check(extra), /not closure v2/); + const tampered = new Map(files); tampered.set('app.js', Buffer.concat([files.get('app.js'), Buffer.from('\n')])); + assert.throws(() => check(tampered), /misnames app.js/); + const remote = new Map(files); remote.set('index.html', Buffer.from('')); + assert.throws(() => check(remote), /references https:\/\/cdn.example/); + const missing = new Map(files); missing.set('index.html', Buffer.from('')); + assert.throws(() => check(missing), /logo.png/); +}); + +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'); +}); diff --git a/src/Uorc/Neuromorphic.lex.tex b/src/Uorc/Neuromorphic.lex.tex new file mode 100644 index 00000000..6a73ae6a --- /dev/null +++ b/src/Uorc/Neuromorphic.lex.tex @@ -0,0 +1,451 @@ +\begin{lexlean}{Uorc.Neuromorphic} +\title{Parameters} +\begin{semanticmodule} +structure{ + name: SynapticPlasticity, + type_parameters: [], + parameters: [], + fields: [ + {name: mixerCount, type: Nat}, + {name: mixerInputs, type: Nat}, + {name: weightLimit, type: Nat}, + {name: weightInitial, type: Nat}, + {name: inputLimit, type: Nat}, + {name: errorLimit, type: Nat}, + {name: plasticityScale, type: Nat}, + {name: plasticityCeiling, type: Nat}, + {name: plasticityFloor, type: Nat}, + {name: plasticityHalfLife, type: Nat}, + {name: stepLimit, type: Nat} + ] +} + +structure{ + name: SlotPlasticity, + type_parameters: [], + parameters: [], + fields: [ + {name: contexts, type: Nat}, + {name: probabilityLimit, type: Nat}, + {name: countLimit, type: Nat}, + {name: rateNumerator, type: Nat}, + {name: rateCeiling, type: Nat}, + {name: rateFloor, type: Nat} + ] +} + +structure{ + name: RefinementPlasticity, + type_parameters: [], + parameters: [], + fields: [ + {name: maps, type: Nat}, + {name: points, type: Nat}, + {name: probabilityLimit, type: Nat}, + {name: rateShift, type: Nat} + ] +} + +structure{ + name: NeuromorphicStandard, + type_parameters: [], + parameters: [], + fields: [ + {name: profile, type: String}, + {name: standard, type: String}, + {name: kernel, type: String}, + {name: synaptic, type: SynapticPlasticity}, + {name: slot, type: SlotPlasticity}, + {name: refinement, type: RefinementPlasticity} + ] +} + +definition{name: mixerCount, parameters: [], result: Nat, body: 3} + +definition{name: mixerInputs, parameters: [], result: Nat, body: 20} + +definition{name: weightLimit, parameters: [], result: Nat, body: 4194304} + +definition{name: weightSpan, parameters: [], result: Nat, body: 8388608} + +definition{name: weightInitial, parameters: [], result: Nat, body: 16384} + +definition{name: inputLimit, parameters: [], result: Nat, body: 2047} + +definition{name: errorLimit, parameters: [], result: Nat, body: 4096} + +definition{name: plasticityScale, parameters: [], result: Nat, body: 65536} + +definition{name: plasticityFloor, parameters: [], result: Nat, body: 24} + +definition{name: plasticityGain, parameters: [], result: Nat, body: 104} + +definition{name: plasticityHalfLife, parameters: [], result: Nat, body: 4096} + +definition{name: plasticityCeiling, parameters: [], result: Nat, body: 128} + +definition{name: stepLimit, parameters: [], result: Nat, body: 16376} + +definition{name: slotContexts, parameters: [], result: Nat, body: 17} + +definition{name: probabilityLimit, parameters: [], result: Nat, body: 65535} + +definition{name: countLimit, parameters: [], result: Nat, body: 127} + +definition{name: rateNumerator, parameters: [], result: Nat, body: 131072} + +definition{name: rateCeiling, parameters: [], result: Nat, body: 43690} + +definition{name: rateFloor, parameters: [], result: Nat, body: 510} + +definition{name: refinementMaps, parameters: [], result: Nat, body: 2} + +definition{name: refinementPoints, parameters: [], result: Nat, body: 33} + +definition{name: refinementTarget, parameters: [], result: Nat, body: 65598} + +definition{name: refinementShift, parameters: [], result: Nat, body: 6} + +definition{ + name: scale, + parameters: [a : Nat, c : Nat], + result: Nat, + body: (match c | Nat.zero => 0 | Nat.succ k => ((scale a k) + a)), + axioms: [], + executable: true, + recursive_argument: c +} + +theorem{ + name: multiplySucc, + parameters: [a : Nat, n : Nat], + statement: ((prim multiply a (n + 1) : Nat) = ((prim multiply a n : Nat) + a)), + proof: reflexivity{}, + axioms: [] +} + +theorem{ + name: scaleIsMultiply, + parameters: [a : Nat, c : Nat], + statement: ((scale a c) = (prim multiply a c : Nat)), + proof: induction{ + branches: [ + {proof: reflexivity{}, binders: [], constructor: zero}, + {proof: simplify{definitions: [ih, multiplySucc, scale]}, binders: [k, ih], constructor: succ} + ], + scrutinee: c + }, + axioms: [propext] +} + +definition{ + name: plasticity, + parameters: [pos : Nat], + result: Nat, + body: ((plasticityFloor) + (prim quotient (prim multiply (plasticityGain) (plasticityHalfLife) : Nat) ((plasticityHalfLife) + pos) 0 : Nat)) +} + +definition{ + name: stepTerm, + parameters: [mag : Nat, err : Nat, rate : Nat], + result: Nat, + body: (scale (scale mag err) rate) +} + +definition{ + name: potentiationStep, + parameters: [mag : Nat, err : Nat, rate : Nat], + result: Nat, + body: (prim quotient (stepTerm mag err rate) (plasticityScale) 0 : Nat) +} + +definition{ + name: depressionStep, + parameters: [mag : Nat, err : Nat, rate : Nat], + result: Nat, + body: (prim quotient ((stepTerm mag err rate) + 65535) (plasticityScale) 0 : Nat) +} + +definition{ + name: potentiateWeight, + parameters: [w : Nat, mag : Nat, err : Nat, rate : Nat], + result: Nat, + body: (if ((weightSpan) ((learnWeight w mag err rate potentiate) <= (weightSpan))), + proof: linear_arithmetic{definitions: [depressWeight, learnWeight, potentiateWeight, weightSpan]}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: potentiationNeverLowersHolds, + parameters: [w : Nat, mag : Nat, err : Nat, rate : Nat], + statement: ((w <= (weightSpan)) -> (w <= (potentiateWeight w mag err rate))), + proof: linear_arithmetic{definitions: [potentiateWeight, weightSpan]}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: depressionNeverRaisesHolds, + parameters: [w : Nat, mag : Nat, err : Nat, rate : Nat], + statement: ((depressWeight w mag err rate) <= w), + proof: linear_arithmetic{definitions: [depressWeight]}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: plasticityBoundsHold, + parameters: [pos : Nat, share : Nat], + statement: (((prim multiply 4096 share : Nat) <= (scale ((plasticityHalfLife) + pos) share)) /\ (((scale ((plasticityHalfLife) + pos) share) <= (prim multiply (plasticityGain) (plasticityHalfLife) : Nat)) -> (share <= 104))), + proof: induction{ + branches: [ + { + proof: linear_arithmetic{definitions: [plasticityGain, plasticityHalfLife, scale]}, + binders: [], + constructor: zero + }, + { + proof: linear_arithmetic{definitions: [plasticityGain, plasticityHalfLife, scale]}, + binders: [k, ih], + constructor: succ + } + ], + scrutinee: share + }, + axioms: [Classical.choice, Quot.sound, propext] +} + +theorem{ + name: plasticityAt0, + parameters: [], + statement: ((plasticity 0) = 128), + proof: decide{}, + axioms: [] +} + +theorem{ + name: plasticityAt4096, + parameters: [], + statement: ((plasticity 4096) = 76), + proof: decide{}, + axioms: [] +} + +theorem{ + name: plasticityAt421888, + parameters: [], + statement: ((plasticity 421888) = 25), + proof: decide{}, + axioms: [] +} + +theorem{ + name: plasticityAt421889, + parameters: [], + statement: ((plasticity 421889) = 24), + proof: decide{}, + axioms: [] +} + +theorem{ + name: laneFitHolds, + parameters: [mag : Nat, err : Nat, rate : Nat], + statement: ((mag <= (inputLimit)) -> ((((scale mag err) <= (prim multiply 2047 err : Nat)) /\ ((err <= (errorLimit)) -> ((stepTerm mag err rate) <= (prim multiply 8384512 rate : Nat)))) /\ ((err <= (errorLimit)) -> ((rate <= (plasticityCeiling)) -> (((stepTerm mag err rate) <= 1073217536) /\ ((depressionStep mag err rate) <= (stepLimit))))))), + proof: induction{ + branches: [ + { + proof: induction{ + branches: [ + { + proof: linear_arithmetic{ + definitions: [ + depressionStep, + errorLimit, + inputLimit, + plasticityCeiling, + plasticityScale, + scale, + stepLimit, + stepTerm + ] + }, + binders: [], + constructor: zero + }, + { + proof: linear_arithmetic{ + definitions: [ + depressionStep, + errorLimit, + inputLimit, + plasticityCeiling, + plasticityScale, + scale, + stepLimit, + stepTerm + ] + }, + binders: [j, jh], + constructor: succ + } + ], + scrutinee: err + }, + binders: [], + constructor: zero + }, + { + proof: linear_arithmetic{ + definitions: [ + depressionStep, + errorLimit, + inputLimit, + plasticityCeiling, + plasticityScale, + scale, + stepLimit, + stepTerm + ] + }, + binders: [k, ih], + constructor: succ + } + ], + scrutinee: rate + }, + axioms: [Classical.choice, Quot.sound, propext] +} + +definition{ + name: slotRate, + parameters: [count : Nat], + result: Nat, + body: (prim quotient (rateNumerator) ((prim multiply 2 count : Nat) + 3) 0 : Nat) +} + +definition{ + name: slotStep, + parameters: [gap : Nat, rate : Nat], + result: Nat, + body: (prim quotient (scale rate gap) (plasticityScale) 0 : Nat) +} + +definition{ + name: slotStepUp, + parameters: [gap : Nat, rate : Nat], + result: Nat, + body: (prim quotient ((scale rate gap) + 65535) (plasticityScale) 0 : Nat) +} + +definition{ + name: slotCount, + parameters: [count : Nat], + result: Nat, + body: (if ((countLimit) <=? (count + 1)) then (countLimit) else (count + 1)) +} + +definition{ + name: slotRatesBounded, + parameters: [fuel : Nat], + result: Bool, + body: (match fuel + | Nat.zero => true + | Nat.succ k => (((slotRate k) <=? (rateCeiling)) && (((rateFloor) <=? (slotRate (if ((countLimit) <=? k) then (countLimit) else k))) && (slotRatesBounded k)))), + axioms: [], + recursive_argument: fuel +} + +theorem{ + name: slotRatesBoundedHolds, + parameters: [], + statement: ((slotRatesBounded 256) = true), + proof: decide{}, + axioms: [] +} + +theorem{ + name: slotRateAtConsolidation, + parameters: [], + statement: ((slotRate (countLimit)) = (rateFloor)), + proof: decide{}, + axioms: [] +} + +theorem{ + name: slotCountBoundHolds, + parameters: [count : Nat], + statement: ((slotCount count) <= (countLimit)), + proof: linear_arithmetic{definitions: [countLimit, slotCount]}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: slotStepWithinGapHolds, + parameters: [gap : Nat, rate : Nat], + statement: ((rate <= (plasticityScale)) -> ((((scale rate gap) <= (prim multiply 65536 gap : Nat)) /\ ((slotStep gap rate) <= gap)) /\ ((slotStepUp gap rate) <= gap))), + proof: induction{ + branches: [ + { + proof: linear_arithmetic{definitions: [plasticityScale, scale, slotStep, slotStepUp]}, + binders: [], + constructor: zero + }, + { + proof: linear_arithmetic{definitions: [plasticityScale, scale, slotStep, slotStepUp]}, + binders: [k, ih], + constructor: succ + } + ], + scrutinee: gap + }, + axioms: [Classical.choice, Quot.sound, propext] +} + +definition{ + name: refineUp, + parameters: [t : Nat], + result: Nat, + body: (t + (prim quotient (prim subtract (refinementTarget) t : Nat) 64 0 : Nat)) +} + +definition{ + name: refineDown, + parameters: [t : Nat], + result: Nat, + body: (prim subtract t (prim quotient (t + 63) 64 0 : Nat) : Nat) +} + +theorem{ + name: refinementBoundsHold, + parameters: [t : Nat], + statement: ((t <= (probabilityLimit)) -> (((t <= (refineUp t)) /\ ((refineUp t) <= (probabilityLimit))) /\ ((refineDown t) <= t))), + proof: linear_arithmetic{definitions: [probabilityLimit, refineDown, refineUp, refinementTarget]}, + axioms: [Classical.choice, Quot.sound, propext] +} + +definition{ + name: ncmNeuromorphicStandard, + parameters: [], + result: NeuromorphicStandard, + body: (record NeuromorphicStandard {profile := "uorc/ncm-plasticity/1", standard := "prism/neuromorphic-standard", kernel := "ncm", synaptic := (record SynapticPlasticity {mixerCount := (mixerCount), mixerInputs := (mixerInputs), weightLimit := (weightLimit), weightInitial := (weightInitial), inputLimit := (inputLimit), errorLimit := (errorLimit), plasticityScale := (plasticityScale), plasticityCeiling := (plasticity 0), plasticityFloor := (plasticityFloor), plasticityHalfLife := (plasticityHalfLife), stepLimit := (stepLimit)}), slot := (record SlotPlasticity {contexts := (slotContexts), probabilityLimit := (probabilityLimit), countLimit := (countLimit), rateNumerator := (rateNumerator), rateCeiling := (slotRate 0), rateFloor := (slotRate (countLimit))}), refinement := (record RefinementPlasticity {maps := (refinementMaps), points := (refinementPoints), probabilityLimit := (probabilityLimit), rateShift := (refinementShift)})}) +} +\end{semanticmodule} +\end{lexlean} diff --git a/src/Uorc/Registry.lex.tex b/src/Uorc/Registry.lex.tex index 17e9d622..b5d1b6d4 100644 --- a/src/Uorc/Registry.lex.tex +++ b/src/Uorc/Registry.lex.tex @@ -208,5 +208,12 @@ 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: neuromorphicStandard, + parameters: [], + result: ConformanceRow, + body: (record ConformanceRow {id := "UC-NEU-01", level := "build", suite := "neuromorphic-standard", statement := "The ncm coder's plasticity is stated as the Prism neuromorphic standard in Uorc.Neuromorphic, with kernel-checked bounds: every mixer weight stays within plus or minus 2^22 under the bounded Hebbian rule, potentiation never lowers and depression never raises a weight, the plasticity lies between 24 and 128 per 65536 (128 at the first byte, 24 in the limit), one bit's weight change is at most 16376 and every product fits a 32-bit lane, a context slot never steps past its gap to the coded bit and consolidates at count 127, and every probability-map point stays within 16 bits; the native coder reads the model's constants.", given := "the Uorc.Neuromorphic module and the native ncm coder's plasticity constants", when := "the locked SDK verifies the module and the native test reads the module's constants and theorem inventory", expected := "every bound theorem is kernel-checked and every native plasticity constant equals the model's", evidenceKind := "kernel_theorem", researchDisposition := "not_measured"}) +} \end{semanticmodule} \end{lexlean} diff --git a/vendor/hologram-brand/MANIFEST.sha256 b/vendor/hologram-brand/MANIFEST.sha256 new file mode 100644 index 00000000..65000e45 --- /dev/null +++ b/vendor/hologram-brand/MANIFEST.sha256 @@ -0,0 +1,10 @@ +662ee16ec308a8b8a722acc8580e68efd7b194a26a619e7677c41924beed0cab README.md +d9e8c29fdd348edde2a4f9aae438e569dd165bbbdebda78495824a2d9aaa67e8 fonts/Archivo-SemiBold.woff2 +b0a0867cda44efef4529a4b13ce37fd9fd6e1597708615287542a51bc7452ab4 fonts/Geist-Medium.woff2 +d8bce822db092746889bcf3f57350b41f53708b025458fe7af30729ec4ce0df2 fonts/Geist-Regular.woff2 +b1e6a1dd2122485d0a1f3a8d30a45443aa9453224f83018bec35f8266bc77915 fonts/Geist-SemiBold.woff2 +e4507fb4fb5f832fbbb6c06aea4206274ba3083007f23fa8cbc0e87a10acf95b fonts/GeistMono-Regular.woff2 +108b4e57c9c796d3d38d0428ca7ee39de47ad93187302718d9b2d8864b9b716b fonts/OFL-Archivo.txt +c683bfbcc7e087f5d37a54ef628f10387c451a83ddc459b151403a164ac46c90 fonts/OFL-Geist.txt +4bcecd524095589911adbe367370de2186d51732f75dabfb2ab19bed8de96dfb icon-512.png +cd3bde2a1ed983c5c671a2edd29190ba952b70b7ce3943dd8814a5a908c70df2 icon.svg diff --git a/vendor/hologram-brand/README.md b/vendor/hologram-brand/README.md new file mode 100644 index 00000000..549e4d19 --- /dev/null +++ b/vendor/hologram-brand/README.md @@ -0,0 +1,10 @@ +# Hologram brand assets + +Vendored from https://github.com/Hologram-Technologies/hologram-brand-kit at +`f14a9d8cfe6bce14fc8a6ff09ac0f99b01e300be` (`develop`). Every Prism browser closure (closure v2) carries these +files: the Geist, Geist Mono and Archivo web fonts under the SIL Open Font +License 1.1 (the licence texts ship beside them), and an app icon composed +from the kit's white logomark on the warm dark ground `#151312`. + +Regenerate only from a pinned kit commit, then update MANIFEST.sha256 and +the `hologram-brand` row of `model/dependencies.toml`. diff --git a/vendor/hologram-brand/fonts/Archivo-SemiBold.woff2 b/vendor/hologram-brand/fonts/Archivo-SemiBold.woff2 new file mode 100644 index 00000000..2e56f9fd Binary files /dev/null and b/vendor/hologram-brand/fonts/Archivo-SemiBold.woff2 differ diff --git a/vendor/hologram-brand/fonts/Geist-Medium.woff2 b/vendor/hologram-brand/fonts/Geist-Medium.woff2 new file mode 100644 index 00000000..3a62ba43 Binary files /dev/null and b/vendor/hologram-brand/fonts/Geist-Medium.woff2 differ diff --git a/vendor/hologram-brand/fonts/Geist-Regular.woff2 b/vendor/hologram-brand/fonts/Geist-Regular.woff2 new file mode 100644 index 00000000..d98d41cc Binary files /dev/null and b/vendor/hologram-brand/fonts/Geist-Regular.woff2 differ diff --git a/vendor/hologram-brand/fonts/Geist-SemiBold.woff2 b/vendor/hologram-brand/fonts/Geist-SemiBold.woff2 new file mode 100644 index 00000000..ea20a791 Binary files /dev/null and b/vendor/hologram-brand/fonts/Geist-SemiBold.woff2 differ diff --git a/vendor/hologram-brand/fonts/GeistMono-Regular.woff2 b/vendor/hologram-brand/fonts/GeistMono-Regular.woff2 new file mode 100644 index 00000000..f76e5531 Binary files /dev/null and b/vendor/hologram-brand/fonts/GeistMono-Regular.woff2 differ diff --git a/vendor/hologram-brand/fonts/OFL-Archivo.txt b/vendor/hologram-brand/fonts/OFL-Archivo.txt new file mode 100644 index 00000000..8597481e --- /dev/null +++ b/vendor/hologram-brand/fonts/OFL-Archivo.txt @@ -0,0 +1,93 @@ +Copyright 2020 The Archivo Project Authors (https://github.com/Omnibus-Type/Archivo) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/vendor/hologram-brand/fonts/OFL-Geist.txt b/vendor/hologram-brand/fonts/OFL-Geist.txt new file mode 100644 index 00000000..04e95fc5 --- /dev/null +++ b/vendor/hologram-brand/fonts/OFL-Geist.txt @@ -0,0 +1,93 @@ +Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file diff --git a/vendor/hologram-brand/icon-512.png b/vendor/hologram-brand/icon-512.png new file mode 100644 index 00000000..4f69d97d Binary files /dev/null and b/vendor/hologram-brand/icon-512.png differ diff --git a/vendor/hologram-brand/icon.svg b/vendor/hologram-brand/icon.svg new file mode 100644 index 00000000..1caa0802 --- /dev/null +++ b/vendor/hologram-brand/icon.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/style.css b/web/app.css similarity index 59% rename from web/style.css rename to web/app.css index d8bfc73b..abd930c3 100644 --- a/web/style.css +++ b/web/app.css @@ -1,10 +1,15 @@ -:root { --bg: #fbfbfa; --fg: #1d1d1b; --muted: #5d5d58; --line: #d9d8d3; --accent: #2f5bd3; --code: #f1f0ec; } -@media (prefers-color-scheme: dark) { :root { --bg: #151514; --fg: #ecebe6; --muted: #a3a29b; --line: #34332f; --accent: #8aa8ff; --code: #22211f; } } +@font-face{font-family:Geist;src:url(Geist-Regular.woff2) format("woff2");font-weight:400;font-style:normal;font-display:swap} +@font-face{font-family:Geist;src:url(Geist-Medium.woff2) format("woff2");font-weight:500;font-style:normal;font-display:swap} +@font-face{font-family:Geist;src:url(Geist-SemiBold.woff2) format("woff2");font-weight:600 700;font-style:normal;font-display:swap} +@font-face{font-family:"Geist Mono";src:url(GeistMono-Regular.woff2) format("woff2");font-weight:400 600;font-style:normal;font-display:swap} +@font-face{font-family:Archivo;src:url(Archivo-SemiBold.woff2) format("woff2");font-weight:500 700;font-style:normal;font-display:swap} +:root { color-scheme: light dark; --bg: #f3f3ee; --fg: #1d1d1b; --muted: #5d5d58; --line: #d9d8d3; --accent: #2f5bd3; --code: #f1f0ec; } +@media (prefers-color-scheme: dark) { :root { --bg: #151312; --fg: #ecebe6; --muted: #a3a29b; --line: #34332f; --accent: #8aa8ff; --code: #22211f; } } * { box-sizing: border-box; } -body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; } +body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 Geist, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; } header, main { max-width: 52rem; margin: 0 auto; padding: 0 16px; } header { padding-top: 2.5rem; } -h1 { font-size: 2rem; margin: 0 0 .5rem; letter-spacing: -.01em; } +h1 { font-family: Archivo, Geist, system-ui, sans-serif; font-weight: 600; font-size: 2rem; margin: 0 0 .5rem; letter-spacing: -.03em; } h2 { font-size: 1.25rem; margin: 2.5rem 0 .75rem; border-top: 1px solid var(--line); padding-top: 1.5rem; } h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; } p { color: var(--fg); max-width: 44rem; } @@ -17,6 +22,7 @@ button.secondary { background: transparent; color: var(--accent); } button:disabled { opacity: .45; cursor: not-allowed; } button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } a { color: var(--accent); } +code, pre { font-family: "Geist Mono", ui-monospace, monospace; } pre { background: var(--code); padding: .75rem 1rem; border-radius: 6px; overflow-x: auto; font-size: .9rem; } table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; } th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); } diff --git a/web/app.js b/web/app.js index c643182c..9f5c88b6 100644 --- a/web/app.js +++ b/web/app.js @@ -21,8 +21,8 @@ const steps = () => BigInt(Math.max(0, Math.floor(Number($("steps").value) || 0) const tick = () => new Promise((resolve) => setTimeout(resolve, 20)); try { - const uorc = await load("./uorc.wasm"); - fetch("version.txt").then((r) => r.ok ? r.text() : "").then((v) => { if (v) $("version").textContent = `Release ${v.trim()}`; }); + const uorc = await load("./uorc_bg.wasm"); + fetch("provenance.json").then((r) => r.ok ? r.json() : {}).then((p) => { if (p.version) $("version").textContent = `Release ${p.version}`; }).catch(() => {}); for (const id of ["compress", "decompress", "inspect", "verify"]) $(id).disabled = false; status.textContent = "Ready. Choose a file, or run an example below."; diff --git a/web/index.html b/web/index.html index 259b441d..7944b16a 100644 --- a/web/index.html +++ b/web/index.html @@ -4,7 +4,8 @@ uorc client - + +
@@ -88,7 +89,7 @@

Rust library

uorc::compress_stream(reader, writer, uorc::DEFAULT_STEPS, uorc::default_threads())?;

JavaScript (this page's module)

import { load } from "./uorc.js";
-const uorc = await load("./uorc.wasm");
+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, ... }]