interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

GitHub aien-dev/omega-mv#811 (code only)

closed derived 759b159128e41c3c #811

Imported from GitHub aien-dev/omega-mv#811 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 07c78e3f7efc9ac9c63bc3ba65c1a74cbb563ab4 · Head 1f73b7c3c5fef6e917cea8a421600703c7eecb0e

Fetch it

A git bundle of the pull request's head, 23244 bytes.

curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/759b159128e41c3c.bundle -o 759b159128e41c3c.bundle
git fetch 759b159128e41c3c.bundle refs/pull/811/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/omega-mv
811
1f73b7c3c5fef6e917cea8a421600703c7eecb0e
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":811,"url":"https://github.com/aien-dev/omega-mv/pull/811","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:38:39Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index ffda09b20..6b3977e9a 100644
--- a/.crumb
+++ b/.crumb
@@ -96,14 +96,14 @@
         }
       ],
       "children_root": "sha256:6e0949f91ab0352c63f7da31d9a95bc178cfc188bb15062a7efd1330d996e34b",
-      "compiled_at": "2026-10-26T17:46:27Z",
+      "compiled_at": "2026-10-26T18:17:43Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:e88d7fc9340129db2fbc4afc959f6a9cef879fa1143f8906b65878b119a05f25",
+      "digest": "sha256:45916e7fd6ec4edbcd210eeabcc545cc3a6dd9804eb6fe354cefd91a8fc6282e",
       "evidence_files": 12448,
       "evidence_root": "sha256:6a7f22f217cc5cfd8bf239c891f08fa4d4286883a3a43299addeb7bcf8dc3125",
-      "files": 16990,
-      "generated_at_commit": "80e409a1fefede818e620f746120095e9a9bcf34",
-      "source_tree": "sha256:0b10f0a53b24f6c94a07266738d39939a02d5f191ceb1ab5ff5e20903980351a"
+      "files": 16999,
+      "generated_at_commit": "40bcecd6d9016986d4234e02c719b3c42f82d292",
+      "source_tree": "sha256:6d9a0957c6236c68066328a2034c309b41daac6427ee4ae35ddba0f0444a6ba2"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/seed/wasm/.crumb b/seed/wasm/.crumb
index 59b8c2b38..1acdff4bd 100644
--- a/seed/wasm/.crumb
+++ b/seed/wasm/.crumb
@@ -3,14 +3,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-26T13:58:17Z",
+      "compiled_at": "2026-10-26T18:17:43Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:724549b38b297b5f073f351a21b2f4fbbc6e74b839d185c9a6f5e900bfc45f2a",
+      "digest": "sha256:25eb14465d7445a19fca872ff1c2efaec2c74c23c163a41ec4c5e3c1b1310b05",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 7,
-      "generated_at_commit": "3901efa4b43bfc0b0921590484af18a5c5ec3dbb",
-      "source_tree": "sha256:8da664870845ba63cf39926aced75587a1902f19049b194ba5ea94c8becffee8"
+      "files": 16,
+      "generated_at_commit": "40bcecd6d9016986d4234e02c719b3c42f82d292",
+      "source_tree": "sha256:8abdc72b187a629ee994d31825ffa92fd2c9e6cb979c8c23f4edf5c485baa1d8"
     }
   },
   "layer": "seed",
diff --git a/seed/wasm/renderer/PORTING.md b/seed/wasm/renderer/PORTING.md
new file mode 100644
index 000000000..3c33981ca
--- /dev/null
+++ b/seed/wasm/renderer/PORTING.md
@@ -0,0 +1,178 @@
+# Porting Allen's C scene to seeded Omega and the IR memory backend
+
+Status, kept separate:
+
+| Item | Status |
+|---|---|
+| `glow.om` and its fixture/oracle harness | IMPLEMENTED; register-heavy expressions split into bounded helpers |
+| Native parity (`gate-glow.sh` sections 1-3) | EXERCISED on Linux AArch64 with pinned `befb8199…8a1d`: full buffers identical (55,628 bytes, pixel difference 0), deterministic output, three mutants differ |
+| Wasm parity (`GLOW_WASM=1`, section 4) | NOT_RUN. It needs the IR memory backend. At this source, IR mode refuses `global` (OMEGESE 11, error 9). |
+| The rest of the scene | PROPOSED: only the mapping below exists |
+| Memory wire format and JS ABI | PENDING: the parent's spec PR. Section 6 lists what it must define. |
+
+Nothing here is browser integration, hardware qualification or deployment.
+
+## 1. Source pin
+
+The C reference is aien-dev/aienux `da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c`, `native/kernel/ui/`. The same bytes are
+copied unchanged into aien-dev/aienos.com `om/allen-scene/native/` and bound there by `native.sha256`.
+`native-pin.sha256` in this directory repeats the four digests the glow oracle compiles
+(`paint.c`, `paint.h`, `allen_font.c`, `allen_font.h`). These are copies of the recorded digests, not new
+measurements. `gate-glow.sh` checks them before it compiles anything. If `AIENUX_GIT` is set, it also
+byte-compares the files with the aienux commit.
+
+## 2. How the glow parity works
+
+1. `oracle-glow.c` links the unchanged `paint.c` and `allen_font.c` and calls the original
+   `ck_glow`. Only the fixture lives in that file: the case reader, the canvas reset and the gradient
+   law it shares with `background.om`. The oracle is built with UBSan in fatal mode, so a case that
+   reaches C undefined behaviour stops the gate instead of producing a reference.
+2. `glow-cases.tsv` is the single list of cases. It is read by the C oracle, by the gate's generator
+   for the native `main`, and by `compare-glow.js`. Every frame's full canvas is compared byte for
+   byte as little-endian uint32 pixels, including the pixels the glow never touches.
+3. The cases cover:
+   - an unclipped and a clipped gradient background;
+   - a glow cut by the clip rectangle on the right and bottom;
+   - a glow lying entirely outside the clip;
+   - centres off the canvas at negative coordinates, which exercises arithmetic `>>`;
+   - channel saturation in `ck_add`;
+   - `a = 4294967295`, which exercises uint32 wrap in `w * a` and `ck_ch(c) * a`;
+   - a sub-pixel radius;
+   - the no-op guards `r = 0`, `r < 0` and `a = 0`;
+   - a 37x23 canvas, so a stride that confuses w and h is caught.
+
+   Colours are copied from the pinned callers.
+4. Determinism: the oracle runs twice, omc compiles twice, irwasm translates twice, and each pair is
+   compared.
+5. Mutants: the gate rewrites one exact line of `glow.om` for each of three mutants and requires the
+   result to run and to differ from the oracle. The mutants are the falloff shift 32 to 33, the
+   saturation 255 to 254, and dropping the right clip. With `GLOW_WASM=1`, `compare-glow.js` must
+   also exit 1 with `pixel mismatch` for each mutant.
+
+`compare-glow.js` reads pixels through the scalar export `fbget`, so it does not assume where the
+backend places `fb`. Once the ABI is agreed, a direct linear-memory comparison can be added beside it.
+
+Commands (nice, ionice idle, at most -j2; the full command requires backend integration):
+
+```sh
+ALLEN_NATIVE_DIR=/path/to/pinned/native nice -n 19 ionice -c3 sh seed/wasm/renderer/gate-glow.sh            # native; exits 3 (wasm NOT_RUN)
+GLOW_WASM=1 ALLEN_NATIVE_DIR=/path/to/pinned/native nice -n 19 ionice -c3 sh seed/wasm/renderer/gate-glow.sh # full
+```
+
+## 3. C-to-Omega rules used by `glow.om`
+
+Every rule below holds in the existing language at this source (`seed/out/omc` `befb8199…8a1d`).
+
+| C | Omega |
+|---|---|
+| `int32_t`, `uint32_t`, `int64_t`, `uint64_t` | `int`, `uint`, `long`, `ulong`. There are no implicit conversions, so each one is written out (`long x`). |
+| `ck_canvas *cv` (pointer to pixels) | `global fb uint 65536`. A global is named directly and is never passed (error 19). Canvas `w` and `h` live in the cells `cf 0` and `cf 1`. |
+| `const ck_rect *clip` | The cells `cf 2..5`, set by `fbclip`. IR mode refuses structs, so there are no struct globals. |
+| more than 6 parameters (`ck_glow` has 7) | Canvas and clip become state that is set earlier. The export takes five scalars. |
+| per-call constants (`r2`, `inv`, the fitted span) | The cells `gl 0..5`. These keep each helper under the 16-register pool (error 12) and the 6-parameter limit. |
+| `continue` | An `if` around the rest of the body. IR mode refuses `continue` (error 3). |
+| `for (...)` | `while ... bound N`. Each N comes from the canvas bound w, h <= 65536 or from the isqrt count of 32, and is written in a `note`. |
+| early `return` | An enclosing `if`, because a typed function's `end` must not be reachable (error 18). |
+| `>>` on signed values | `shr` on `int` or `long`, which keeps the sign (floor), as GCC and Clang do. |
+| uint32 multiply wrap | `mul` on `uint`, which wraps mod 2^32. |
+| signed overflow (undefined in C) | Trap 1. Fixtures must stay in the defined range, and UBSan proves the oracle did. |
+| `(uint32_t)` and `(int32_t)` casts | Checked conversions (trap 5). Every cast in `ck_glow` provably fits: `f` < 2^9, `isqrt(r2 - dy2)` <= r. |
+| helper order | Callee before caller, because IR mode calls only earlier functions. |
+| `CK_RGB` | `ckrgb`, so every colour stays the literal triple copied from C. |
+
+Names: locals and globals have at most 8 characters, and none of them may be a keyword or a host word
+(checked against `seed/omc/genkw.awk`).
+
+## 4. Mapping the rest of the scene (PROPOSED)
+
+These units total 8,478 lines (`wc -l`), counting the pinned native files plus `adapter.c`. Each item
+lists what the existing language already covers and what it does not. Gaps are stated as gaps, not
+solved here.
+
+- **`paint.h` inlines** (`ck_scale`, `ck_mix`, `ck_smooth`, `ck_ease_out`, `ck_prog`, `ck_cover`, `ck_clip`
+  family): scalar functions only. These can go to IR v1 today, and each needs an exact-result table row
+  against the C.
+- **`paint.c` tables** (`sin_t[4097]`, `exp_t[4096]`, `log_t[257]`, lazily filled by `setup()`): globals
+  plus an explicit `setup` export with a `ready` cell. The generation loops port as written. The
+  `step[14]` atan2 constants and the `ck_hash` multipliers are C hex and decimal literals: copy them as
+  decimals, and convert any hex value with Wolfram, quoting the query beside the code.
+  `__builtin_clzll` in `ck_log2_q16` becomes a bounded loop of at most 64 passes.
+- **`ck_thread`, `plot`, `ck_sd_rrect`**: the same pattern as glow. Clip and canvas come from the state
+  cells, and the per-call state goes in a cell global.
+- **`allen_font.c`**: the glyph strings are `text` in program mode, but IR mode refuses `text`
+  (OMEGESE 11). The glyph cache is a `pool_used` arena, which needs a fixed global pool (there is no
+  heap; decision 24). How read-only data enters the module is a memory-spec decision (section 6).
+- **`mind.c`** (120 points, 300 edges, 64 sparks): fixed-size arrays become globals, and its draw is a
+  sequence of `ck_glow` and `ck_thread` calls. `static const` arrays (`spins`, `squeezes`, `hearts`) have
+  the same data-entry question as the font.
+- **`night.c`**: the caller supplies memory (`ck_night_mem_bytes`, `void *mem`, `ck_night_picture_take`).
+  That has to become fixed globals sized for the bounded browser resolution, because Omega has no
+  address word and no heap. The `bayer[16]`, `band_t` and `pow2_t` tables are handled like the
+  `paint.c` tables.
+- **`flow.c`**: `ck_flow_mark(ck_flow *, void (*mark)(ck_rect))` takes a function pointer, and Omega has
+  no function values. The proposal is to write the dirty rectangles into a fixed global list that the
+  caller reads. That changes the interface, so it needs its own parity check.
+- **`sky_real.c` and `sky_data.c`** (5,610 lines of catalogue data): bulk read-only data. Its attribution
+  terms in `provenance.txt` travel with it. How the data is placed in memory waits on section 6.
+- **`chirp.c`** (audio): table setup plus `int16_t` output fills an output buffer global.
+- **`adapter.c`**: the web entry and lifecycle. Its scalar exports (`scene_init`, `scene_step`,
+  `scene_draw` and so on) map directly to scalar Omega exports. `scene_pixels()` returns an address,
+  which has no raw-address source spelling; the JS side obtains the region offset through the ABI in section 6.
+
+Capacity facts at this source: the IR wire allows at most 32 functions per unit and
+4,096 instructions per function, but the current omc IR producer has a smaller
+per-function instruction table; the native register allocator has 16 registers.
+Do not infer that a wire-format limit is the producer's implemented capacity.
+The full scene needs explicit capacity qualification; globals shared across
+separately translated units are not part of this memory profile.
+
+## 5. Recipe for each further primitive
+
+1. Pin the C function and each helper it reaches. Add their digests to `native-pin.sha256`.
+2. Port it by the rules in section 3, keeping helpers before their callers.
+3. Extend the case list. Make the oracle call the unchanged C, compare full buffers, run each artifact
+   twice, and add at least one one-line mutant that must differ.
+4. Run native parity first, then wasm parity, and report each result by its status word.
+
+## 6. Memory ABI and JavaScript integration
+
+The contract is OSC wire **v7**, specified in
+[`spec/one-layer-format.md` section 10](../../../../spec/one-layer-format.md),
+merged in c5d981041bcca3f4c145431ae7e2864f401cb2e1. "IR v2" was the milestone
+name, not its wire version. Backend qualification remains separate from this
+merged specification.
+
+`global NAME T N` declares a class-0 region with no initial data. Its packed,
+naturally aligned elements start at zero once per module instance and persist
+between calls. `get` and `put` lower to RLOAD and RSTORE, with an element-count
+bounds check before address arithmetic. A negative or wide out-of-range index
+traps rather than wrapping to a wasm32 address. `len` is the element count.
+
+`text NAME "bytes"` declares a class-2 u8 region initialized by an active data
+segment, with no implicit terminator. Generated Omega cannot write it.
+JavaScript holding exported memory can write it: source read-only storage is
+not an isolation boundary. Local `new` arrays use class 1 and RINIT on each
+invocation; they have no exported address and cannot expose prior-call contents
+through valid Omega instructions.
+
+The import-free module exports `memory`, each scalar function, and an immutable
+i32 global `region.NAME` for each module region. Treat the global value as an
+unsigned byte offset; never hardcode layout offsets or assume regions are
+adjacent. Memory has exactly the whole 64 KiB pages required for all backing,
+with maximum equal to initial size. It never grows. Instances do not share
+globals, and separately translated units have no shared-global linking ABI.
+Source global pools retain the 1 GiB aggregate limit; local arrays retain
+the 4 MiB aggregate limit. Backend capacity refusals are independent limits,
+not permission to truncate an oversized region.
+
+For the framebuffer, JavaScript obtains `region.fb`, invokes `fbsize`, then
+calls `fbgrad` and `ckglow` explicitly. Read pixels using a `DataView` on
+`exports.memory.buffer` and `getUint32(byteOffset, true)` for little-endian
+access; the region base is `exports["region.fb"].value >>> 0`.
+The renderer stores packed `0x00RRGGBB` words, not browser RGBA bytes: a canvas
+consumer must extract the color channels and supply its own alpha before
+passing bytes to `ImageData`. Omega installs no animation loop or JS services.
+
+The full-buffer oracle uses `fbget` independently of region placement.
+Memory-ABI qualification additionally compares module-region bytes through
+the exported offsets; scalar-only agreement does not establish that ABI.
diff --git a/seed/wasm/renderer/background.om b/seed/wasm/renderer/background.om
new file mode 100644
index 000000000..d79648c3e
--- /dev/null
+++ b/seed/wasm/renderer/background.om
@@ -0,0 +1,30 @@
+note background.om: fixture-only gradient background for the glow parity cases; not a scene primitive.
+note It is concatenated after glow.om. It paints only the clip rectangle intersected with the canvas,
+note so pixels outside the clip stay 0 and every later glow lands on known non-zero light.
+note Law (repeated in oracle-glow.c): r = (x*7) and 255, g = (y*11) and 255, b = ((x+y)*3) and 255.
+fn bgpix x int y int to uint
+r = and uint mul x 7 255
+g = and uint mul y 11 255
+b = and uint mul add x y 3 255
+ret ckrgb r g b
+end
+fn bgstore x int y int to void
+p = add mul ulong y ulong get cf 0 ulong x
+put fb p bgpix x y
+end
+note Row and column counts are at most canvas h and w, each <= 65536.
+fn fbgrad to void
+x0 = imax get cf 2 0
+y0 = imax get cf 3 0
+x1 = imin add get cf 2 get cf 4 get cf 0
+y1 = imin add get cf 3 get cf 5 get cf 1
+y = y0
+while lt y y1 bound 65536
+x = x0
+while lt x x1 bound 65536
+bgstore x y
+x = add x 1
+end
+y = add y 1
+end
+end
diff --git a/seed/wasm/renderer/compare-glow.js b/seed/wasm/renderer/compare-glow.js
new file mode 100644
index 000000000..fad019406
--- /dev/null
+++ b/seed/wasm/renderer/compare-glow.js
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: Apache-2.0
+// Verification oracle only: reads artifacts; never generates IR, wasm, or native code.
+// Usage: node compare-glow.js glow.wasm glow-cases.tsv oracle.bin
+// Replays every case through the module's scalar exports and compares the full
+// canvas of every frame, byte for byte, with the pinned C oracle's output.
+// Pixels are read back through the scalar export fbget, so this check does not
+// depend on where the memory backend places fb; a direct linear-memory view is
+// for the parent to add once the memory ABI is agreed.
+// Exit 0 identical, 1 pixel or length mismatch, 2 usage or module refusal.
+'use strict';
+const fs = require('node:fs');
+const [wasmPath, table, oraclePath] = process.argv.slice(2);
+if (!oraclePath) { console.error('usage: compare-glow.js glow.wasm glow-cases.tsv oracle.bin'); process.exit(2); }
+const bytes = fs.readFileSync(wasmPath);
+if (!WebAssembly.validate(bytes)) { console.error('invalid wasm'); process.exit(2); }
+const module = new WebAssembly.Module(bytes);
+if (WebAssembly.Module.imports(module).length) { console.error('unexpected import'); process.exit(2); }
+const ex = new WebAssembly.Instance(module).exports;
+for (const name of ['fbsize', 'fbclip', 'fbgrad', 'ckglow', 'fbget']) {
+  if (typeof ex[name] !== 'function') { console.error(`missing export ${name}`); process.exit(2); }
+}
+const oracle = fs.readFileSync(oraclePath);
+const frames = [];
+let frame = null;
+const dump = () => {
+  if (!frame) return;
+  const out = Buffer.alloc(frame.w * frame.h * 4);
+  for (let i = 0; i < frame.w * frame.h; i++) out.writeUInt32LE(ex.fbget(i) >>> 0, i * 4);
+  frames.push({ name: frame.name, bytes: out });
+};
+for (const line of fs.readFileSync(table, 'utf8').split('\n')) {
+  if (!line || line.startsWith('#')) continue;
+  const [op, ...f] = line.split('\t');
+  const n = f.map(Number);
+  if (op === 'frame') { dump(); frame = { name: f[0], w: Number(f[1]), h: Number(f[2]) }; ex.fbsize(frame.w, frame.h); }
+  else if (!frame) { console.error('case before frame'); process.exit(2); }
+  else if (op === 'clip') ex.fbclip(n[0], n[1], n[2], n[3]);
+  else if (op === 'grad') ex.fbgrad();
+  else if (op === 'glow') ex.ckglow(n[0], n[1], n[2], ((n[3] << 16) | (n[4] << 8) | n[5]) >>> 0, n[6] >>> 0);
+  else { console.error(`unknown case ${op}`); process.exit(2); }
+}
+dump();
+const all = Buffer.concat(frames.map(f => f.bytes));
+if (all.length !== oracle.length) {
+  console.error(`length mismatch wasm=${all.length} oracle=${oracle.length}`);
+  process.exit(1);
+}
+let at = 0;
+for (const f of frames) {
+  const want = oracle.subarray(at, at + f.bytes.length);
+  if (!want.equals(f.bytes)) {
+    for (let i = 0; i < f.bytes.length; i += 4) {
+      if (want.readUInt32LE(i) !== f.bytes.readUInt32LE(i)) {
+        console.error(`pixel mismatch frame=${f.name} index=${i / 4} wasm=${f.bytes.readUInt32LE(i)} oracle=${want.readUInt32LE(i)}`);
+        break;
+      }
+    }
+    process.exit(1);
+  }
+  at += f.bytes.length;
+}
+console.log(`PASS glow wasm frames=${frames.length} bytes=${all.length} identical to pinned C oracle`);
diff --git a/seed/wasm/renderer/gate-glow.sh b/seed/wasm/renderer/gate-glow.sh
new file mode 100755
index 000000000..0ca2486fd
--- /dev/null
+++ b/seed/wasm/renderer/gate-glow.sh
@@ -0,0 +1,129 @@
+#!/bin/sh
+# Host-only glow parity gate. Referees only: the pinned original C ck_glow
+# (oracle-glow.c links it unchanged) and Node as a read-only wasm executor.
+# Neither generates any Omega output.
+#   ALLEN_NATIVE_DIR  directory holding the pinned paint.c paint.h allen_font.c
+#                     allen_font.h (checked against native-pin.sha256)
+#   AIENUX_GIT        optional aienux clone; also byte-compares those files
+#                     with commit da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c
+#   GLOW_WASM=1       run the wasm half; set only once the IR memory backend
+#                     is integrated. Unset: wasm is NOT_RUN and the gate exits 3.
+# Exit 0 all PASS, 1 FAIL, 3 NOT_RUN (missing prerequisite or wasm half off).
+set -eu
+cd "$(dirname "$0")/../../.."
+R=seed/wasm/renderer
+B=build/seed/wasm/renderer
+mkdir -p "$B"
+fail() { printf 'FAIL %s\n' "$*"; exit 1; }
+quiet() { nice -n 19 ionice -c3 "$@"; }
+[ "$(uname -m)" = aarch64 ] || { echo 'NOT_RUN requires AArch64 Linux'; exit 3; }
+command -v cc >/dev/null || { echo 'NOT_RUN requires a host C compiler for the oracle'; exit 3; }
+[ -n "${ALLEN_NATIVE_DIR:-}" ] || { echo 'NOT_RUN set ALLEN_NATIVE_DIR to the pinned native sources'; exit 3; }
+N=$(cd "$ALLEN_NATIVE_DIR" && pwd)
+OMC=seed/out/omc
+# Keep equal to the pin in seed/wasm/gate-irwasm.sh.
+pin=befb8199db8c4bca188a494dfaac2a6f0ee5c36fcea11188c75666c55fce8a1d
+[ "$(sha256sum "$OMC" | cut -d ' ' -f 1)" = "$pin" ] || fail 'compiler pin differs'
+printf 'SOURCE %s\n' "$(git rev-parse HEAD)"
+printf 'COMPILER %s\n' "$pin"
+uname -sm
+(cd "$N" && sha256sum -c "$OLDPWD/$R/native-pin.sha256") || fail 'native sources differ from pin'
+if [ -n "${AIENUX_GIT:-}" ]; then
+    for f in paint.c paint.h allen_font.c allen_font.h; do
+        git -C "$AIENUX_GIT" show "da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c:native/kernel/ui/$f" > "$B/aienux-$f"
+        cmp "$B/aienux-$f" "$N/$f" || fail "$f differs from aienux da55660"
+    done
+    echo 'PASS native sources equal aienux da55660 native/kernel/ui'
+else
+    echo 'NOT_RUN aienux blob comparison (AIENUX_GIT unset); digest pin checked'
+fi
+
+# 1. Oracle: the pinned C ck_glow, undefined behaviour fatal, run twice.
+quiet cc -std=gnu11 -O1 -fsanitize=undefined -fno-sanitize-recover=all -I "$N" \
+    "$R/oracle-glow.c" "$N/paint.c" "$N/allen_font.c" -o "$B/oracle"
+quiet "$B/oracle" "$R/glow-cases.tsv" > "$B/oracle.bin" || fail "oracle exit $?"
+quiet "$B/oracle" "$R/glow-cases.tsv" > "$B/oracle.again.bin" || fail 'oracle rerun'
+cmp "$B/oracle.bin" "$B/oracle.again.bin" || fail 'oracle nondeterministic'
+want=$(awk -F '\t' '$1 == "frame" { s += $3 * $4 * 4 } END { print s + 0 }' "$R/glow-cases.tsv")
+[ "$(wc -c < "$B/oracle.bin")" = "$want" ] || fail "oracle wrote $(wc -c < "$B/oracle.bin") bytes, want $want"
+echo "PASS oracle bytes=$want deterministic, no undefined behaviour"
+
+# 2. Native Omega: the same cases as a generated main.
+awk -F '\t' '
+    /^#/ || NF == 0 { next }
+    $1 == "frame" { if (seen) print "fbdump"; seen = 1; printf "fbsize int %s int %s\n", $3, $4; next }
+    $1 == "clip"  { printf "fbclip int %s int %s int %s int %s\n", $2, $3, $4, $5; next }
+    $1 == "grad"  { print "fbgrad"; next }
+    $1 == "glow"  { printf "ckglow int %s int %s int %s ckrgb uint %s uint %s uint %s uint %s\n", $2, $3, $4, $5, $6, $7, $8; next }
+    { exit 2 }
+    END { print "fbdump" }
+' "$R/glow-cases.tsv" > "$B/main.body" || fail 'unknown case row'
+native() { # $1 glow source, $2 output stem
+    { cat "$1" "$R/background.om" "$R/native-runner.om"
+      printf 'fn main to int\n'; cat "$B/main.body"; printf 'ret 0\nend\n'; } > "$B/$2.om"
+    quiet "$OMC" < "$B/$2.om" > "$B/$2" 2> "$B/$2.err" || fail "$2 compile exit $?"
+    [ ! -s "$B/$2.err" ] || fail "$2 compiler stderr"
+    chmod +x "$B/$2"
+    set +e
+    quiet timeout 60 "$B/$2" > "$B/$2.bin"
+    rc=$?
+    set -e
+    [ "$rc" = 0 ] || fail "$2 run exit $rc"
+}
+native "$R/glow.om" native
+cp "$B/native" "$B/native.first"
+native "$R/glow.om" native
+cmp "$B/native" "$B/native.first" || fail 'native compile nondeterministic'
+cmp "$B/native.bin" "$B/oracle.bin" || fail 'native frames differ from pinned C ck_glow'
+echo "PASS native Omega glow frames identical to pinned C ck_glow bytes=$want"
+
+# 3. Mutants: each changes one line of glow.om and must still run but differ.
+mutate() { # $1 name, $2 exact line, $3 replacement
+    awk -v a="$2" -v b="$3" '$0 == a { $0 = b; c++ } { print } END { exit c != 1 }' \
+        "$R/glow.om" > "$B/glow-$1.om" || fail "mutant $1 anchor not found once"
+}
+mutate falloff 'f = sub uint 256 uint shr mul ulong d2 ulong get gl 1 32' \
+    'f = sub uint 256 uint shr mul ulong d2 ulong get gl 1 33'
+mutate saturate 'ret uint 255' 'ret uint 254'
+mutate clipright 'x1 = imin imin add shr add cx r 4 1 add get cf 2 get cf 4 get cf 0' \
+    'x1 = imin add shr add cx r 4 1 get cf 0'
+for m in falloff saturate clipright; do
+    native "$B/glow-$m.om" "mutant-$m"
+    [ "$(wc -c < "$B/mutant-$m.bin")" = "$want" ] || fail "mutant $m wrong length"
+    if cmp -s "$B/mutant-$m.bin" "$B/oracle.bin"; then fail "mutant $m escaped"; fi
+    echo "PASS native mutant $m differs from oracle"
+done
+
+# 4. Wasm through the IR memory backend.
+if [ "${GLOW_WASM:-0}" != 1 ]; then
+    echo 'NOT_RUN wasm half (GLOW_WASM unset: IR memory backend not integrated)'
+    printf 'GLOW NATIVE PASS bytes=%s mutants=3; WASM NOT_RUN\n' "$want"
+    exit 3
+fi
+command -v node >/dev/null || { echo 'NOT_RUN requires Node WebAssembly oracle'; exit 3; }
+node --version
+quiet "$OMC" < seed/wasm/irwasm.om > "$B/irwasm" 2> "$B/irwasm.err" || fail 'irwasm compile'
+[ ! -s "$B/irwasm.err" ] || fail 'irwasm compiler stderr'
+chmod +x "$B/irwasm"
+towasm() { # $1 glow source, $2 output stem
+    { printf 'ir\n'; cat "$1" "$R/background.om"; } > "$B/$2.input"
+    quiet "$OMC" < "$B/$2.input" > "$B/$2.ir" 2> "$B/$2.ir.err" || fail "$2 IR exit $?: $(cat "$B/$2.ir.err")"
+    quiet "$B/irwasm" < "$B/$2.ir" > "$B/$2.wasm" 2> "$B/$2.wasm.err" || fail "$2 irwasm exit $?: $(cat "$B/$2.wasm.err")"
+}
+towasm "$R/glow.om" glow
+cp "$B/glow.wasm" "$B/glow.first.wasm"
+towasm "$R/glow.om" glow
+cmp "$B/glow.wasm" "$B/glow.first.wasm" || fail 'wasm translation nondeterministic'
+quiet node "$R/compare-glow.js" "$B/glow.wasm" "$R/glow-cases.tsv" "$B/oracle.bin" || fail 'wasm frames differ'
+for m in falloff saturate clipright; do
+    towasm "$B/glow-$m.om" "mutant-$m"
+    set +e
+    quiet node "$R/compare-glow.js" "$B/mutant-$m.wasm" "$R/glow-cases.tsv" "$B/oracle.bin" > "$B/mutant-$m.log" 2>&1
+    rc=$?
+    set -e
+    [ "$rc" = 1 ] || fail "wasm mutant $m exit $rc instead of 1"
+    grep -q 'pixel mismatch' "$B/mutant-$m.log" || fail "wasm mutant $m failed for an unrelated reason"
+    echo "PASS wasm mutant $m rejected"
+done
+printf 'GLOW PASS native and wasm identical to pinned C ck_glow bytes=%s mutants=3\n' "$want"
+sha256sum "$R/glow.om" "$R/background.om" "$R/glow-cases.tsv" "$B/glow.wasm" "$B/native"
diff --git a/seed/wasm/renderer/glow-cases.tsv b/seed/wasm/renderer/glow-cases.tsv
new file mode 100644
index 000000000..0fdc23fb3
--- /dev/null
+++ b/seed/wasm/renderer/glow-cases.tsv
@@ -0,0 +1,37 @@
+# Glow parity cases: one source for the C oracle, the native Omega runner and the wasm harness.
+# frame NAME W H        new canvas, every pixel 0, clip = whole canvas; the previous frame is dumped
+# clip X Y W H          clip rectangle in pixels (C ck_rect)
+# grad                  fixture gradient inside clip and canvas (background.om)
+# glow CX CY R RED GREEN BLUE A   ck_glow; CX CY R in 16ths of a pixel; colour CK_RGB(RED, GREEN, BLUE)
+# Output: every frame's whole canvas, little-endian uint32 pixels, row-major, frames in order.
+# Colours are copied from the pinned callers (adapter.c lines 174-175, mind.c lines 228-265).
+frame	background	64	48
+clip	8	6	40	30
+grad
+frame	flash	64	48
+grad
+glow	520	392	300	200	210	255	85
+glow	520	392	100	255	240	224	256
+frame	clipped	64	48
+clip	8	6	40	30
+grad
+glow	700	500	420	255	210	170	230
+glow	40	40	50	255	236	214	256
+frame	edges	64	48
+grad
+glow	-100	-60	600	112	92	255	200
+glow	1100	800	500	60	74	210	52
+frame	saturate	32	24
+clip	4	4	20	12
+grad
+glow	256	192	320	255	250	240	4294967295
+glow	250	190	5	255	236	214	256
+glow	250	190	0	255	236	214	256
+glow	250	190	-3	255	236	214	256
+glow	250	190	200	255	236	214	0
+frame	stride	37	23
+clip	3	2	30	19
+grad
+glow	300	180	260	206	222	255	300
+glow	127	129	37	255	214	160	180
+glow	590	360	90	255	222	176	128
diff --git a/seed/wasm/renderer/glow.om b/seed/wasm/renderer/glow.om
new file mode 100644
index 000000000..313302962
--- /dev/null
+++ b/seed/wasm/renderer/glow.om
@@ -0,0 +1,161 @@
+note glow.om: ck_glow, the soft round light of Allen's scene, ported from the pinned C drawing kit
+note aien-dev/aienux da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c native/kernel/ui/paint.c lines 158-185
+note with paint.h ck_clip ck_add ck_ch ck_max ck_min and allen_font.c ck_af_isqrt lines 135-150.
+note Every helper precedes its callers (IR mode calls earlier functions only); no continue; no host
+note word. State lives in fixed globals; every export takes and returns scalars only.
+note fb  framebuffer: 0x00RRGGBB pixels, row-major, rows cf0 apart (C ck_canvas.px).
+note cf  int cells: 0 canvas w, 1 canvas h, 2 clip x, 3 clip y, 4 clip w, 5 clip h.
+note gl  long cells of one ckglow call: 0 r*r, 1 2^40 div r*r, 2 color, 3 a, 4 fitted x, 5 fitted last x.
+global fb uint 65536
+global cf int 6
+global gl long 6
+fn imax a int b int to int
+if gt a b
+ret a
+end
+ret b
+end
+fn imin a int b int to int
+if lt a b
+ret a
+end
+ret b
+end
+note C CK_RGB(r, g, b) = r << 16 | g << 8 | b
+fn ckrgb r uint g uint b uint to uint
+ret or or shl r 16 shl g 8 b
+end
+note One channel of C ck_add: ck_ch(d, s) + (ck_ch(c, s) * a >> 8), held at 255; uint wraps as in C.
+fn chadd d uint c uint s uint a uint to uint
+v = add and shr d s 255 shr mul and shr c s 255 a 8
+if gt v 255
+ret uint 255
+end
+ret v
+end
+fn ckadd d uint c uint a uint to uint
+ret or or shl chadd d c 16 a 16 shl chadd d c 8 a 8 chadd d c 0 a
+end
+note C ck_af_isqrt. bit starts at 4^31 and drops by a factor 4 per pass, so each loop ends within 32.
+fn isqrt v ulong to ulong
+n = v
+r = ulong 0
+b = shl ulong 1 62
+while gt b n bound 32
+b = shr b 2
+end
+while ne b 0 bound 32
+if ge n add r b
+n = sub n add r b
+r = add shr r 1 b
+else
+r = shr r 1
+end
+b = shr b 2
+end
+ret r
+end
+note C ck_canvas {px, w, h}: a w*h canvas inside fb, cleared to 0, clip reset to the whole canvas.
+note Trap 9 refuses a non-positive side or a canvas larger than fb (the C caller owns that check).
+fn fbsize w int h int to void
+if or le w 0 le h 0
+trap 9
+end
+n = mul ulong w ulong h
+if gt n len fb
+trap 9
+end
+put cf 0 w
+put cf 1 h
+put cf 2 0
+put cf 3 0
+put cf 4 w
+put cf 5 h
+i = ulong 0
+while lt i n bound 65536
+put fb i 0
+i = add i 1
+end
+end
+note C ck_rect clip {x, y, w, h}, copied as given; ckglow intersects it with the canvas.
+fn fbclip x int y int w int h int to void
+put cf 2 x
+put cf 3 y
+put cf 4 w
+put cf 5 h
+end
+fn fbget i uint to uint
+ret get fb ulong i
+end
+note A pixel or row centre offset in 16ths of a pixel, squared: C int64 dx * dx and dy * dy.
+fn sq v long to long
+ret mul v v
+end
+fn glblend p ulong w uint to void
+color = uint get gl 2
+alpha = shr mul w uint get gl 3 8
+put fb p ckadd get fb p color alpha
+end
+note C ck_glow inner body for pixel x of row y: d2, the falloff f, w = f^3 / 65536, then ck_add.
+fn glpix x int y int cx int dy2 long to void
+d2 = add sq sub add mul long x 16 8 long cx dy2
+if lt d2 get gl 0
+f = sub uint 256 uint shr mul ulong d2 ulong get gl 1 32
+w = shr mul shr mul f f 8 f 8
+p = add mul ulong y ulong get cf 0 ulong x
+glblend p w
+end
+end
+note C ck_glow row y: rows with dy^2 >= r^2 draw nothing; the span is cut to the fitted x range.
+note At most canvas w <= 65536 pixels per row.
+fn glrow y int cx int cy int to void
+dy2 = sq sub add mul long y 16 8 long cy
+if lt dy2 get gl 0
+half = int isqrt ulong sub get gl 0 dy2
+x0 = imax int get gl 4 shr sub cx half 4
+x1 = imin int get gl 5 shr add cx half 4
+x = x0
+while le x x1 bound 65536
+glpix x y cx dy2
+x = add x 1
+end
+end
+end
+fn glright cx int r int to int
+x1 = imin imin add shr add cx r 4 1 add get cf 2 get cf 4 get cf 0
+ret x1
+end
+fn glbottom cy int r int to int
+y1 = imin imin add shr add cy r 4 1 add get cf 3 get cf 5 get cf 1
+ret y1
+end
+fn glsetup r int color uint a uint to void
+put gl 0 mul long r long r
+put gl 1 long div shl ulong 1 40 ulong get gl 0
+put gl 2 long color
+put gl 3 long a
+end
+fn glrows cx int cy int y0 int y1 int to void
+y = y0
+while lt y y1 bound 65536
+glrow y cx cy
+y = add y 1
+end
+end
+note C ck_glow(cv, clip, cx, cy, r, color, a): centre and radius in 16ths of a pixel, colour added with
+note weight a * (1 - d^2/r^2)^3, only inside clip and canvas (C fit: clip, then canvas; the same set).
+note At most canvas h <= 65536 rows.
+fn ckglow cx int cy int r int color uint a uint to void
+if and gt r 0 ne a 0
+x0 = imax imax shr sub cx r 4 get cf 2 0
+y0 = imax imax shr sub cy r 4 get cf 3 0
+x1 = glright cx r
+y1 = glbottom cy r
+if and lt x0 x1 lt y0 y1
+glsetup r color a
+put gl 4 long x0
+put gl 5 long sub x1 1
+glrows cx cy y0 y1
+end
+end
+end
diff --git a/seed/wasm/renderer/native-pin.sha256 b/seed/wasm/renderer/native-pin.sha256
new file mode 100644
index 000000000..f09a2e312
--- /dev/null
+++ b/seed/wasm/renderer/native-pin.sha256
@@ -0,0 +1,4 @@
+7afbe5627d21bd25b70fcf32ff42c294203ad8b152019566300678f2006715e2  paint.c
+a107f4ffecb93dc4828129ac171363a4991732ed0cc2c0be0c0f1cff16393137  paint.h
+92d7157386e65351325d80d5036565e406145230dfb696c9804ec80888d26904  allen_font.c
+e26c3d5bc4c7c987a256dd066146a74da3e764623979a578e2cd0ecf43547fda  allen_font.h
diff --git a/seed/wasm/renderer/native-runner.om b/seed/wasm/renderer/native-runner.om
new file mode 100644
index 000000000..306b0344c
--- /dev/null
+++ b/seed/wasm/renderer/native-runner.om
@@ -0,0 +1,35 @@
+note native-runner.om: AArch64 program-mode fixture only. It follows glow.om and background.om; the gate
+note appends a generated fn main from glow-cases.tsv. fbdump writes the canvas as little-endian uint32
+note pixels, row-major, w*h*4 bytes, to stdout. Exit 90 on a failed write (below the trap range).
+global outb uchar 4096
+fn outall k ulong to void
+p = ulong 0
+note every pass writes at least one byte of at most 4096
+while lt p k bound 4096
+m = write 1 outb p sub k p
+if le m 0
+exit 90
+end
+p = add p ulong m
+end
+end
+note at most w*h <= 65536 pixels; outb flushes every 1024 pixels
+fn fbdump to void
+n = mul ulong get cf 0 ulong get cf 1
+i = ulong 0
+k = ulong 0
+while lt i n bound 65536
+v = get fb i
+put outb k uchar and v 255
+put outb add k 1 uchar and shr v 8 255
+put outb add k 2 uchar and shr v 16 255
+put outb add k 3 uchar shr v 24
+k = add k 4
+if eq k 4096
+outall k
+k = ulong 0
+end
+i = add i 1
+end
+outall k
+end
diff --git a/seed/wasm/renderer/oracle-glow.c b/seed/wasm/renderer/oracle-glow.c
new file mode 100644
index 000000000..659c8a785
--- /dev/null
+++ b/seed/wasm/renderer/oracle-glow.c
@@ -0,0 +1,96 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Read-only verification oracle: never a generator, never shipped.
+ * Links the UNCHANGED pinned C drawing kit (aien-dev/aienux
+ * da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c native/kernel/ui/paint.c and
+ * allen_font.c, digests in native-pin.sha256) and calls its ck_glow. Only the
+ * fixture parts live here: the case reader, the canvas reset and the gradient
+ * background law shared with background.om.
+ * Usage: oracle-glow glow-cases.tsv > frames.bin
+ * Exit: 0 ok, 2 usage/IO, 3 malformed case, 4 canvas too large. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "paint.h"
+
+#define FB_CELLS 65536 /* glow.om: global fb uint 65536 */
+
+static uint32_t fb[FB_CELLS];
+static ck_canvas cv;
+static ck_rect clip;
+static int framed;
+
+static int dump(void)
+{
+    if (!framed)
+        return 0;
+    for (int32_t i = 0; i < cv.w * cv.h; i++) {
+        unsigned char b[4] = {fb[i] & 255u, fb[i] >> 8 & 255u, fb[i] >> 16 & 255u, fb[i] >> 24};
+        if (fwrite(b, 1, 4, stdout) != 4)
+            return 2;
+    }
+    return 0;
+}
+
+/* background.om bgpix/fbgrad: inside clip and canvas only */
+static void grad(void)
+{
+    int32_t x0 = ck_max(clip.x, 0), y0 = ck_max(clip.y, 0);
+    int32_t x1 = ck_min(clip.x + clip.w, cv.w), y1 = ck_min(clip.y + clip.h, cv.h);
+    for (int32_t y = y0; y < y1; y++)
+        for (int32_t x = x0; x < x1; x++)
+            fb[y * cv.w + x] = CK_RGB((uint32_t)(x * 7) & 255u, (uint32_t)(y * 11) & 255u,
+                                      (uint32_t)((x + y) * 3) & 255u);
+}
+
+int main(int argc, char **argv)
+{
+    if (argc != 2)
+        return 2;
+    FILE *in = fopen(argv[1], "r");
+    if (!in)
+        return 2;
+    char line[512], op[16];
+    while (fgets(line, sizeof line, in)) {
+        if (line[0] == '#' || line[0] == '\n')
+            continue;
+        if (sscanf(line, "%15s", op) != 1)
+            return 3;
+        if (!strcmp(op, "frame")) {
+            char name[64];
+            long w, h;
+            int rc = dump();
+            if (rc)
+                return rc;
+            if (sscanf(line, "frame %63s %ld %ld", name, &w, &h) != 3 || w <= 0 || h <= 0)
+                return 3;
+            if (w * h > FB_CELLS)
+                return 4;
+            memset(fb, 0, sizeof fb);
+            cv = (ck_canvas){fb, (int32_t)w, (int32_t)h};
+            clip = (ck_rect){0, 0, (int32_t)w, (int32_t)h};
+            framed = 1;
+        } else if (!framed) {
+            return 3;
+        } else if (!strcmp(op, "clip")) {
+            long x, y, w, h;
+            if (sscanf(line, "clip %ld %ld %ld %ld", &x, &y, &w, &h) != 4)
+                return 3;
+            clip = (ck_rect){(int32_t)x, (int32_t)y, (int32_t)w, (int32_t)h};
+        } else if (!strcmp(op, "grad")) {
+            grad();
+        } else if (!strcmp(op, "glow")) {
+            long cx, cy, r;
+            unsigned long red, green, blue, a;
+            if (sscanf(line, "glow %ld %ld %ld %lu %lu %lu %lu", &cx, &cy, &r, &red, &green, &blue, &a) != 7)
+                return 3;
+            ck_glow(&cv, &clip, (int32_t)cx, (int32_t)cy, (int32_t)r, CK_RGB(red, green, blue), (uint32_t)a);
+        } else {
+            return 3;
+        }
+    }
+    if (ferror(in))
+        return 2;
+    int rc = dump();
+    return rc ? rc : fflush(stdout) ? 2 : 0;
+}