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 / osc / audit / language-compiler.md

168 lines · 19660 bytes Raw Blame History Source

Appendix to OMEGA_SYSTEMS_CORE_CODE_AUDIT.md. Worker report (Opus, read-only), omega 193a7e7. Reviewed: spot-checked omega_program.c:276 raw-struct hash, aarch64_encoder.c:114,122 silent immediate truncation, absence of ADDS/BL/STP (confirmed). Correction: a SUBS-immediate emitter exists (aarch64_encoder.c:158); the report says there is no ADD/SUB immediate. Not authoritative on its own; Part II of the main document rules.

Omega language / IR / encoder / identity audit (OSC-0 / OSC-0B input)

Repo: omega worktree osc-0 at 193a7e7. Read-only audit plus one throwaway encoder probe (~/.claude/jobs/9d0b86f6/tmp/probe.c). Other docs: aienos ADR 0012 read live from GitHub, aienos main d39dd5b; local aien-architecture at 873025c on branch feat/resident-semantic-store-boundary (may lag origin). The Seed/Forge ADR 0012 lives in aienos, not aien-architecture (aien-architecture's 0012 is "shell-dispatch-then-landing").

Labels: [FACT] code fact, [SETTLED] decided in a doc, [PROPOSED] recommended OSC-0B decision, [OPEN] unresolved.


1. The Omega language as implemented (V0)

[FACT] Code: src/language/omega_lex.[ch] (197 lines), omega_parse.[ch] (429), omega_lower.[ch] (487). Test: tests/language/test_language_v0.c + tests/language/golden/v0.txt (27 golden rows). [FACT] The spec spec/omega-language-v0.md matches the code closely (the EBNF there is accurate).

Grammar the parser actually accepts (one statement per LINE)

line      = [ stmt ]
stmt      = "let" NAME ":" type "=" expr
          | "fn" NAME "(" NAME ":" type ")" "->" type ["requires" clause] ["ensures" clause] "{" expr "}"
          | expr [ ":" type ]
expr      = or [cmp_op or]         -- comparisons PARSE but lowering rejects them (-2)
or        = and { "|" and } ; and = add { "&" add } ; add = mul { ("+"|"-") mul } ; mul = prim { ("*"|"/") prim }
prim      = INT | "true" | "false" | NAME | "(" expr [":" type] ")"
type      = u8 | u16 | u32 | u64 | bool          (i8..i64 recognised, rejected -2)
INT       = decimal | 0x.. | 0b..  (<= 64 bits, decoded in lexer)
comments  = // ... | /* ... */

Real example that parses and lowers (per spec + golden file):

let x: u64 = 7
x * 2 + 1
fn f(x: u64) -> u64 requires x < 100 ensures result > x { x * 2 + 1 }

Spec/wished features NOT implemented

[FACT] No evaluator in the language; no comparisons/bool ops in lowering; no signed ints; no unary minus / !; no calls; no multi-param or non-u64 functions; no blocks, statements sequences, control flow, loops, mutation, structs/enums, slices, references, pointers, arrays, strings; no effects/authority; contracts not verified; programs not verified (is_verified=false). Multi-line source is not supported at all.

Data structures and memory

2. Other IR / compiler machinery

ThingFileWhat it really doesReusable as typed AST / verified IR target?
Semantic object graphsrc/omega_core.c, omega_types.h, omega_canonical.cContent-addressed DAG of VALUE/TYPE/OPERATION/APPLY objects; ops ADD..COMPILE incl. SELECT, SLICE, EQUAL, LESS_THAN; overflow policy WRAP/SATURATE/FAIL_CLOSED in op payloadGood pure-expression IR; has type tags for SIGNED_INT, SEQUENCE, TUPLE, ADDRESS, RESOURCE, CAPABILITY_REF already. No statements, locals, control flow, memory. Fixed 256 objects.
Program modelsrc/omega_program.c/.hOmegaProgram = name + contract text + cost + one RealizationObject; build_unary_op emits MOVZ/MOVK + one ALU op + RET; compose concatenates (drops RET). u64->u64 onlyNot a general IR. program_id hashes name/contract/cost bytes, NOT code (spec admits).
Realize (M5)src/omega_realize.cEmits fixed patterns for f_add_sub and single pure binary opsPattern emitter only.
realize_synthsrc/omega_realize_synth.c:34-50Ignores the program: always emits MOVZ x1,3; MUL; MOVZ 2; SUB (x*3-2), two schedules by issue widthFixed-output stand-in (same class as self-host).
Self-host (M6)src/omega_self_host.cConfirmed fixed-output stand-in: emitted "compiler" checks magic "OMGG", dispatches on object COUNT byte (8 -> writes 3 hard-coded words ADD/SUB/RET; 5 -> ADR self + copy-loop of its own instructions = quine).Not a compiler. Its two-pass label scheme (SET_LABEL, REL_IMM19) is the only fixup machinery in repo.
Action graph IRsrc/runtime/rx_graph.[ch], spec action-graph-ir.mdTyped goal->node graph (nodes, data/guard/order edges, auth[], res[], effects[] in total order), validated, optimised, lowered onto resident reactionsRuntime orchestration IR, not a language IR. Its identity/effect-order discipline is a good model.
Plan IRsrc/runtime/rx_plan.[ch]Plan templates + verified plan cache; semantic_id over sorted predicate listsSame: orchestration, not codegen.
State projectionrx_cortex, rx_projectionneed -> minimal projection of Cortex storeNot relevant to codegen.
Visorsrc/visor/*./omega REPL session: graph, bindings, programs table (16), realization/verify/evidence commands; hosts language V0The front door the new language should plug into.
Flow IRnone[FACT] Nothing named Flow IR. "flow" appears only as prose ("control flow", "flow control", plan-reuse.md §4 "Flow").Name is free.

3. Identity and determinism (OSC-0B items 3, 6)

How identity is computed

Nondeterminism

Live handle vs persistent identity (item 6)

4. Machine-code emitters

[FACT] src/aarch64_encoder.c (168 lines) is the only AArch64 encoder. Exact emittable instructions: ADD/SUB/AND/ORR/EOR (shifted register, no shift), MUL (MADD with XZR), MOV (ORR XZR), MOVZ, MOVK (any hw), RET, B, B.cond, CBZ, CBNZ, ADR, LDR/STR unsigned-offset (W/X), LDRB/STRB unsigned-offset, LDR/STR post-index (W and X), SUBS immediate, SUBS register (so CMP via rd=XZR). Users: omega_matvec.c, omega_matvec_quad.c (quad4 / M12 kinds), omega_realize*.c, omega_program.c, omega_self_host.c. (The Blackwell files emit GPU code, not AArch64.)

Probe (compiled against the real encoder, all matched the ARM reference words):

ADD X0,X0,X1 8B010000 OK | SUB X0,X0,X2 CB020000 OK | MUL X0,X0,X1 9B017C00 OK
MOVZ X0,#1 D2800020 OK | MOVK X0,#1,LSL16 F2A00020 OK | MOVZ LSL48 D2E00020 OK
LDR X0,[X1,#8] F9400420 OK | STR X0,[X1,#8] F9000420 OK
CMP X0,#1 F100041F OK | CMP X0,X1 EB01001F OK | B.EQ +2 54000040 OK | B.VS +2 54000046 OK
CBZ X0,+2 B4000040 OK | B -1 17FFFFFF OK | RET D65F03C0 OK | buffer-full -> rc=-1 OK
ADD rd=31 -> 8B0003FF (XZR, not SP)
LDR X0,[X1,#12] -> F9400420 == LDR [X1,#8]   <-- SILENT MISENCODING (no alignment check)
CapabilityYes/NoEvidence
LDR/STR immediate offsetYES (unsigned, scaled)aarch64_encoder.c:112-126; misaligned offsets silently truncated; no range check (masked to 12 bits)
LDP/STPNOnot in encoder or decoder
Register ALU opsYES: ADD SUB AND ORR EOR MUL:13-61
MOVZ/MOVKYES:67-102
CMP + B.cond / CBZYES (CMP = SUBS to XZR):83-96,158-168
ADDS + B.VSNO ADDS (B.VS encodes; SUBS exists, so sub-overflow check is possible)no adds emitter
Mul overflow (SMULH/UMULH)NO-
SDIV/UDIVNO-
BL / BLRNO (RET only)-
Stack frame (SUB SP / STP FP,LR)NO: REG_SP == REG_XZR == 31 (aarch64_target.h:23-24); shifted-register ADD/SUB cannot address SP; no ADD/SUB immediate; LDR/STR with rn=31 would address SP but SP can't be adjustedprobe
Branch range checksNO (imm masked):78-96
Labels / fixupsonly ad hoc two-pass in omega_self_host.c-

Execution: [FACT] omega_exec_native_f3 (omega_exec.c:8-40) mmap RW, memcpy, __builtin___clear_cache, mprotect RX, call as uint64_t f(uint64_t,uint64_t,uint64_t), munmap. Same pattern inline in omega_realize_synth.c (~:150) and matvec. No ELF writer anywhere. Signature fixed to 3 u64 args. [FACT] Verification gate: omega_verify_v0_structural calls aarch64_validate_code_buffer (omega_verify.c:62), which rejects any opcode not in the decoder allowlist (aarch64_decoder.c, "Undefined/unrecognized AArch64 opcode") and requires a final RET. Every new emitter must be mirrored in the decoder, and "last instruction must be RET" breaks with multi-function code or trap stubs after RET.

Effort estimate for a tiny language backend (functions, stack locals, checked i64 arithmetic, bounds checks, calls to runtime alloc/free):

5. Verification machinery to reuse / stay consistent with

6. Lifetime vs authority vs placement today (item 12)

7. libc the substrate must replace (item 10)

Contradictions (doc vs code)

  1. README.md:19 "OMEGA is not a programming language, compiler..." vs spec/omega-language-v0.md (a language exists) and spec/self-host.md ("self-hosting compiler").
  2. spec/canonical-encoding.md §2 rule 4 "payload always big-endian" vs omega_core.c memcpy of host LE structs; omega-language-v0.md admits the ABI pin.
  3. spec/type-system.md:35 CAPABILITY_REF generation: u32 / EffectPayload.capability_generation u32 vs runtime RxCapRef/AienosCapRef generation u64 (also recorded in commit 8a7d95e).
  4. spec/self-host.md "compiles itself" vs omega_self_host.c count-dispatch + self-copy quine.
  5. spec/realize_synth.md machine-aware synthesis from a program vs omega_realize_synth.c:34-50 fixed x*3-2 code.
  6. spec/program.md:21 "verified native code" vs language lowering leaving is_verified=false and program_id not covering code.
  1. Syntax: extend V0, don't replace it. Keep its lexer rules, literal typing rule (no guessed widths), precedence, fn ... requires/ensures, and reserved list; activate reserved words (i8..i64, mut, struct, if/else/while/return, unsafe) rather than inventing new ones. Add multi-line source with a per-function arena (lift the 1-line/256-token/128-node limits).
  2. Typed AST stays disposable (as V0 settled); identity attaches to the lowered IR (call it Flow IR; name is free), never to syntax.
  3. Wire layout rule: every hashed/serialised byte comes from an explicit big-endian writer (the rx_graph put32/put64 pattern). No memcpy of structs into identity. Migrating the core payloads is a deliberate identity break (re-generate golden vectors once, with a version bump in the "OMG0" header), and fix the SynthesisTask hash range bug.
  4. Handle rule: separate types for durable identity (SemanticId) vs live handles ({id, generation} refs); live handles are forbidden in any canonical encoder (checker rejects the type in hashed payloads). Migrate EffectPayload to reference capabilities by SemanticId only, and settle generation width at u64 in the spec.
  5. Checked arithmetic default: new signed ints lower with OVERFLOW_FAIL_CLOSED (already an enum value) - trap, not wrap; V0 unsigned WRAP stays for back-compat.
  6. Backend for the slice: both, with roles. (a) Direct AArch64 via the extended in-repo encoder is the real backend (matches founding principle + no-outside-deps; the encoder is correct where it exists, per probe). (b) Emit C compiled by system cc only as a differential oracle in the V1 style (same program, two backends, compare results + traps), never shipped. Pros (a): sovereign, reuses exec/verify; cons: 4-7 worker-days, needs decoder mirror + fixups + SP support. Pros (b): fast, catches codegen bugs; cons: depends on gcc semantics (UB) - acceptable only as an oracle since gcc already builds Omega.
  7. Encoder hardening first: reject misaligned/out-of-range offsets and branch displacements (currently silently masked), distinguish SP from XZR in the API.
  8. Reproducible build check: add -ffile-prefix-map and a build-twice-compare gate for the new compiler; do not reuse the M6 C1==C2==C3 claim as evidence of compilation.
  9. [OPEN] Whether contracts (requires/ensures) become checked in the slice or stay text.
  10. [OPEN] Whether the new IR lives inside OmegaGraph (256-object fixed cap) or a new store.