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 / docs / one_layer / OM2-TUTORIAL.md

250 lines · 13417 bytes Raw Blame History Source

OM-2: from compact source to a check to machine code

This is the working tutorial and the guarantee matrix for the OM-2 profile of Omegese. It is not a specification: spec/omegese-om2.md and spec/omegese-om2-errata.md are normative, and docs/one_layer/OMEGESE.md §9.13 says what omc implements of them. Where this document disagrees with those, they win, and this document is stale.

Estate when this was written: OM-2 was on the compiler stack om2/compiler-s4 @ f6a6492fd (PRs #750, #753, #754, #764) and the SHA-256 cutover om2/sha-cutover (PR #776), then draft. All of them have since merged, with the qualification harness #752 (2026-10-25/26 UTC); main compiles OM-1 and OM-2. The pins below are those of the measurements and stay as recorded; main's compiler pin has moved since (at 3364a1dfd it is befb8199...8a1d, after #786 changed IR-mode boolean typing). Nothing here is hardware-qualified: every result is HOST on Linux AArch64.

1. Pins

ItemValue
Compiler sourceseed/omc/omc.om on om2/compiler-s4 @ f6a6492fd
Compiler binaryseed/out/omc, sha256 499236398aabc652e2dae27fe4bdc4c5db3d3726314356e0dbef23e3345803ec
Contractspec/omegese-om2.md sha256 245bb74e…0881, errata E1–E18
Qualificationom2/qualification, records in candidates/*/RESULTS.txt (PR #752)
SHA-256 implementationom/sha256/sha256-om2.om, sha256 dbf002dd…94bb
SHA-256 artifact21,340 bytes, 5,335 words, sha256 27775fb2…570b
Bridgeaien-dev/omega-bridge feat/slice-abi @ a8959fb1, ABI v2
Baseline for every comparisonmain @ acb3f15cd

2. Tutorial

Step 1 — opt in, one line

note a first OM-2 unit
om2
fn main to int
ret 0
end

Leading blank lines and note lines are skipped; the first line that is not one of those decides the profile. om2, om2 diag or om2 fmt makes the unit OM-2. Any other line leaves it OM-1, where the OM-2 words are not reserved and rotr is simply an unknown word (error 3). Nothing else about a unit's shape changes: one statement per line, prefix operators, end blocks.

Step 2 — let the compiler hold the checks

om2
layout blk 8
field lo uint at 0 little
field hi uint at 4 little
end
abstract v32 ulong
holds v32 dup32
note the erasing constructor: the body must be exactly this line
fn v32mk x uint to v32
ret seal v32 or shl ulong x 32 ulong x
end
fn stamp c edit blk to uint
put c lo 0x01020304
put c hi 0x05060708
ret or get c lo shl get c hi 16
end

Three things are now checked by omc rather than at run time or not at all:

Step 3 — compact rounds

om2
fn rounds s edit uint 8 fresh to uint
for i uint 8 unroll
put s i add rotr 0x9e3779b9 i 7
end
ret get s 3
end

unroll emits the body eight times with i constant, so the loop branch and counter disappear; rotr with a number amount becomes one ROR. Removing unroll changes size and speed, never behaviour. The same is true for inline. Both are bounded by contract, not by hope: 64 copies per loop, 4 inline levels and 65536 expansion fuel per function, 16 registers (errors 14 and 12). A function's emitted words have no bound since 2026-11-11 (OMEGESE 9.6).

Folding happens only inside an unrolled or inlined body, and never for an operation that would trap. A number index into a sized array (up to 4095) becomes an immediate offset with no run-time check; every other index keeps trap 3. Constants do not fold through parameters.

Step 4 — one view, one slice, no wrapping arithmetic

om2
fn fold a view uint * to uint
x = new uint 1 0
put x 0 uint len a
for i uint uint len a
put x 0 add get x 0 rotr get a i 5
end
ret get x 0
end

a view uint * takes any length and len a is its run-time count. Every index into it is checked at run time, including a number, and is never eliminated.

part A o k slices only as a call argument for an unsized parameter, and it checks o <= len A then k <= len A - o — the wrapped o + k is never formed. That matters at the edge: with len A = 10, o = 2^64-2, k = 4, a wrapped sum test would pass; OM-2 traps 3.

A complete, compiled example of steps 2, 3 and 4 together is examples/om2-tour.om (sha256 856c541d…315f). Observed with the pinned compiler: compile exit 0, run exit 0; changing one constant inside stamp gives exit 11; holds v32 dup31 gives exit 28; and with om2 diag the same unit emits 15 omc-site records plus one omc-check 1 erased line=11 rule=dup32 — the erased constructor check, proved from the exact body shape rather than asserted.

Step 5 — compile, run, refuse

OMC=seed/out/omc                     # check its sha256 against section 1 first
"$OMC" < prog.om > prog 2> prog.err; echo "compile rc=$?"; cat prog.err
chmod +x prog && ./prog; echo "run rc=$?"

Program exit status is main's value mod 256; a runtime trap exits 100 + code. Never run the output of a non-zero compile — a refusal may still leave bytes on stdout.

Refusals observed with the pinned compiler (omc: line N: error K, exit K):

SourceObserved
x = uint 0x100000000exit 8 (number out of range)
x = uint 0X10exit 6 (malformed number)
part a 0 2 as a statementexit 9 (word in a disallowed place)
rotr 1 1 in a unit without om2exit 3 (unknown word)
om2 twiceexit 16 (syntax)
holds v32 dup31exit 28 (obligation=ctor)
a layout field past SIZEexit 29 (obligation=layout)
a get of an unwritten fresh elementexit 27 (obligation=init)

With om2 diag, stderr also carries `omc-diag 1 code=… sev=… line=… col=… span=A-B expect=… found=… obligation=… profile=OM-2, one omc-site 1 line=N iter=k` per run-time trap site, and one omc-check 1 kept|erased line=N rule=dup32|- per seal.

Step 6 — a unit with no main is called through the bridge

A unit without fn main compiles to bare words and is not runnable on its own. export fn NAME ... marks the entries: with any export, words 0..E-1 branch to the exports in source order, E ≤ 32, and the other functions are private. NAME out T N declares a caller-owned buffer that the binding copies out after status 0. aien-dev/omega-bridge owns the ABI and refuses what it cannot convert; the sha256_* compatibility wrappers in the generated binding are out-of-line so that a freestanding object including only the declaration header still needs nothing from libc beyond mem*.

Step 7 — the whole thing, on SHA-256

om/sha256/sha256-om2.om is 344 lines, 72 of them the K/IV tables, replacing a 4,096-byte C adapter plus an OM-1 unit. Measured on the same machine, interleaved, protocol fixed before the run (spec/omegese-om2-measure.md):

Workloadacb3f15c (OM-1 + C adapter)OM-2 cutoverratio
1 MiB, one call152.5 MB/s210.2 MB/s0.726
1 MiB in 1-byte updates14.3 MB/s32.8 MB/s0.436
55 bytes496 ns560 ns1.129 (declared REGRESSION)
64 bytes896 ns816 ns0.911

3. Guarantee matrix

Read each row as: what the compiler proves, what it checks at run time, what nothing establishes. The class column is the strongest claim the current evidence supports; MEASURED numbers are HOST AArch64 only.

Functional

ClaimStatusEvidence
OM-2 SHA-256 agrees with the historical C on 2,000 casesSUPPORTEDtests/gates/run.sh om-units: SHA256-PARITY PASS cases=2000 diff=0
Agrees with independent oracles (sha256sum 9.4, OpenSSL 3.0.13 hashlib)SUPPORTED158 fixture vectors, 3,200 seeded random messages, 6 digests cross-checked in the measurement run
Every OM-1 unit keeps its meaningSUPPORTEDC2 manifest 5,876/5,876 byte-identical outputs or identical errors, per commit
A wrong rotate count, K, IV, schedule index, pad byte, length or count is caughtSUPPORTED17/17 unit mutants killed, one class (a 32-bit truncated count) caught only by the ≥2^32-byte receipt
The compiler itself is consistent (fixpoint)SUPPORTED, not diverse compilationbirth om4(omc) = omc = omc(omc) at every slice commit
Behaviour of arbitrary OM-2 programsNOT ESTABLISHEDfixtures and mutants only; no proof, no exhaustive coverage

Bounds

ClaimStatusEvidence
Every index into an unsized view is checked, numbers includedSUPPORTEDv6-idx, v6-write, and the view-nocheck mutant killed
Constant indices into sized arrays are checked at compile timeSUPPORTEDerror 21 fixtures; up to 4095 lowered to an immediate offset
part checks o <= len A, then k <= len A - o, o before kSUPPORTEDv6-part-wrap, v6-part-tail, v6-part-o, v6-part-order; three independent mutants killed
Host I/O slices are checked against the countSUPPORTEDexisting OM-1 rules, unchanged
A trap that is unreachable in practiceNOT ESTABLISHEDthe model is "every check that is not proven stays"

Initialization

ClaimStatusEvidence
A fresh element read before a definite write is refusedSUPPORTEDerror 27 fixtures, 5 fresh mutants killed, join-intersection rules gated
A layout-typed context is fully written before it is readSUPPORTED for the SHA unitf5-part, and the mutant that leaves w[15] unwritten is error 27 at that line
fresh analysis across arbitrary control flowPARTIAL BY DESIGNif-without-else, while and rolled for do not advance the set; that is conservative, never optimistic
Stack exhaustion from deep recursionUNSUPPORTED as a statusa fault, not a returned status (trap 6 covers the local-array budget only)

Module and FFI boundaries

ClaimStatusEvidence
Units compose by concatenation; there is no importSUPPORTED (a limit, not a feature)OM-1 rule, unchanged in OM-2 (FR-3 open)
ABI v2: omega2_<export> symbols, omega2_ident_<unit>(), out through a caller bufferSUPPORTEDidentity records (E1), 19 status-32 refusals that leave state untouched, six-language v1 refusal
A freestanding object needs no new libc surfaceSUPPORTEDrx_cortex.o undefined set identical to main's; RX_CX_FS_ALLOWED unchanged (E18)
Calling convention drift between compiler and bridgeDETECTED, not preventedthe bridge refuses unknown slots/statuses; a mismatch surfaces as status 32 or a link error
Packed structs, imports, shared objects, heapUNSUPPORTED at this pinFR-2, FR-3, FR-7, decision 24

Timing and leakage

ClaimStatusEvidence
The OM-2 SHA's init and hash are clean under the static scannerSUPPORTEDpub: scan PASS
The OM-2 SHA's update and final are clean under the static scannerNOT_RUN83 and 3 MANUAL branches, 67 and 1 data-indexed accesses, all derived from the byte-count field the scanner cannot treat as public
Equal-length messages take the same instruction pathMEASURED on 28 pairssingle-step traces identical; negative controls detected
Constant-time behaviour in generalNO CLAIMtrace equivalence only (E12); speculative constant-time is UNSUPPORTED
PerformanceMEASURED, see section 2 step 7bulk 1.38× faster; 1–55-byte inputs 6.5–12.9% slower under the predeclared policy

Effects and authority

ClaimStatus
A guide, a model review or a passing gate grants no authority to run anythingRULE
Host execution is not hardware qualification, and no GPU or device claim is made hereRULE
Merging this stack moves main's compiler pin for every consumerRULE: the stack lands as one unit or not at all

4. What to do when the compiler refuses

  1. Read the code: 27 is initialization, 28 is constructor discipline, 29 is layout, 14 is growth/fuel and also the 33rd export, 12 is registers, 9 is a word in the wrong place.
  2. Reproduce it as small as possible in the same profile, and keep the smallest failing unit.
  3. Decide which side is wrong: your program, a documented limit (OMEGESE §9.13), or the compiler. A limit is not a bug, and an unimplemented word must be reported as such — never worked around in C.
  4. Fix one thing, rerun the unit and a negative control, and record the pin you used.