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/src/runtime/omega_shared_world_abi.h # 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 / src / runtime / omega_shared_world_abi.h` 315 lines ยท 15865 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* 18 * omega_shared_world_abi.h -- Canonical OMEGA_SHARED_WORLD_V1 ABI (frozen). 19 * 20 * This is the ONE canonical, pointer-free, fixed-width binary contract for the 21 * PHYSICS-owned coherent shared-memory world that is physically visible from 22 * both the CPU (where AEGIS executes) and the GPU (where AIEN executes). 23 * 24 * AIEN PROPOSES. OMEGA DEFINES. PHYSICS REALIZES. AEGIS VERIFIES. 25 * HARDWARE ACTS. EVIDENCE TEACHES. 26 * 27 * The *semantics* of this layout are defined by OMEGA doctrine 28 * (aien-architecture doctrine/OMEGA.md 9.2 and docs/adr/0014). The *physical 29 * realization* of the coherent memory that this layout is interpreted over is 30 * owned by PHYSICS (coherent/physics_coherent.*). This header is placed in the 31 * PHYSICS repository so that both PHYSICS and OMEGA compile against a single 32 * definition with zero duplication (OMEGA already includes PHYSICS headers). 33 * 34 * ------------------------------------------------------------------------ 35 * DESIGN LAWS (M20 Stage 1) 36 * ------------------------------------------------------------------------ 37 * 1. POINTER-FREE. No field ever holds a host virtual address, GPU virtual 38 * address, RM object handle, kernel pointer, or physical address. Every 39 * cross-object reference is a *logical* {object_id, object_generation, 40 * offset, length} tuple that PHYSICS resolves internally against a trusted 41 * region, exactly as the M19 capability handle (accelerator-world.md 2.3) 42 * carries no GPU VA or size. This is the memory-level foundation of the 43 * invariant "AIEN can communicate with CPU-side authority without ever 44 * possessing CPU execution authority". 45 * 46 * 2. FIXED-WIDTH & LITTLE-ENDIAN. Every field is a fixed-width integer stored 47 * host-native little-endian (GB10 is little-endian on both the Arm CPU and 48 * the Blackwell GPU). This is the "Zero Serialization" contract: data is 49 * structured in memory exactly as the consuming execution unit expects, so 50 * both CPU and GPU interpret it directly with no marshalling. This is a 51 * DIFFERENT concern from OMEGA canonical *semantic* serialization 52 * (SPEC-OMEGA-CANON-M4), which is big-endian and exists only to derive 53 * content-addressed SEMANTIC_IDs by hashing. 32-byte id fields below are 54 * raw digests (byte arrays) and are therefore endian-neutral. 55 * 56 * 3. GENERATION & EPOCH PROTECTED. A world epoch guards the whole world; a 57 * per-object generation guards each logical reference; a per-slot sequence 58 * number guards each ring entry against stale reuse (ABA) and replay. 59 * 60 * 4. BOUNDED. Ring capacities are compile-time power-of-two constants. Every 61 * offset/length reference is bounds-checked at resolution. No unbounded or 62 * variable-length field appears anywhere in the shared world. 63 * 64 * 5. DETERMINISTIC & HOSTILE-INPUT CHECKED. Every reader treats the producer 65 * as potentially hostile: it validates magic, version, epoch, generation, 66 * sequence, message type, bounds and checksum before acting, and fails 67 * closed on any mismatch. 68 * 69 * This header is header-only and has no dependency on NVRM/UVM/M16. 70 */ 71 #ifndef OMEGA_SHARED_WORLD_ABI_H 72 #define OMEGA_SHARED_WORLD_ABI_H 73 74 #include 75 #include 76 77 /* ---- Versioning & identity ------------------------------------------- */ 78 79 /* Little-endian 32-bit magic "OSW1" (0x4F 0x53 0x57 0x31). Stored as a u32 so 80 * a reader on a little-endian machine sees this exact constant. */ 81 #define OMEGA_SW_MAGIC 0x31575330u /* 'O''S''W''1' LE */ 82 #define OMEGA_SW_ABI_VERSION 1u 83 84 /* 32-byte NUL-padded domain tag for the world state digest (matches the 85 * M19 rolling-state style "OMEGA_WORLD_ROLLING_STATE_V1\0..."). */ 86 #define OMEGA_SW_DOMAIN_TAG "OMEGA_SHARED_WORLD_V1" 87 88 /* Cache line / alignment. NVLink-C2C coherence granule on GB10 is 64 bytes. */ 89 #define OMEGA_SW_CACHELINE 64u 90 91 /* ---- Ring geometry (bounded, power-of-two) --------------------------- */ 92 93 /* SPSC ring capacity (entries). MUST be a power of two so index wrap is a mask. 94 * 1024 mirrors the discovered GPFIFO capacity used by M19. */ 95 #define OMEGA_SW_RING_CAPACITY 1024u 96 #define OMEGA_SW_RING_MASK (OMEGA_SW_RING_CAPACITY - 1u) 97 98 /* ---- Message descriptor (128 bytes = 2 cache lines) ------------------ */ 99 100 /* Message types carried on the rings. */ 101 enum { 102 OMEGA_SW_MSG_NONE = 0x0000u, 103 OMEGA_SW_MSG_XFORM_REQ = 0x0001u, /* CPU -> GPU: transform request */ 104 OMEGA_SW_MSG_XFORM_RES = 0x0002u, /* GPU -> CPU: transform result */ 105 OMEGA_SW_MSG_NOP = 0x0003u, /* keepalive / ordering probe */ 106 OMEGA_SW_MSG_SHUTDOWN = 0x0004u /* CPU -> GPU: ask worker to exit */ 107 }; 108 109 /* Descriptor flags (bitfield). */ 110 enum { 111 OMEGA_SW_FLAG_INLINE_PAYLOAD = 0x0001u, /* payload[] carries the operand */ 112 OMEGA_SW_FLAG_OBJECT_REF = 0x0002u, /* object_* names a shared object */ 113 OMEGA_SW_FLAG_CHECKSUM = 0x0004u /* checksum field is valid CRC32C */ 114 }; 115 116 /* Deterministic transform selector (Stage 1 qualification worker only). The 117 * worker is NOT AIEN; it proves the communication substrate with a trivial, 118 * unambiguous, reproducible operation. */ 119 enum { 120 OMEGA_SW_XFORM_XOR_CONST = 0x01u, /* out = in ^ arg_a */ 121 OMEGA_SW_XFORM_ADD_SEQ = 0x02u /* out = in + (uint32)sequence */ 122 }; 123 124 /* 125 * OmegaSharedWorldDesc -- one ring slot, exactly 128 bytes. 126 * 127 * Line 0 (control, offset 0x00..0x3F): 128 * the fully self-describing, hostile-input-checkable control record. 129 * Line 1 (payload, offset 0x40..0x7F): 130 * 64 bytes of inline payload OR the two 32-byte OMEGA identity digests 131 * (semantic_id, realization_id) that the doctrinal 64-byte intent entry 132 * defines. For the Stage 1 qualification worker the first 8 bytes carry a 133 * u32 input and receive a u32 output; the remainder is reserved. 134 * 135 * checksum is CRC32C over control bytes [0x00..0x3C) followed by all 64 payload 136 * bytes. It is defense-in-depth against torn / partially-published writes; the 137 * primary torn-write guard is the acquire/release sequence handshake. 138 */ 139 typedef struct OmegaSharedWorldDesc { 140 /* ---- line 0: control ---- */ 141 uint32_t magic; /* 0x00 OMEGA_SW_MAGIC */ 142 uint16_t abi_version; /* 0x04 OMEGA_SW_ABI_VERSION */ 143 uint16_t msg_type; /* 0x06 OMEGA_SW_MSG_* */ 144 uint64_t sequence; /* 0x08 monotonic per-ring sequence */ 145 uint32_t world_epoch; /* 0x10 owning world epoch */ 146 uint32_t producer_generation;/* 0x14 producer channel/world generation */ 147 uint32_t object_id; /* 0x18 logical object reference */ 148 uint32_t object_generation; /* 0x1C object generation (ABA guard) */ 149 uint32_t object_offset; /* 0x20 byte offset within the object */ 150 uint32_t object_length; /* 0x24 byte length within the object */ 151 uint32_t payload_len; /* 0x28 bytes of payload[] in use */ 152 uint16_t flags; /* 0x2C OMEGA_SW_FLAG_* */ 153 uint16_t xform; /* 0x2E OMEGA_SW_XFORM_* (Stage 1 worker) */ 154 uint32_t arg_a; /* 0x30 transform operand / constant */ 155 uint32_t arg_b; /* 0x34 transform operand / constant */ 156 uint32_t reserved0; /* 0x38 MBZ */ 157 uint32_t checksum; /* 0x3C CRC32C(control[0..0x3C) || payload)*/ 158 /* ---- line 1: payload ---- */ 159 uint8_t payload[64]; /* 0x40 inline payload / identity digests */ 160 } OmegaSharedWorldDesc; 161 162 /* ---- Ring control block (its own cache line, header-separated) ------- */ 163 164 /* 165 * OmegaSharedWorldRing -- one SPSC ring. 166 * 167 * head/tail are 64-bit monotonically increasing counters (NOT masked); the 168 * slot index is (counter & OMEGA_SW_RING_MASK). Using free-running 64-bit 169 * counters makes sequence-wrap a non-event for the lifetime of the machine 170 * (2^64 exchanges) and lets the consumer detect exactly how many entries are 171 * outstanding. The producer owns tail; the consumer owns head (SPSC). 172 * 173 * Each of head and tail sits alone on its own 64-byte line to prevent false 174 * sharing between the producer's and consumer's hot indices. The descriptor 175 * array follows, 64-byte aligned. 176 */ 177 typedef struct OmegaSharedWorldRing { 178 /* producer's published write cursor (release-published) */ 179 volatile uint64_t tail; 180 uint8_t _pad_tail[OMEGA_SW_CACHELINE - sizeof(uint64_t)]; 181 /* consumer's consumed read cursor (release-published) */ 182 volatile uint64_t head; 183 uint8_t _pad_head[OMEGA_SW_CACHELINE - sizeof(uint64_t)]; 184 /* immutable geometry (written once by PHYSICS at world init) */ 185 uint32_t capacity; /* == OMEGA_SW_RING_CAPACITY */ 186 uint32_t mask; /* == OMEGA_SW_RING_MASK */ 187 uint32_t world_epoch; /* owning world epoch */ 188 uint32_t ring_generation; /* bumped on world rebuild */ 189 uint8_t _pad_geom[OMEGA_SW_CACHELINE - 16]; 190 /* bounded slot array */ 191 OmegaSharedWorldDesc slots[OMEGA_SW_RING_CAPACITY]; 192 } OmegaSharedWorldRing; 193 194 /* ---- Fault mailbox --------------------------------------------------- */ 195 196 enum { 197 OMEGA_SW_FAULT_NONE = 0x0000u, 198 OMEGA_SW_FAULT_BAD_MAGIC = 0x0001u, 199 OMEGA_SW_FAULT_BAD_VERSION = 0x0002u, 200 OMEGA_SW_FAULT_STALE_EPOCH = 0x0003u, 201 OMEGA_SW_FAULT_STALE_GEN = 0x0004u, 202 OMEGA_SW_FAULT_BAD_SEQUENCE = 0x0005u, 203 OMEGA_SW_FAULT_BAD_MSGTYPE = 0x0006u, 204 OMEGA_SW_FAULT_OOB_OBJECT = 0x0007u, 205 OMEGA_SW_FAULT_BAD_CHECKSUM = 0x0008u, 206 OMEGA_SW_FAULT_WORKER_TIMEOUT = 0x0009u 207 }; 208 209 typedef struct OmegaSharedWorldFaultMailbox { 210 volatile uint32_t fault_code; /* OMEGA_SW_FAULT_* (0 = clear) */ 211 uint32_t world_epoch; /* epoch in which the fault was raised */ 212 uint64_t fault_sequence;/* sequence the fault is attributed to */ 213 uint32_t detail_a; /* fault-specific detail */ 214 uint32_t detail_b; 215 uint8_t _pad[OMEGA_SW_CACHELINE - 24]; 216 } OmegaSharedWorldFaultMailbox; 217 218 /* ---- Shared world header --------------------------------------------- */ 219 220 /* 221 * OmegaSharedWorldHeader -- the fixed prologue at offset 0 of the coherent 222 * region. It names the world, its epoch, and the byte offsets (relative to the 223 * region base) of each substructure. Offsets are stored (not pointers) so the 224 * region is fully relocatable and identically interpretable from any mapping 225 * on either processor. 226 * 227 * Reserved offset slots are declared now for the Stage 2/3/4 rings so their 228 * ABI space is frozen without implementing them: 229 * effect_ring, effect_result_ring, proof_ring, evidence_ring, 230 * semantic_store, agent_state. 231 * A zero offset means "not present in this ABI revision". 232 */ 233 typedef struct OmegaSharedWorldHeader { 234 uint32_t magic; /* 0x00 OMEGA_SW_MAGIC */ 235 uint16_t abi_version; /* 0x04 OMEGA_SW_ABI_VERSION */ 236 uint16_t header_bytes; /* 0x06 sizeof(OmegaSharedWorldHeader) */ 237 uint32_t world_epoch; /* 0x08 monotonic world epoch */ 238 uint32_t world_generation; /* 0x0C bumped on rebuild */ 239 uint64_t region_bytes; /* 0x10 total coherent region size */ 240 uint32_t ring_capacity; /* 0x18 OMEGA_SW_RING_CAPACITY */ 241 uint32_t desc_bytes; /* 0x1C sizeof(OmegaSharedWorldDesc)==128*/ 242 243 /* Byte offsets from region base (Stage 1 populated fields). */ 244 uint64_t off_cpu_to_gpu_ring; /* 0x20 */ 245 uint64_t off_gpu_to_cpu_ring; /* 0x28 */ 246 uint64_t off_fault_mailbox; /* 0x30 */ 247 uint64_t off_object_table; /* 0x38 logical object descriptor table */ 248 249 /* Reserved for future stages (zero == absent). */ 250 uint64_t off_effect_ring; /* 0x40 Stage 3 */ 251 uint64_t off_effect_result_ring; /* 0x48 Stage 3 */ 252 uint64_t off_proof_ring; /* 0x50 future */ 253 uint64_t off_evidence_ring; /* 0x58 future */ 254 uint64_t off_semantic_store; /* 0x60 future */ 255 uint64_t off_agent_state; /* 0x68 Stage 4 (tensor/KV handles) */ 256 uint64_t reserved_off[10]; /* 0x70..0xBF */ 257 258 uint8_t _pad[OMEGA_SW_CACHELINE - (0xC0 % OMEGA_SW_CACHELINE)]; 259 } OmegaSharedWorldHeader; 260 261 /* ---- Logical object table -------------------------------------------- */ 262 263 /* 264 * A shared object is a bounded, generation-tagged sub-range of the coherent 265 * region. Ring descriptors reference objects by {object_id, object_generation} 266 * plus an {offset, length} window; PHYSICS resolves these against this table 267 * and rejects any reference whose generation is stale or whose window escapes 268 * [0, size_bytes). The table stores a region-relative byte offset, never a VA. 269 */ 270 #define OMEGA_SW_MAX_OBJECTS 64u 271 272 enum { 273 OMEGA_SW_OBJ_REVOKED = 0u, 274 OMEGA_SW_OBJ_ACTIVE = 1u 275 }; 276 277 /* Permission bits (mirror OMEGA_PERM_* / PHYSICS allowed_ops). */ 278 enum { 279 OMEGA_SW_PERM_READ = 0x1u, 280 OMEGA_SW_PERM_WRITE = 0x2u 281 }; 282 283 typedef struct OmegaSharedWorldObject { 284 uint32_t object_id; /* == table index */ 285 uint32_t generation; /* bumped on revoke/reuse (ABA guard) */ 286 uint32_t state; /* OMEGA_SW_OBJ_ACTIVE / _REVOKED */ 287 uint32_t permissions; /* OMEGA_SW_PERM_* */ 288 uint64_t region_offset; /* byte offset from region base (NOT a VA) */ 289 uint64_t size_bytes; /* bounded window size */ 290 } OmegaSharedWorldObject; 291 292 typedef struct OmegaSharedWorldObjectTable { 293 uint32_t count; 294 uint32_t world_epoch; 295 uint8_t _pad[OMEGA_SW_CACHELINE - 8]; 296 OmegaSharedWorldObject objects[OMEGA_SW_MAX_OBJECTS]; 297 } OmegaSharedWorldObjectTable; 298 299 /* ---- Compile-time invariants ----------------------------------------- */ 300 301 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 302 _Static_assert(sizeof(OmegaSharedWorldDesc) == 128, 303 "shared-world descriptor must be exactly 128 bytes (2 cache lines)"); 304 _Static_assert(offsetof(OmegaSharedWorldDesc, checksum) == 0x3C, 305 "checksum must be the last control word of line 0"); 306 _Static_assert(offsetof(OmegaSharedWorldDesc, payload) == 0x40, 307 "payload must start on the second cache line"); 308 _Static_assert((OMEGA_SW_RING_CAPACITY & OMEGA_SW_RING_MASK) == 0, 309 "ring capacity must be a power of two"); 310 _Static_assert(sizeof(OmegaSharedWorldObject) == 32, "object record must be 32 bytes"); 311 _Static_assert(sizeof(OmegaSharedWorldFaultMailbox) == OMEGA_SW_CACHELINE, 312 "fault mailbox must occupy exactly one cache line"); 313 #endif 314 315 #endif /* OMEGA_SHARED_WORLD_ABI_H */