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 / OSC-3-DESIGN.md

318 lines · 18741 bytes Raw Blame History Source

OSC-3 design: the third Omega Systems Core compiler slice

OSC-3 slice; not a general Omega compiler; no self-hosting.

OSC-3 builds on OSC-2 (docs/osc/OSC-2-DESIGN.md; omega #148..#151) under ADR OMEGA-SYSTEMS-CORE-0000. Each item is its own pull request, merged before the next, with a content-addressed receipt in evidence/OSC-3/receipts/ written by make osc3-receipt ITEM=<item> PHYSICS_DIR=<pinned physics>.

Every OSC-3 receipt records: make test-compiler-full PASS (plain and ASan/UBSan), contract/struct/arena fuzz with 0 mismatches, runtime model replay with 0 rejected runs, the full legacy writer differential, golden and negative counts, the golden corpus digests compared program by program with the OSC-2 encoder receipt (identical unless the item says why), cross-process determinism, and the M6/M9/M14 gate logs compared by sha256 with the OSC-2 encoder receipt. Item-specific evidence lines start with osc3 <item>:.

Item 0: owed external review of OSC-2

OSC-2 (#148..#151) was reviewed only by the Gemini fallback because Codex was at its usage limit. The owed Codex review ran on 2026-10-01: first attempt 11:30Z refused (usage limit, reset 12:03Z); second attempt 12:04Z, codex exec -s read-only -c model="gpt-6-astra" over git diff 0abdb08^..7e713e3 -- src/compiler src/language tests/compiler mk/compiler.mk src/aarch64_encoder.c, asked for correctness bugs only (miscompilation, interpreter/native disagreement, missed contract traps, unsound ownership/borrow/arena checks, compiler memory safety, layout, encoder ranges) with concrete failing inputs. Result: NO FINDINGS. No item 0 fix PR was needed; the result is recorded here and in the item 1 pull request.

Item 1: quick and full compiler suites

make test-compiler had grown to 1m32..2m23 single core, mostly the legacy writer's exhaustive differential and the full fuzz counts, against a 3-minute budget. It is split:

The quick wall time is measured inside every OSC-3 receipt (test_compiler_quick.wall_seconds, binaries already built).

CI: the compiler job in .github/workflows/host-suites.yml runs quick on every pull request touching the compiler paths and full when src/compiler/ or src/aarch64_* changes. Since omega #154 (Lane 34) the workflow also runs on every push to main, and the compiler job then runs quick and full, so main has its own post-merge result (the 2026-10-01 audit found the compiler suites never ran after merge). An earlier draft of this item added a separate compiler-main.yml for this; it was dropped as redundant after #154.

Item 2: versioned handles

The OSC-0B model (src/compiler/model/osc_model.h) gives slots u64 generations with SLOT_ALLOC / SLOT_FREE / HANDLE_USE events: a use or free with the wrong generation is STALE_GENERATION, and a slot freed at gen_max is retired, never wrapped (GENERATION_WRAP). Item 2 compiles that discipline.

Subset

Grammar

stmt   += 'pool' NAME ':' '[' scalar ';' INT ']' ( 'gen' INT )? block
        | 'let' 'mut'? NAME ':' 'handle' NAME '=' hexpr ';'
        | NAME '.' 'free' '(' NAME ')' ';'
        | NAME '[' NAME ']' '=' expr ';'      (pool write)
        | NAME '=' hexpr ';'                  (handle rebind, NAME mut)
hexpr  := NAME '.' 'alloc' '(' expr ')' | NAME   (a handle of the same pool)
expr   += NAME '[' NAME ']'                   (pool read)

gen INT declares the generation base (default 0): every slot starts at that generation. It exists so tests can reach exhaustion with a few allocations; the base is part of the unit's canonical encoding.

Semantics

Static refusals (named)

The checker tracks a provenance per allocation; copies share it. A provenance is freed when every path freed it (branch merge intersects).

DiagnosticTransitionWhen
STALE_HANDLEread / write after freeuse of a handle whose slot was freed on every path
STALE_HANDLE... via a copythe same through a copy made before the free
STALE_HANDLEfree after freedouble free (also via a copy)
GENERATION_EXHAUSTEDretired slot reuseddefinite allocations exceed K x (2^64 - base)
POOL_CAPACITYpool fulldefinite live allocations exceed K
POOL_CAPACITYpool size outside 1..16K outside 1..16
WRONG_POOLhandle of another poolhandle of pool p used with pool q, or q.alloc bound as a handle of p
TYPE_MISMATCHhandle / pool used as a value; pool index not a handletype confusion
UNSUPPORTEDhandle crosses a function boundarypool or handle parameter or return type
IMMUTABLE_ASSIGNrebinding a handle declared without mut

"Definite" means at the pool's own loop and branch depth. Allocations inside loops or branches are not counted; once a free happens behind a branch or loop, the live count is no longer tracked statically (the generation count still is). What the checker cannot decide is checked at run time (the traps above).

Limits

Evidence

Measured on the Spark, single core, nice (full counts = `make test-compiler-full`, identical plain and under ASan/UBSan):

osc3 handles: units=125 compiled=102 static_refused=23 runs=4896 ok=2705 stale_traps=1616 pool_full=530 retired=45 overflow=0 mismatches=0
osc3 handles: model replay pool_events=48807 stale_confirmed=1616 wrap_confirmed=45 full_confirmed=530 windows=0 (handle fuzz runs only)
osc3 handles: serial counters at UINT32_MAX trap RUNTIME, never wrap: 4 of 4
runtime model replay: ... rejected=0

Item 3: drop flags (conditional moves)

OSC-1 and OSC-2 refused any move of an owner inside an if (CONDITIONAL_MOVE, OSC-1-DESIGN "no drop flags"). Item 3 accepts it: an owner that is moved on some paths and not on others gets a hidden drop flag, and its scope-end release runs only when the flag says live. This supersedes the OSC-1 rule; CONDITIONAL_MOVE keeps its number but is no longer emitted.

Subset

Grammar

No new syntax. The grammar of OSC-2 is unchanged; programs that OSC-2 refused with CONDITIONAL_MOVE are now accepted when the rules below hold.

Semantics

Static refusals (named)

DiagnosticTransitionWhen
USE_AFTER_MOVEuse after maybe-moveread, write, field access or call use of a maybe-moved owner ("used after it may have been moved at line N (moved on some path of an 'if')")
USE_AFTER_MOVEuse after maybe-moveborrow (& / &mut) of a maybe-moved owner
USE_AFTER_MOVEuse after maybe-movemoving a maybe-moved owner again (double move across branches / two ifs)
USE_AFTER_MOVEuse after move (move inside loop)an owner declared outside a loop moved inside it, also inside an if in the loop (unchanged from OSC-1)
IMMUTABLE_ASSIGNassign to immutable bindingre-assigning an owner, maybe-moved or not ("owners are never reassigned"); item 3 does not add a set-live rule

For the model the maybe-move refusals are use-after-move: the checker emits an accepted MOVE obj -> 0 (the path that moved it) right before the refused event, so the negative harness replays them as use-after-move.

Limits

Evidence

EVIDENCE_PLACEHOLDER

Generation width: remaining 32-bit sites and fix plan

ADR OMEGA-SYSTEMS-CORE-0000 decision 1 fixes capability and object generations at u64 end to end, a slot retired at the maximum, never wrapped. The 2026-10-01 audit (track 2, s.F.3) found these sites still 32-bit; checked against main 07004a8. A u64 generation stored into any of them is silently truncated, and a truncated generation can make a stale handle look live again.

Site (main 07004a8)TodayOwnerFix plan
src/runtime/rx_world.h:177 RxObjRef{uint32_t id; uint32_t generation}u32runtime lane (src/runtime)widen generation to u64; retire the object id at UINT64_MAX; versioned like omega#71
src/runtime/rx_world.h:305 object generationu32runtime lanesame change, same PR as :177
src/runtime/rx_world.h:328 RxSub{reaction; generation; mask}u32runtime lanewiden with :177 (subscriptions compare against object generations)
src/runtime/rx_world.h:599 seat_generationu32runtime lanewiden; retire the seat at max
src/runtime/rx_graph.c:517, :529 crumb/graph hash writes object generations with put32u32 on the wireruntime laneput64 together with a crumb/graph record version bump (old records refused, not reinterpreted), in the identity-break sequence (item 5)
src/runtime/rx_jspace.c:1406, :1413, :1414 J-Space body writes branch/slot generations with put32u32 on the wireruntime laneput64 with a J-Space record version bump, same rule
src/omega_accelerator.h:67, :87 uint32_t capability_generationu32accelerator owner (not OSC)widen to u64, retire at max; ADR decision 1 names this file
src/compiler/osc_rt.h slot_serial[], next_serial, pool_serialu32, never wraps (item 2)OSC (this lane)done in item 2: handle generations are u64 with retire-at-max; the serials stay u32 (hashed into the event log as 4 bytes) and an allocation, arena open, arena allocation or pool open with its counter at UINT32_MAX traps RUNTIME before any state changes (item 2, Limits)
Aienux ADR 0013 (index u32; generation u32, retire at u32::MAX)u32aienos lanerequest only, see item 5 (docs/osc/OSC-3-ADR0013-REQUEST.md); not edited from this repository

Only the osc_rt row is inside this lane's files. The others are listed so the owning lanes can schedule them; each is a versioned change with old records refused, never reinterpreted. Only the osc_rt row is applied by OSC-3 (item 2).

Slice order after item 4

Per the audit (III.7 and the 2026-10-01 review), the first real migration is crumbline (src/crumbline/) once effects and capabilities exist: item 4 (effects/capabilities), then item 5 (identity break + ADR 0013 request), then item 6 (crumbline as the first production C module under contracts; proposal in docs/osc first).