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

branch main Branches Tags History

omega-mv / seed / README.md

1098 lines · 75333 bytes Raw Blame History Source

seed/: a compiler chain born from nothing

Drake's question: C was built from B, B from something older. If every old tool added mistakes or waste, I would inherit all of it. So this folder grows a toolchain from a few hundred hand-written bytes, step by step, with the existing C compiler and the GNU tools used only as a referee that checks the answers, never as a builder.

The current completeness audit (implemented areas, open compiler work, and what is blocked on a decision or an external store) is docs/one_layer/OM_COMPLETION.md.

The scalar OSC IR backends are wasm/irwasm.om (WebAssembly MVP) and spirv/irspirv.om (SPIR-V 1.0 OpenCL Kernel). Both are compiled by seeded omc. IR mode casts (TYPE value) read the operand at its own type and convert it, the same as the AArch64 path, so ret ulong sub c 48 with c a uchar compiles. A bare number in the cast is range-checked against the cast's type (error 8) and a bool converts to or from a number only by comparison (error 9). seed/omc/gate-ir.sh pins 21 cast units against the C oracle plus 6 cast refusals; reverting the operand read to the cast's type makes the gate fail.

See SPIR-V usage, CPU parity gate and OpenCL demo.

To rebuild omc from the 408-byte seed on your own AArch64 Linux machine and check every rung against published hashes without touching tracked files, run sh seed/challenge/run.sh (see the seed-chain bootstrap challenge).

At commit e5b32567 (2026-10-27) the compiler source omc/omc.om is 12,040 lines and 208,168 bytes (sha256 7703da00055fc0c7a91fcae43071df76a3f277dbe867cb284a3bdff3bedb7e1b), and out/omc is 325,524 bytes. The line, function and byte counts given in each rung section below were recorded when that rung landed and are not current sizes.

Think of it as a ladder. Each rung is a small program, written in the language the rung below understands, and built by the rung below. Every rung must rebuild itself to the exact same bytes, which proves it reads its own language the same way the rung below does.

The only source for instruction bits is the public Arm Architecture Reference Manual (Arm document DDI 0487, revision M.d, sha256 80d589a4...e3d5). Every instruction in every hand-written file names the manual section it came from.

Rung 0: seed-0 (done)

Rung 1: hex1, labels (done)

Rung 2: asm2, instructions by name (done)

Rung 3: om3, a translator for Omegese (done)

Rung 4: om4, the systems words a compiler needs (done)

Rung 5: Atlas reborn (done)

Rung R5: omc, the Omega compiler written in Omega (done)

Rung R6, first piece: structs (done for the language; GPU words still open)

om4 does not learn structs. It remains the parent that rebuilds omc, and omc.om does not use the new words, so the two parents still build the same compiler. A struct program is a stack of 8-byte cells, given back when the function returns. There is no free.

Rung R6b: one compiler line, structs and native host operations (done)

Structs and the native host extension were built on separate branches from R5. They are now one compiler: seed/omc/omc.om, 4,616 lines and 173 functions, accepts both. The keyword table keeps both islands with no id shared (struct 85; host words 100 to 131).

Rung R7: break and trap (done)

Section 3 listed both words while the compiler refused them (keyword 77). omc now implements them (86 and 87) with the following semantics, and seed/omc/gate7.sh checks each one (11 cases plus the om4 refusal); seed/host/check.sh runs gate7.

Rung R8: OSC IR output, one line (experimental checkpoint)

fix/seed-ir-trap added a leading ir line that writes OSC IR version 1 for one function instead of AArch64 words. It branched from R6, so it lacked the native host words and break/trap. It is now part of the same compiler: seed/omc/omc.om, 5,395 lines and 209 functions, sha256 2b029a217e8f2d033b484dec3a5a24570370b8a139157f4204358e226d1e5bd9 (149,904 bytes).

Rung R9: f32 and f64 (done)

IEEE-754 binary32 and binary64 are now part of the language, written in omc (f32, f64, bitcast, decimal literals, arithmetic, comparisons and conversions). A float value is its bit pattern in an ordinary integer register; arithmetic moves it to v0/v1, runs one scalar FP instruction and moves it back, with FPCR untouched and no fused operation.

Rung R10: grouping parentheses (done)

The design says brackets are optional and separate words; the lexer did not implement that, so (5) was read as one unknown name. tok2 now emits ( and ) as one-character tokens even when they touch a value, and the existing group path returns the inner value with no code.

Rung R11: full-range decimal literals (done)

The first float slice converted N * 10^p only while both factors fit u64 (scale at most 18). The converter now keeps a normalized 64-bit significand, a binary exponent and one sticky bit (fmul10/fdiv10), rounds once to nearest even (froundsh) and packs with subnormal handling (fpack). No 128-bit integer and no double rounding are needed.

Rung R12: layout queries (done)

sizeof T / sizeof S and offsetof S f are compile-time constants of type ulong over the same 8-byte-cell layout that new/get/put use. They add no code and compose in expressions, which is the primitive that structure formats and the future C ABI work need in order to describe a layout without hard-coded numbers.

Rung R13: keyword compatibility (done)

The first float slice spelled its words bits, sqrt, abs, min and max. Auditing the 103 .om files of the benchmark corpus against the pinned compiler (e5d60db8…) showed seven refusals: existing code uses bits as a parameter or variable in six files and min in one. A keyword may not take a name that existing code uses, so the float words are now bitcast, fsqrt, fabs, fmin, fmax (ids unchanged).

Rung R14: continue (done)

break had no counterpart. continue now finds the innermost loop like break, but its branch is patched to the loop's latch instead of its exit: the head of a while, so the condition and the hidden bound count run again, or the increment of a for, so the counter still advances. It uses the same fixup discipline (recorded with the loop's block index, patched when that loop closes, then marked spent) and the same 1024-site limit per function.

Rung R15: benchmark parity audit (evidence)

The current compiler was checked against the benchmark-pinned compiler over the real benchmark workspace, not just this repository's fixtures:

Method and per-scope counts: evidence/SEED-0/benchmark-parity/README.md. The corpus is external, so this is evidence rather than a gate.

Rung R16: IR refusals (done)

IR mode used to consume non-fn top-level tokens and silently skip them, so a struct, global or text declaration simply vanished from the IR. ir_run now classifies every top-level token: blank lines and note lines are skipped, fn goes through the IR path, a struct/global/text declaration is error 9, and any other token is error 16. Nothing is lowered by accident.

Rung R17: getrandom (done)

random A off n flags fills a writable uchar slice from Linux getrandom through the same host-word path as the other slice operations: off/n are bounds-checked (trap 3), a view or text is refused (error 20), and flags is a typed int. It returns the bytes written or -errno; unknown flags return -EINVAL.

Rung R18: environment access (done)

envcnt and envread index A off capacity read the process's own environment vector, which the start code preserves in X27 beside argv. envp[0] sits at X27 + 8*(argc+2); envread walks the entries before the requested index, so an index at or past the count traps 3. The slice rules match argread: bounds trap 3, a view/text is refused (error 20), and a short buffer returns -105 without modifying it.

Rung R19: chdir (done)

chdir A off n changes the working directory through the same checked-path machinery as open/unlink/mkdir/rmdir: length-delimited path, private NUL-terminated copy, bounds trap 3, nonempty/embedded-zero refused, result 0 or -errno. The *at words leave AT_FDCWD in X0; chdir moves the path into X0 before syscall 49.

Rung R20: capacity boundaries gated (done)

OMEGESE 9.6 states where the compiler runs out of room. seed/omc/gate12.sh now generates each boundary and checks both sides:

seed/host/check.sh runs gate12. Compiler unchanged since R19: 6,474 lines, 238 functions, sha256 7e7b68fd8922284e4b535005aef40b179bca70d8f3e775d7862af8c62c57e382.

Rung R21: compiler fuzz gate (done)

seed/omc/gate13.sh embeds two deterministic generators (an explicit 16-bit LCG, never rand()):

The 600 programs run in about two seconds and seed/host/check.sh runs the gate.

Rung R22: ftrunc (done)

ftrunc fd length sets an open descriptor's length through the scalar host path (Linux ftruncate, syscall 46). fd is int, length is long, and the result is long: 0 or minus the kernel error.

Rung R23: numeric conformance from Wolfram (done)

seed/omc/gate14.sh runs 35 programs whose expected exit statuses were computed exactly in Wolfram Language through the Wolfram MCP server (2026-10-23; server 2026.09.15), not by this compiler. The expressions and the returned table are in evidence/SEED-0/num-conformance/wolfram.txt.

Values are compared as main's value mod 256; traps must exit 100 + code. The gate runs in about 0.1 s and seed/host/check.sh runs it. Compiler unchanged: 6,480 lines, 238 functions, sha256 4aa1b0bf….

Rung R24: path stat (done)

stat A off n B off capacity returns metadata for a checked path without opening it: Linux newfstatat with AT_FDCWD (syscall 79), writing the same 128-byte ARM64 structure as fstat. It returns 0 or minus the kernel error. The output slice must hold 128 bytes; a shorter one traps 3 before the kernel writes anything.

link A off n and symlnk A off n create a hard link or a symbolic link from a packed two-path list, reusing the renames/execprog list format: little-endian u16 count, then per record a u16 length and the bytes. The count must be 2, both records nonempty, the packet at most 4096 bytes. They call linkat (syscall 37) and symlinkat (36) and return 0 or minus the kernel error.

Rung R26: chmod (done)

chmod A off n mode sets permissions on a checked path through fchmodat (syscall 53, flags 0). It reuses the path-copy machinery and the one-int argument shape of makedir; it returns 0 or minus the kernel error.

Rung R27: access checks and identity (done)

faccess A off n mode checks a checked path through faccessat (syscall 48, flags 0); mode is F_OK 0, X_OK 1, W_OK 2, R_OK 4. getuid, geteuid, getgid and getegid are zero-argument words (syscalls 174-177) returning the process's real and effective ids.

Rung R28: lstat (done)

lstat A off n B off capacity writes the same 128-byte ARM64 stat structure as stat, but passes AT_SYMLINK_NOFOLLOW (256) to newfstatat, so a final symbolic link is reported instead of followed. It returns 0 or minus the kernel error; a short output traps 3.

Rung R29: path truncate (done)

truncate A off n length sets a checked path's length through Linux truncate (syscall 45). It reuses the path-copy machinery; the length is a long, and after the copy the path moves to X0 and the length to X1.

Rung R30: refusal-code conformance gate (done)

seed/omc/gate15.sh pins the compiler's refusal table. At R30 that was one minimal program per code 3..23, each of which had to exit with exactly that code and print error N, plus a valid control. Since #797 the codes live in one registry, seed/omc/error-codes.reg, and gate15 covers every emitted code 1..25 and 27..30 (33 cases, each checked against its exact omc: line L: error C) and runs the seed/omc/codereg.om drift check with three negative controls; see OMEGESE §9.14.

Rung R31: chown (done)

chown A off n uid gid sets ownership on a checked path through fchownat (syscall 54, flags 0). It reuses the open-path argument shape (path plus two int ids); -1 leaves that id unchanged.

Rung R32: named integer constants (done)

const NAME TYPE INTEGER at top level defines a typed value before use. It is visible to later functions, composes wherever a value goes (including call arguments), cannot be assigned (error 7), and is kept across function scope resets by advancing the global-name watermark. Integer types only; f32/f64 constants and IR mode are refused (error 9). Names are at most 8 characters and may not collide with a visible name, function or struct (error 10); the value must fit (error 8).

Rung R33: constants as array lengths (done)

lenval accepts either a number or an integer constant name wherever an array length is parsed: local new, global pools, and view/edit parameter declarations. A name that is not an integer constant is error 16, and arrlen keeps the 1..16777216 range (errors 8 and 23). namescan now scans const lines before function signatures, so a signature may use a previously defined constant; the scan resets the global-name watermark afterwards so the body pass re-registers it.

Rung R34: float constants and constant field lengths (done)

const now accepts a float literal (f64 0.1, f32 0.1): rdval reads the float token, fspan converts it to target bits, and the name stores the bits with the float type. An integer literal under a float type (f64 5) is refused (error 16). Integer constants are also accepted as struct field lengths (1..64; over that is error 14), while a float constant used as any length is error 16.

Rung R35: constants in trap codes, loop bounds and for counts (done)

trap N and while ... bound N now accept an integer constant as well as a literal (ranges 1..14 and 1..999999); a for count was already an ordinary value, so a constant works there too. A float constant is error 16 and an out-of-range integer keeps error 8.

Rung R36: integer constants in IR mode (done)

IR mode now accepts top-level integer constants and folds each use to the same IR literal: the gate compiles const N uint 5 with ret N and the literal ret uint 5 form and requires byte-identical IR. Float constants in IR are still refused (error 9), as are struct/global/text declarations. ir_name consults the global name table only after failing to find an IR-local name, so locals still shadow as before.

Rung R37: fchdir, getppid and umask (done)

fchdir fd changes the working directory to an open directory descriptor (syscall 50); getppid returns the parent process id (110); umask mask sets the file-mode mask and returns the previous one (166). All use the scalar host path; fd and mask are int, results are long.

Rung R38: data sync and anonymous files (done)

fdsync fd syncs file data only (fdatasync, syscall 83). memfd A off n flags creates an anonymous in-memory file (memfd_create, syscall 279) and returns its descriptor; the slice is a name, copied privately like a path. Both are ordinary host words.

Rung R39: process groups (done)

setsid (syscall 157), getpgid pid (155) and setpgid pid pgid (154) are scalar host words; pid/pgid 0 means self (and own pid for setpgid). The gate checks getpgid 0 > 0, accepts setpgid to the current group (0) or EPERM, accepts setsid or EPERM when already a session leader, and checks getpgid 0 > 0 afterwards.

While adding these, the zero-argument hargc chain reached nine or operands and om4 refused the source with error 12 (register pool). hargc is now a list of individual if eq c N ret K end checks; the argument counts are unchanged.

Rung R40: IR constants in trap/bound/for; IR trap dispatch fixed (done)

IR mode now folds integer constants used as trap codes, while bounds and for counts to the same IR as their literals; gate-ir compares each pair byte for byte. Two latent IR bugs surfaced and were fixed:

The ten one-function dev outputs stay byte-identical; the literal for count is still allocated in the same register order as before.

Rung R41: IR multi-function calls (done)

IR mode now emits a unit of up to 32 function records and supports calls to earlier functions.

Rung R42: positioned I/O (done)

pread fd A off n pos and pwrite fd A off n pos (syscalls 67/68) move bytes at an explicit long position without changing the descriptor's file offset; slice checks and the result match read/write. A text is readonly, so pwrite's source must be a writable array (error 20).

Rung R43: differential fuzz against the pinned compiler (done)

seed/omc/pinned.om is the R5 compiler source from commit f0499f41. gate17.sh builds it with the seed-owned om4 and asserts the resulting digest e5d60db8…; it then generates 300 deterministic structured programs (scalars, arrays, if/while/for, arithmetic; explicit 16-bit LCG) and compiles each with both compilers. Every program must be accepted with byte-identical machine code.

This is a regression net wider than the 103-file benchmark corpus: 300 programs, 0 differences, about 0.5 s total. seed/host/check.sh runs it.

Rung R44: IR differential fuzz (done)

gate-ir now generates 30 deterministic two-function programs (a helper with random arithmetic/comparison/if, and a caller with a call and arithmetic) from an explicit 16-bit LCG. Each must be byte-identical to the C omegese + omega_emit oracle and checker2 ACCEPT. This covers random call sites and argument values beyond the nine hand-written units: 30 programs, 0 differences, about 0.5 s.

Rung R45: IR break (done)

IR mode lowers break to a BR to the innermost loop's exit and marks the path dead; the enclosing if/loop closes skip unreachable joins exactly as after ret or trap. The gate compares while, for and nested-loop break programs byte-for-byte with the C oracle and requires checker2 ACCEPT; break outside a loop is error 9 and a later line in the same block is error 17. continue remains refused (error 3), matching the C omegese, which does not accept it.

Rung R46: getsid, syncfs and shutdown (done)

getsid pid (syscall 156), syncfs fd (267) and shutdown fd how (210) are scalar host words. The gate checks getsid 0 > 0, a successful syncfs on an open file, and a negative shutdown on a regular file (not a socket); the file is unlinked.

Rung R47: IR binary operand types (done)

ir_bin_r now checks the right operand against the left: arithmetic and comparisons require the same type (bool arithmetic is refused); shifts allow any whole-number amount, matching the language (shl ulong 1 uint 3 is oracle-identical), but refuse bool or float amounts; float operands are refused. Before this, add s i with s uint, i ulong emitted IR that checker2 rejected; it now fails 7 instead.

Rung R48: IR operator result types and comparison destinations (done)

ir_val now checks the result type of bin/un/true/false against the expected context (error 7), closing the class where ret uchar add uint 1 uint 2 or x = eq ... with a uint x emitted checker2-rejected IR. ir_bin_r writes comparison results into the destination register (a fresh one only for the sentinels), so reassigning a bool local now matches the oracle exactly.

Rung R49: IR context types without blocking casts (done)

Type enforcement moved out of ir_val's name/literal/call paths (which wrongly rejected explicit conversions such as x = ushort a and ret uchar uint 1) to the sites that require an exact type: if/while conditions, for counts, returns, local assignments, binary operands and call arguments. Explicit TYPE value casts may still change type; the cast-return unit is oracle-identical.

This fixes if x with uint x, ret x in a uchar function, and x = eq ... with a uint x (all now error 7), while dev01/dev02 (ushort a, long a) and uchar inc ... compile.

Rung R50: keyword generator parity (done)

seed/omc/gate18.sh regenerates the chain with genkw.awk and compares every literal pack/id pair with fn kw scoped to that function. It independently checks the complete ID multiset and derives the expected pair count from the semantic canonicalizer's committed tkw1 inventory (seed/semhash/semhash.om), without regenerating that inventory during verification. The two computed entries (readlnk 133, sockopt 134) and target-scoped efi are checked separately. Thus deleting a word from both the generator and compiler chain still fails; tests/kfd/check.py exercises that coordinated-removal control. To generate the canonicalizer inventory when changing the language, use awk -v semhash=1 -f seed/omc/genkw.awk; replace its text tkw1 declaration with that output. seed/semhash/check.sh checks the canonicalizer's full spelling/id parity. Decimal string arithmetic preserves packs above 2^53 exactly. seed/host/check.sh runs gate18.

Rung R51: constants in function mode (done)

A function-mode unit (no fn main) used to refuse any top-level name with error 9 at the end of the input, because s_eof tested the count of top-level names, and that count includes constants. The new fnstore scans those names and refuses only a global pool (kind 4) or a text (kind 5); a constant (kind 9) folds to its typed number at every read and needs no program image. Host words keep their error 9 at the line that uses them.

TileLab planner input refusal (TL907-01)

Build the candidate compiler with sh seed/omega-from-seed.sh, then run sh seed/tilelab/gate.sh from the repository root on an AArch64 Linux host. The gate prints the compiler and planner binary SHA256 values before checking the exact planner output and process status in seed/tilelab/expected.txt.

Planner dimensions remain decimal integers in the documented range. Decimal overflow is refused before unsigned multiplication or addition can wrap. An optional REGS budget must be a nonempty decimal ulong: malformed, over-capacity and overflowing input returns usage status 3 without a plan. A valid budget too small for any configuration still returns refusal status 2. The maximum representable ulong budget is valid; parse failure is tracked separately rather than interpreting its value as an unlimited budget.

The host gate includes the independent audit's overflowing dimensions and malformed REGS input, empty and over-capacity REGS controls, and maximum-value acceptance. seed/tilelab/parser_mutant.om removes the overflow guard or the REGS status check independently. Each mutant must compile, return success and emit a plan for the corresponding invalid audit input; compiler failures or unrelated runtime failures are not accepted as control evidence. These checks qualify host parsing only. They do not access or qualify a GPU, alter the empirical scheduling model, or rewrite historical evidence.

Local trace segment (omega-mv #608)

seed/trace/segment.om is a library unit (no main) for a local, append-only trace segment: a 16-byte header and 64-byte records, each with its sequence number and a CRC-32. It can scan a segment read-only, and its recovery keeps the valid prefix and quarantines the damaged file as <segment>.bad. Run sh seed/trace/gate.sh (or tests/gates/run.sh trace) from the repository root on an AArch64 Linux host. The gate checks seed/out/omc against its recorded SHA-256, then requires the 71 checks in seed/trace/segment-test.om to print exactly seed/trace/expected.txt. It also requires four source mutants to fail their own checks: CRC comparison removed, torn tail ignored, append alignment guard weakened, and create with O_TRUNC in place of O_EXCL. seed/trace/README.md describes the format.

seed/trace/tracecli.om is the offline read-only CLI for that format (omega-mv #610): version, verify, show, events, stats, export, compare and list. Nothing is written except stdout. Run sh seed/trace/cli-gate.sh (or tests/gates/run.sh tracecli) from the repository root on an AArch64 Linux host. The gate checks seed/out/omc against its recorded SHA-256, pins the generated fixture SHA-256 values and the golden stdout, refuses a mode-0000 segment, and requires four source mutants to fail their own checks. One of those is a literal scan of the read-only open flags (32768; a change to 32770, which is O_RDWR|O_NOFOLLOW, must fail the scan). seed/trace/README.md describes the format and the CLI.

Candidate scalar fma and exact literals

fma a b c (keyword 227) is explicit AArch64 scalar FMADD for three equal f32/f64 types. It rounds once, unlike separate mul and add. x86linux/x86efi refuse a well-typed fma with error 9 rather than silently substituting non-fused arithmetic; operand errors 7 and 11 come first, as on AArch64. See OMEGESE section 9.9 for NaNs, signed zero, literal rounding and refusal rules.

The exact-limb decimal converter and 512-literal fixture are reused from the core of draft #1027 (681d6f487ac3c237e0b8d73c287e0a8f232b1434, fixing #1024 and #1026), applied to main 5287336a50b4b75a357bfc330f599cc604209e40. They are not an independent second fix. evidence/SEED-0/fma-exact-literals/oracle.wl records a mounted Wolfram evaluation that independently checks all 512 expected patterns and the f32/f64 fused counterexamples. The inherited Python oracle is not needed for this qualification.

Run the seed fixpoint, then sh seed/omc/gate8.sh and sh seed/omc/gate-fma.sh. The latter compiles a seeded exact-once source mutator, rejects an absent mutation site, and requires detection of FMSUB, unfused multiply/add, discarded decimal remainder and ties-down mutants. seed/host/check.sh includes both gates.

This is an additive candidate profile, not a production compiler-pin refresh. Per integration ownership, the bridge's e5b32567 profile and active generated-unit/gate pins remain frozen. Adoption requires a separately authorized batch reseed, generated-unit regeneration and full pin refresh; this draft must not be treated as installed or independently merge-ready.

How the checks stay honest