Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/README.md # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / README.md` 207 lines · 20283 bytes Raw Blame History Rendered 1 # seed/ng: Omega NG 2 3 Omega NG is the next Omega compiler (Hive NG). Source goes through a front end (`src/front.om`) into 4 ΩIR, the intermediate form specified in [`IR.md`](IR.md); passes (`src/opt.om`) rewrite ΩIR; back ends 5 lower it to AArch64 (`src/a64.om`) and sm_121 (`src/gpu.om`). Everything here is Omega, compiled by 6 the pinned seeded compiler `seed/out/omc`. 7 8 This directory is shared by the NG lanes. Lane ng-ir owns the ΩIR spec, its in-memory form and the 9 tools below; the other lanes own their `src/*.om` unit and their subdirectory: 10 11 | Directory | Lane | Role | 12 |---|---|---| 13 | `front/`, `src/front.om` | ng-front | Omega source to ΩIR (`@ng front-ir`, gate `front/gate-front-ir.om`); every language refusal of omc (`@ng front-check`, gate `front/gate-front.om`). | 14 | `a64/`, `src/a64.om` | ng-a64 | ΩIR to AArch64: the integer slice and scalar f32/f64 (`a64/DESIGN.md` sections 2 and 9; gates `a64/gate.om` and `a64/rgate.om`, whose float phase runs `a64/tests/frand.om`). | 15 | `gpu/`, `src/gpu.om` | ng-gpu | Encoder conformance gate over the units pinned in `cudapp.lock`, now in this repository under `gpu/nvidia/` (ADR 0047); `gpu.om` lands in `src/`. | 16 | `bench/` | ng-bench | A/B timing harness against omc and gcc -O2. | 17 18 ## ΩIR files (lane ng-ir) 19 20 | File | Role | 21 |---|---| 22 | `IR.md` | ΩIR v1: binary format, types, ops, token chain, coverage rule, refusal classes, text form, limits. | 23 | `hostwords.tsv` | Normative host word table (`id word args class`) the `host` op is checked against. | 24 | `src/ir.om` | First unit of the `ng` program (om2): ΩIR tables, builder, the one binary reader and writer (IR.md s14). | 25 | `src/opt.om` | Unit after ir.om: the ΩIR optimizer (IR.md s15.1). Per function: preheaders, PHI (a block parameter whose `br` arguments are one value besides itself becomes that value), bounds-check elimination (a `chk.bounds` proved by a const index or a dominating compare-and-branch becomes `fact.inbounds` origin 1; a `chk.divz` of a nonzero const goes), loop-invariant code motion of class P ops (checks, memory and calls stay on the token chain), PHI, BCE and LICM repeated while one of them changes something, then loop rotation (header after its latch). | 26 | `src/main.om` | Last unit: `ng` driver. `@ng ir-copy` reads a unit and writes it back byte for byte; `@ng front-check` and `@ng front-ir` run `src/front.om` (front/README.md); `@ng opt` writes it optimized; `@ng opt-count` prints `opt fns= loops= inloop=A->B phi= bce= hoisted= merged= rotated= preheaders=` (A, B: executing ops in loop blocks before and after; phi: block parameters removed; bce: checks deleted; counts of later passes come before `bce=`, and the gate's fixed-point check reads the tail from `phi=` on). | 27 | `ng.units` | The ordered unit list of `ng`, each with its sha256 pin. | 28 | `ngbuild.om` | `ngbuild build OMC UNITS OUT` validates the list, checks every pin, joins and compiles; `ngbuild sums UNITS` prints fresh pins. | 29 | `*.units`, `tests/ngbuild/gate.om` | Per-tool pinned lists, including `ngbuild.units` for its own self-build; standalone Omega first-birth and refusal gate. | 30 | `sha256.om` | FIPS 180-4 SHA-256 shared by ngbuild, ngcheck and the gate. | 31 | `ngcheck.om` | The validator: binary ΩIR on stdin, `ACCEPT fns= blocks= ops=` or `ngcheck: CLASS at OFFSET` with the class as exit code (IR.md s11). Its own reader: it shares no code with `src/ir.om`. `ngcheck --table` prints the host word table it was built with. | 32 | `ngtxt.om`, `ngas.om`, `ngdis.om` | Canonical text tools (IR.md s10): `ngas` text to binary, `ngdis` binary to text. A third independent decoder of the wire format. | 33 | `ngrun.om` | The reference interpreter (IR.md s7): `ngrun FILE.ir [STEPS] [--scratch NEW-DIR] [-- ARGS...]` runs the program entry of an accepted unit; exit status = the entry's result, a failing check exits 100 + code. Host words follow IR.md s7.11: argument, environment, clock, id and cpu words execute (ARGS after `--` are arguments 1..), file words only inside the fresh `--scratch` directory on one-component names and descriptors ngrun created, and every other word prints `ngrun: refused host class C word W at OFFSET` and exits C, 115..123. Scalar f32/f64 bitcasts preserve all bits; every defined f32/f64 conversion mode and fused FMA are supported. Run-time pool ops 111..116 execute (IR.md s7.13); pool storage and the program's frames share one 16 MiB live-storage budget. Unsupported ops (vectors, tiles, kernels, fmath, f16/bf16/fp8) print `ngrun: unsupported op N at OFFSET` and exit 125. Its own limits stay off the trap exits 100..114: `ngrun FILE.ir STEPS` stops after STEPS executed ops (default 2^36, about an hour) with `ngrun: step limit at OFFSET` and exit 124, and an element outside the object its REF or SLICE names (reachable only from input ngcheck refuses) gives `ngrun: access outside storage at OFFSET` and exit 126. Its exit status is an IR result only for a unit ngcheck accepts; on refused input it means nothing. Back ends diff their output against it (D9). It reads through `src/ir.om`, the reader `ng` itself uses, so a diff against ngrun alone cannot see a reader fault both share: that is what the gate's run pairs are for, which judge ngrun against omc's build of the same program in Omega (no shared code). Exercised: `sub` operands swapped in both the reader and the writer of `ir.om` pass every round-trip and ir-copy case and are caught by the run pairs `x-fib` and `x-float`. The gate also mutates ngrun nine ways (fuel one pass late; rem MIN/-1, u64 `chk.add` and `chk.mul`, `chk.shl` negative side, signed conv lower bound, `chk.bounds` with e = 0, narrow `neg`, depth cap): each is caught by a run pair or an N case (`n-*.oir`, ngrun alone, for the semantics Omega cannot state). | 34 | `ngrand.om` | Random programs, valid by construction (IR.md s10): `ngrand SEED` writes a binary unit (helpers, diamonds, counted loops, calls, checks with their codes, i64 memory, host write) built with `src/ir.om`; `ngrand tape FILE` replays a choice tape; `ngrand shrink SEED STATUS OUT CMD [ARG...]` deletes and zeroes tape bytes while `CMD ARG... OUT` exits STATUS and leaves the smallest unit in OUT and its tape in OUT.tape (the predicate runs at most 20001 times). The D9 differential source: a back end runs the same units as ngrun and the outputs must agree. | 35 | `tests/ir/` | Text fixtures (`*.oir`), run pairs (`x-*.oir` + `x-*.om`) and `cases`, the expectations the gate runs. | 36 | `tests/opt/` | Optimizer fixtures (`O`/`L` lines of `tests/ir/cases`): ng-front's 23 lowered run units and six by hand (`o-pre2`, `o-zero`, `o-bce0`, `o-bce1`, and the kernel loops `o-shfl` and `o-mma`, whose invariant `shfl` and `mma` must not leave the loop). | 37 | `gate-ir.om` | The ΩIR gate. | 38 39 ## Run-time pools 40 41 `global NAME T *` lowers to a class 2 global and six descriptor-based operations: 42 `pool.grow`, `pool.len`, `pool.load`, `pool.store`, `pool.read`, and `pool.write`. 43 See [IR.md, section 7.13](IR.md#713-run-time-pool-ops-111116) for types, tokens, and bounds. 44 No REF or SLICE can name pool storage, so growth during operand evaluation cannot leave a stale address. 45 46 The interpreter and Linux AArch64 back end support these operations. The interpreter keeps its 47 16 MiB combined live-storage budget and existing host I/O policy; Linux uses mmap/mremap and the 48 host's allocation limits. Mach-O pool operations are explicitly unsupported. This does not add 49 other host words to the native back end or pool operations to kernels. 50 51 Regression coverage is in the IR, source-lowering and AArch64 gates below. Full front check parity 52 is also required by `tests/gates/run.sh seed`. 53 54 ## Build and gate 55 56 From the repository root (any scratch directory works): 57 58 seed/out/omc < seed/ng/tests/ngbuild/gate.om > /tmp/ngbuild-gate && chmod +x /tmp/ngbuild-gate && /tmp/ngbuild-gate seed/out/omc /tmp/ngbuild-birth 59 /tmp/ngbuild-birth/ngbuild build seed/out/omc seed/ng/gate-ir.units /tmp/gate-ir 60 /tmp/gate-ir seed/out/omc /tmp/ng-ir-gate 61 62 The first line is the only bootstrap invocation. The standalone Omega gate independently joins 63 `sha256.om` and `ngbuild.om`, compiles the result, then has ngbuild read `ngbuild.units` and build 64 itself. It requires both joined source and binary to match byte for byte. It also exercises the 65 refusal exits 3, 4, 5, 8 and 9 below with exact exit status and diagnostic, no stdout and no 66 created output/source; exits 1, 2, 6 and 7 are not gate cases. The 64-argument usage refusal 67 cannot be a gate case: an `execprog` packed list holds at most 64 records (OMEGESE s10), so an 68 Omega parent never starts ngbuild with more than 63 arguments after the program name. 69 `ngbuild build` invokes OMC directly with `fork`, `dupfd`, `execprog` and `waitpid`, not a shell. 70 No `cat` is needed by these commands. Gate negative control: append `wrong` to its arguments; the 71 missing-unit expectation is inverted and the gate must end `NGBUILDGATE FAIL`, exit 1. 72 73 The ΩIR gate also runs the native seeded-omc float and conversion-range oracles in 74 `tests/ir/float-oracle.om` and `tests/ir/intcv-oracle.om` (IR.md s10), including sign-bit, 75 rounding-mode, fused FMA and unsigned-to-signed range-check mutants. 76 It builds ngbuild, ngcheck, ngas, ngdis, ngrun and ngrand with that omc, builds `ng` through 77 `ngbuild build` (so every pin in `ng.units` is checked), requires `ngcheck --table` to equal 78 `hostwords.tsv`, and requires `ngbuild build` to refuse a units file with one wrong pin (exit 3, 79 the exact mismatch line) before it compiles anything. Then it runs every line of `tests/ir/cases`: 80 the text round trip `ngdis(ngas(t)) == t`; ngcheck's whole output line, either 81 `ACCEPT fns=F blocks=B ops=O` (digest by the gate's own SHA-256, counts taken from the 82 fixture text) or the exact refusal line `ngcheck: CLASS at OFFSET` with empty stdout; `ng 83 ir-copy` on every unit (IR.md s14: identity, or the same refusal line for structural classes); 84 ngas syntax and limit refusals; byte mutants judged by ngcheck, ngdis and ng; inputs the gate 85 generates at the capacities of IR.md s10 and s12 (a unit of exactly `16777216` bytes and one byte 86 more, which ngcheck and ngdis refuse as LIMIT while ng and ngrun, reading into the no-caps arena of 87 `src/ir.om`, read it whole and refuse the byte as TRAILING; 65537 type entries, text with 65537 types, 88 globals, functions, blocks or parameters); and 89 run pairs: ngrun on `x-NAME.oir` against omc's build of `x-NAME.om` (exit status, stdout and 90 stderr equal); N cases: ngrun alone on `n-NAME.oir` with a step budget of `1000000` (exit status, 91 empty stdout, the step-limit or outside-storage line); random units of ngrand for seeds 1..1000 (ngcheck's whole ACCEPT line, 92 `ngas(ngdis(b)) == b`, the same bytes twice for seed 1, ngrun ending with exit 0..63 and 0 or 8 93 stdout bytes, 64..95 by `exit` or 101..114 by a trap, empty stderr); one shrink with ngrun as 94 the predicate (accepted, still trapping, smaller, its tape replays it); and the optimizer on every 95 random seed and every `tests/opt/` fixture (`@ng opt` exit 0, ngcheck's whole ACCEPT line on the 96 output, its text round trip, ngrun before and after equal, a second `@ng opt-count` finding nothing 97 to move; a row `ok O NAME fns=.. inloop=A->B ...` per fixture, which must equal the row written on 98 its `O`/`L` line, so a pass that stops doing its work fails). The `L` fixtures are the long 99 kernels (ngrun takes 25 s to several minutes each on the Spark, twice: about 19 min of ngrun per pass 100 on an idle Spark core, sum of the measured per-kernel runs), which makes a full gate run take about 40 101 minutes (2353 s at `854d8152` on core 11). The workflow `.github/workflows/ng-ir-arm64.yml` keeps main's 102 30-minute timeout, so a CI run of this gate would be cut off; the gate is run on the Spark. Then its negative controls: 103 three deliberately wrong expectations must each trip 104 their named check, three mutants of ngcheck (load and store typing disabled, the witness prefix 105 changed, the class name shifted), ten mutants of ngrun (`chk.fuel` one pass late, rem MIN/-1 106 giving a, u64 `chk.add` and `chk.mul` never failing, `chk.shl` without its negative bound, the signed 107 conv lower bound at -2^(w-1), `chk.bounds` passing e = 0, narrow `neg` left uncanonical, the depth 108 cap at 70000, the step limit one op late: `n-loop2` then names 87, not 116), a mutant ngrand (a 109 random check's new token not made current) and five of opt.om (a load hoisted past the loop's 110 stores and checks hoisted past their guard, both refused by ngcheck; preheader merging that 111 ignores imm and BCE accepting an index one past its proof, a run differs; LICM moving a convergent 112 `shfl`, the pinned `o-shfl` row differs) must each fail their named check at least once (the 113 ngrand mutant: ngcheck refuses TOKEN); each mutant's pattern must occur exactly once in its source. 114 Under a mutant, Q runs 100 seeds and `L` cases are skipped. Last line `NGIRGATE PASS cases=N`, 115 exit 0; otherwise one `FAIL` line per failure and exit 1. 116 117 The tools one by one, after first birth: 118 119 /tmp/ngbuild-birth/ngbuild build seed/out/omc seed/ng/ngbuild.units ngbuild 120 ./ngbuild build seed/out/omc seed/ng/ngcheck.units ngcheck 121 ./ngbuild build seed/out/omc seed/ng/ngas.units ngas 122 ./ngbuild build seed/out/omc seed/ng/ngdis.units ngdis 123 ./ngbuild build seed/out/omc seed/ng/ngrun.units ngrun 124 ./ngbuild build seed/out/omc seed/ng/ngbench.units ngbench 125 ./ngbuild build seed/out/omc seed/ng/ngrand.units ngrand 126 ./ngrand 7 > r7.ir && ./ngcheck < r7.ir && ./ngrun r7.ir; echo $? 127 ./ngbuild build seed/out/omc seed/ng/ng.units ng 128 ./ngas < seed/ng/tests/ir/a-arith.oir | ./ngcheck 129 ./ngas < seed/ng/tests/ir/x-fib.oir > fib.ir && ./ngrun fib.ir; echo $? 130 131 After changing a listed unit, refresh every affected `*.units` file with `./ngbuild sums LIST`. 132 Capture its output into a separate file before replacing LIST; never truncate a list while `sums` 133 is reading it. 134 135 ### Unit-list contract and exit status 136 137 Each line is exactly 64 lowercase SHA-256 hex digits, one space, a nonempty path of at most 4095 138 bytes (no NUL), then LF. A relative path resolves against the working directory; an absolute path 139 is used as given. No comments, blank lines or ordering metadata are accepted. Order is the line 140 order, with no inserted byte between files. 141 There is no dependency graph in this format, so a cycle has no representation. At least one and 142 at most 64 units, at most 65536 list bytes, and at most `8388607` joined source bytes are accepted. 143 The entire list is validated before any unit is read. In `build`, paths and digest pins must be 144 unique (this also catches aliases with identical contents); `sums` permits equal placeholder pins 145 but still refuses duplicate paths. All units and pins are checked before output is opened or OMC runs. 146 147 | Exit | Meaning | 148 |---|---| 149 | 0 | Built, or sums printed. | 150 | 1 / 2 / 3 | OMC refused (its status is printed) / usage, including any argument count other than `build`'s 4 or `sums`' 2 (checked before any argument is read) / pin mismatch. | 151 | 4 / 5 | Malformed or empty list / unreadable list or unit. | 152 | 6 / 7 | Cannot write output / fork or wait failure, or OMC ended by a signal (`ngbuild: fork or wait failed, or omc ended by a signal`). A failed exec or redirect in the child exits 127 and is reported as `ngbuild: omc exit 127`, exit 1. OUT.src is written before OUT is opened and OMC runs, and stays after a successful build; exit 6 can leave OUT.src, and exits 1 and 7 can leave both. After OMC exits 0, OUT is read back for its sha256; exit 5 (`ngbuild: unreadable: OUT`) or exit 9 (`ngbuild: too large: OUT`, OUT of `16777216` bytes or more) then leaves both. | 153 | 8 / 9 | Duplicate unit / list, unit count, unit file or joined-source limit exceeded. | 154 155 Exact diagnostic formats are in `ngbuild.om`; malformed-line offsets count bytes from zero. 156 Regression gate: `tests/ngbuild/gate.om`, with no shared implementation with ngbuild. 157 158 CI: `.github/workflows/ng-ir-arm64.yml` births omc from the seed, requires the committed 159 `seed/out/omc.sha256`, builds the gate and runs it. That historical workflow's `cat` bootstrap is 160 unchanged here (protected path); use the host commands above for the no-cat build. It runs on any 161 pull request that changes `seed/**` or the workflow, and on every push to main. 162 163 ## No-caps gate 164 165 ng's input-sized tables (the front's, the front-ir lowering's, the ΩIR payload, output, global data and 166 globals of `src/ir.om`, and a64's per-function wires, liveness bitsets, call sites, global addresses and code 167 image) are regions of one arena, `ar_m` in `src/ir.om` (`16777216` words, 128 MiB; omc.om's arena design, 168 OmcNoCaps 2026-11-11). A region doubles when an index reaches its capacity, and the arena is compacted when the 169 copies do not fit, so the only capacity left is the arena itself: a full arena is a defined refusal (front error 14, 170 ΩIR reader LIMIT 23, otherwise `ng: arena full`, exit 14) followed by the ng-use record `ng-use 1 arena=A top=T 171 waste=W full=F GROUP=N/H ...` on stderr. A front unit whose first line is `usage` writes that record in place of 172 output (the alarm's input). Value nesting stays bounded by ng's 8 MiB stack at 32768 levels (front.om's note at the 173 depth check). The tables of IR.md s12 that the ΩIR builder, ngcheck and the text tools keep are refused with a line, 174 never overrun (`ir_lim`). 175 176 cat seed/ng/sha256.om seed/ng/tests/nocaps/gate.om | seed/out/omc > nocaps-gate 177 nocaps-gate seed/out/omc $(sha256sum seed/out/omc | cut -c1-64) SCRATCH [NG] 178 179 It builds ng from `ng.units`, generates units far past every old table (100,000 globals, texts and long names, 180 60,000 functions, 1,000,000 calls in one function and 1,100,000 in 1100, a 64 MiB input, 5000 nested blocks, 181 3000 breaks and continues, values 5000 and 32767 deep, nested calls, 2,000,000 front-ir name snapshots, 10,000 182 local arrays, 22,500 inline edges, an om2 diag unit of 1,000,000 sites, 17 MiB of text data; past the front's old 183 loop bounds, 1,000,001 rets in one inline body, one text literal of 16,777,219 bytes and 16,777,232 blank lines in 184 one block; past a64's 262144 branch fixups a function, 270,000 overflow branches, once with the trap taken), has 185 omc compile and run each and ng check, lower, compile and run it, and requires the same answers. 32 mutants 186 (each old table or loop bound put back, the trap-label tag of a64 back at 1000, a moved region losing its words) 187 must be KILLED, and a control (a wrong expected answer) tripped. The usage alarm: ng checks 188 `seed/node/journal-gate.om` (a large real first-party unit) and its own units after a `usage` line; 189 the arena top must stay at or below 10% of the 190 arena, every group at or below 5%, a check at or below 2 s; ng with the arena shrunk to `1048576` words must 191 trip it. With NG given, that binary 192 is judged and nothing is built (the ng of the base must FAIL here). Last line `NOCAPSGATE PASS cases=31 fail=0 193 mutants=32 killed=32 controls=2 tripped=2 notrun=0`, exit 0. 194 195 ## Host dependencies 196 197 Every host binary that stays in an NG build, gate or bench path, with its version, what it does 198 for me and its Omega replacement (Hive NG ledger `HOST-DEPS.md`, carried here). Verification 199 oracles (the pinned omc, git, gh, crumb) and referees (gcc, objdump, cuobjdump, Wolfram) are exempt. 200 201 | host tool | version | where | what it does | Omega replacement | 202 |---|---|---|---|---| 203 | cat | Not required by the host commands above | historical workflow bootstrap only (unchanged) | concatenates units in the historical workflow | standalone `tests/ngbuild/gate.om` owns first birth; `ngbuild build` owns all later pinned builds | 204 | taskset | util-linux 2.39.3 | Spark builds and timed runs | pins builds to core 1, timed runs to their cores | an Omega `sched_setaffinity` host word in ngbench (proposal to omega-mv) | 205 | flock | util-linux 2.39.3 | Spark lane builds and bench rounds | shared and exclusive core-pool locks between agents | an Omega flock host word, or ngbench taking the lock itself (proposal) | 206 | nice | GNU coreutils 9.4 | Spark build and timing prefixes | lowers scheduling priority | a setpriority host word (proposal) | 207 | sh / YAML run lines | GitHub runner | CI workflows `ng--arm64.yml` | one-line invocations of `.om` gates | none planned: CI glue only, no logic |