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/seed/physics0/README.md # 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 / seed / physics0 / README.md` 138 lines ยท 7800 bytes Raw Blame History Rendered 1 # PD0 deterministic streams in Omega 2 3 This is a handwritten, additive `.om` successor for the **stream primitive 4 slice** of [`src/physics0/pd0_rng.c`](../../src/physics0/pd0_rng.c): FNV-1a64 tag 5 hashing, SplitMix64 state/next, stream initialization, and uniform micro-units. 6 `stream.om` is an actual native consumer of that primitive, not generated C or 7 a source-extension rename. It is designed to run without a C runtime when compiled with the 8 pinned seeded compiler below. Native compilation/execution of this candidate 9 is **NOT_RUN**; that runtime property still requires qualification. 10 11 The C world, planner, scorer, fixed-point arithmetic, constant sampling and 12 noise consumers are **not switched or deleted**. This is not a whole PD0 port, 13 a drop-in C ABI, a cryptographic RNG, or a production qualification claim. 14 The existing PD0 owner and tests remain authoritative for those consumers. 15 16 ## Contract 17 18 - `rngtag[256]` holds bytes. `rnginit(seed, n)` accepts `n` in 0..256 and exactly 19 `n` **nonzero** bytes. Empty tags are valid. High-bit bytes are unsigned. 20 These valid tags match the C string consisting of those bytes plus a trailing 21 NUL. Longer strings and embedded NULs are deliberately outside the bounded 22 adapter contract, not claimed to have the C function's truncation behavior. 23 - Initialization returns 0 and sets `rngstate[0] = seed XOR FNV1a64(tag)`, or 24 returns 2 on a bad tag without changing the prior state. The 256-byte buffer 25 is caller-owned; its unused tail is ignored. One global stream is supported; 26 it is not reentrant or thread-safe. All 64-bit seeds are accepted. 27 - `rngnext()` increments state by `0x9e3779b97f4a7c15` modulo 2^64, stores that 28 incremented state, then applies the exact existing SplitMix64 mixing steps. 29 `rnguniform()` consumes exactly one next word and returns word `% `1000001``. 30 - Omega's arithmetic must not accidentally replace C unsigned wrapping with 31 overflow traps: `rngadd` uses 32-bit halves, `rngmul` four base-65536 columns. 32 Addition intermediates are below 2^34. A multiplication column contains at 33 most four products <=65535^2 plus carry <262144, hence is below 2^35. Masked 34 digits alone are shifted into their final positions; no shift is by 64. 35 - `request.om` adapts a request of **8 little-endian seed bytes followed by 36 0..256 nonzero tag bytes**. `rngreqok(n)` validates length before indexing and 37 preserves stream state on refusal. No terminator, count, or newline is sent. 38 - `stream.om` reads that request through EOF and emits **eight consecutive 39 little-endian 64-bit words** (64 bytes). It handles partial reads/writes; 40 a 265th byte detects oversized requests. Exit 0 means success, 2 malformed 41 or oversized input, 4 I/O error. Malformed input produces no output. An I/O 42 error during output can leave a partial response; it is not transactional. 43 44 ## Source and compiler pins 45 46 C baseline and PR base: ``d863780eb42bd940349eba61a3d1c78b0b819941``. 47 `src/physics0/pd0_rng.c` SHA-256: 48 ``957efcd03de3d3153e4e46347969bd3649ebc84af95cf9f2e8c616a4e20ebf24``. 49 The contract is also recorded in `src/physics0/pd0_rng.h`; generators remain 50 isolated in `pd0_gen.c` and are not linked into this work. 51 52 Use the existing compiler owner's Linux AArch64 seed profile, not an old C 53 frontend or a new compiler implementation: 54 55 - Repository commit ``8921a65204c2daf6d66a61813e89854c145713da`` (PR #676). 56 - `seed/omc/omc.om` Git blob ``8e73c4f2c1d6736222f27ecd6dfdf796c27b4213``. 57 - Compiler source SHA-256 58 ``fe67a0c31e42fcf6d86fce786b0a16b46a95daf3c7da1af7b6974df68ecfe400``. 59 - Follow that checkout's `seed/README.md`, `seed/host/README.md`, and existing 60 `seed/omega-from-seed.sh` reconstruction/fixpoint procedure in a disposable 61 compiler checkout. The initial loader is the existing documented exception; 62 no C compiler, assembler or linker builds this candidate. 63 64 This source uses only integer scalars, bounded global byte/word arrays, 65 functions, loops, shifts, and read/write. Global/text/local identifiers stay 66 within eight bytes. It adds no host operations, shared compiler changes, 67 compiler binaries or bootstrap scripts to main. A correctly rebuilt/pinned 68 compiler is a prerequisite, not supplied or certified by this PR. 69 70 ## Native qualification procedure (NOT_RUN here) 71 72 On authorized Linux AArch64 hardware, after checking the compiler pin and 73 successfully reconstructing the existing compiler, set `OMC` to its absolute 74 `seed/out/omc` path. From this candidate checkout, compose the handwritten 75 sources in dependency order into a disposable directory: 76 77 ```sh 78 ( 79 set -eu 80 [ "$(uname -m)" = aarch64 ] 81 : "${OMC:?Set OMC to the qualified pinned compiler's absolute path}" 82 B=$(mktemp -d) 83 cat seed/physics0/rng.om seed/physics0/request.om seed/physics0/unit.om > "$B/unit.om" 84 "$OMC" < "$B/unit.om" > "$B/unit" 85 LC_ALL=C readelf -h "$B/unit" > "$B/unit.elf" 86 grep -q 'Class:.*ELF64' "$B/unit.elf" 87 grep -q 'Machine:.*AArch64' "$B/unit.elf" 88 grep -q 'Type:.*EXEC' "$B/unit.elf" 89 chmod +x "$B/unit" 90 "$B/unit" # require exit 0, not just successful compilation 91 cat seed/physics0/rng.om seed/physics0/request.om seed/physics0/stream.om > "$B/stream.om" 92 "$OMC" < "$B/stream.om" > "$B/stream" 93 LC_ALL=C readelf -h "$B/stream" > "$B/stream.elf" 94 grep -q 'Class:.*ELF64' "$B/stream.elf" 95 grep -q 'Machine:.*AArch64' "$B/stream.elf" 96 grep -q 'Type:.*EXEC' "$B/stream.elf" 97 chmod +x "$B/stream" 98 printf 'Candidate test artifacts: %s\n' "$B" 99 ) 100 ``` 101 102 Stop on any failing command; do not run a partially emitted executable. The 103 shell here only composes/launches files, not implements the primitive. No new 104 shell/Python/C automation is added. The current x86_64 authoring environment 105 has **not** run these commands or any bundled AArch64 program. 106 107 `unit.om` checks raw state 0/max (including increment wrap), modular carries 108 and products, both seed extremes for empty/ASCII/high-bit/capacity tags, 109 38 fixed C next-word answers, state advancement, one-draw uniform behavior, 110 refusal-state preservation, short/oversized/NUL requests, a mixed-byte seed, 111 and response packing with independently fixed first-word bytes. 112 113 Before qualification, also exercise the compiled stream via real stdin/stdout: 114 empty/7-byte requests -> exit 2 and zero bytes; 8 zero bytes -> exit 0 and 64 115 bytes beginning `30 ff a4 6b 01 7c 81 c3`; all-FF seed with 256 `a` bytes -> 116 exit 0; a 265-byte request or NUL tag -> exit 2 and zero bytes. Check interrupted 117 and partial I/O, and descriptor failures (exit 4), under the existing owner's 118 native I/O test facilities. In a disposable source copy, alter the increment, 119 first FNV multiplier, or seed byte order separately; the unchanged unit test 120 must return nonzero. Retain exact source/compiler hashes and outcomes. These 121 native positive, refusal, I/O and mutation runs remain **NOT_RUN**. 122 123 ## Checks actually performed 124 125 On x86_64, the unmodified pinned C source was compiled with GCC solely as a 126 disposable reference. A separate checked-integer host model of the handwritten 127 limb formulas matched 10,000 modular add/multiply pairs, 1,000 nonzero byte tags 128 of lengths 0..256, and 32,000 sequential C words **and states**. All 38 committed 129 next-word constants were compared with that actual C baseline; identifier 130 bounds and whitespace checks passed. The disposable model/harness is not a 131 product implementation, compiler, or substitute for running `.om`. 132 133 Independent review also compared 100,000 arithmetic pairs and 48,000 words and 134 states across 1,500 tags against a separately GCC-built C baseline. This is 135 source/model evidence only. Native compile, native unit/consumer execution, 136 compiler regression gates, signed hardware evidence, and production-consumer 137 qualification are **NOT_RUN**. Do not delete C or claim migration completion 138 until the existing owners qualify and switch the real consumers.