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
omega-mv / spec / universal / translation-v1.md
| 1 | # Translation handoff contract v1 (#624 G0) |
| 2 | |
| 3 | Status: FROZEN for the first executable slice (G1, C17 pure u64) on 2026-10-25 by the #624 integration |
| 4 | coordinator. Additive. It changes no existing format: `semantics.md`, `source-aware-v1.md` (OMSB/OMSA/OMSP |
| 5 | v1), `c-u64-import-v1.md`, OSC, Omegese, checker2 and every v1 identity stay byte-identical. A change to |
| 6 | anything below needs `translation-v2.md`, never an edit of this file. |
| 7 | |
| 8 | ## 1. Frozen inputs (exact bytes) |
| 9 | |
| 10 | | input | identity | |
| 11 | |---|---| |
| 12 | | semantics `spec/universal/semantics.md` (#625, reviewed 69790fb4/c1da86d6) | sha256 `d4ed6148bfa97cc693d3fa4495e2d7e2e68aba04607a7e96dd9a9c54bf9073a8` | |
| 13 | | upper envelope `spec/universal/source-aware-v1.md` (#621 cd2c41f3) | sha256 `e0efbc717b61976614c1a1e9eee543284bcfb5410922d23b4ad70cb6a99615ec` | |
| 14 | | C import profile `spec/universal/c-u64-import-v1.md` (#622 50f75da2) | sha256 `84f06ce1ad1653bed08c940696b23d87ce22afb7ebb1b5c3e5970a23b3916012` | |
| 15 | | importer/codec toolchain | as pinned by those specs (bridge seed `0fc7d866`, compiler `191b776e…98e9`), unchanged | |
| 16 | | native realization compiler | omega-mv seed `seed/out/omc`, sha256 `734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61`, born from the seed by `seed/omega-from-seed.sh` | |
| 17 | | native binding generator | omega-bridge `src/native.om` at `012860dbf26ee62a9838594b9dfd1e3e94a540a9` (#8, #12 last-function entry + private helpers, #13 read-only runtime table) | |
| 18 | |
| 19 | ## 2. Semantic profile S1 (the only shared profile of G1) |
| 20 | |
| 21 | One pure function of 0..6 u64 inputs returning u64; values are integers modulo 2^64; operations are |
| 22 | constants 0..2^64-1 and add, sub, mul modulo 2^64 (upper ops 1, 2, 3, 4, input op 9). No division, |
| 23 | shifts, bitwise operators, comparisons, control flow, recursion, memory, calls, effects, exceptions or |
| 24 | runtime. Representation limits are those of the upper v1 envelope: 1..64 SSA results including inputs |
| 25 | and constants, the last result is the function result, input slot immediates are a permutation of |
| 26 | 0..n-1 (unused inputs are kept), source at most 4096 bytes, envelope input at most 8192 bytes. |
| 27 | |
| 28 | An upper unit is in S1 iff it decodes under source-aware v1 with language 1 profile 1 runtime 0 ABI 1, |
| 29 | and every operation is of type 1, effects 0, alias 0, with exactly these attribute/obligation fields |
| 30 | (source-aware-v1.md typed registry): input op 9 attribute 0 obligations 1; constant op 1 attribute 1 |
| 31 | obligations 0; add/sub/mul ops 2/3/4 attribute 1 (modulo 2^64) obligations 1. |
| 32 | (Rust profile 2 and Python profile 4 units use the same operations and join S1 in G2; their source |
| 33 | profiles are separate. Profile 4 adds obligation 4, source-explicit-masking, to arithmetic.) |
| 34 | |
| 35 | ## 3. Observable equivalence |
| 36 | |
| 37 | Two artifacts agree on S1 iff for every input vector they return the same u64, and both refuse or both |
| 38 | accept (with the declared status) the same source. Evidence classes, never mixed in a claim: |
| 39 | - REFERENCE: the #625 integer model evaluated on Python bigints with explicit `& (2^64-1)`. |
| 40 | - DIFFERENTIAL: finite input sets (boundary values 0, 1, 2, 2^32-1, 2^32, 2^63-1, 2^63, 2^64-2, 2^64-1 |
| 41 | per input, plus seeded random vectors) compared across artifacts. |
| 42 | - PROOF: none in G1. Equal SHA256 semantic identities are content identity, not equivalence. |
| 43 | |
| 44 | ## 4. The importer's `+0` normalization |
| 45 | |
| 46 | The C importer appends a synthetic `const 0` (empty span) and `add(root, that const)` so the returned |
| 47 | value is always the last SSA result (`c-u64-import-v1.md`). Rules: |
| 48 | - A unit is NORMALIZED iff it has at least 3 results, result n-2 is `const 0` and result n-1 is |
| 49 | `add(r, n-2)` with r < n-2. The normalization adds exactly one such pair per import. |
| 50 | - Exporters emit the expression of r (the pre-normalization root) for a NORMALIZED unit, and the |
| 51 | expression of the last result otherwise. They never strip a second, source-written `+ 0ULL`. |
| 52 | - Round-trip check: import(export(U)) must have the same semantic identity as U for a NORMALIZED U from |
| 53 | the C importer (the re-import adds the pair back). A unit that is not NORMALIZED gains one pair on |
| 54 | re-import; its round trip is checked by equal evaluation (section 3), and the identity difference is |
| 55 | recorded, not hidden. |
| 56 | |
| 57 | ## 5. Lowering seam (compiler/core lane): upper -> restricted .om -> native |
| 58 | |
| 59 | `tools/adapters/lower` (Omega source `src/adapters/upper-lower.om`) reads one S1 envelope on stdin and |
| 60 | writes one restricted Omegese function-mode unit on stdout: |
| 61 | |
| 62 | ``` |
| 63 | note omega.universal.lower.v1 semantic <64 lowercase hex of the unit's semantic identity> |
| 64 | fn <name> i0 ulong i1 ulong ... to ulong (exactly n inputs, slot order; "fn <name> to ulong" for 0) |
| 65 | v = new ulong <count> 0 |
| 66 | put v <k> i<slot> (op 9) |
| 67 | put v <k> <decimal> (op 1) |
| 68 | put v <k> add|sub|mul get v <a> get v <b> (ops 2, 3, 4) |
| 69 | ret get v <count-1> |
| 70 | end |
| 71 | ``` |
| 72 | |
| 73 | One line per SSA result in record order; `<name>` is `calc` unless the caller passes a name |
| 74 | (`lower NAME`, a C identifier of at most 63 bytes that is not an Omegese reserved word). Output is |
| 75 | byte-deterministic. Refusals: non-S1 unit 68 PROFILE_MISMATCH; malformed envelope 65; bad name 64. |
| 76 | Native realization = the pinned omc compiling that unit in function mode, bound by the pinned bridge |
| 77 | generator as `uint32_t omega_<name>(uint64_t *result, uint64_t i0, ...)` (status 0 ok). |
| 78 | |
| 79 | ## 6. C export (#622 lane): upper -> newly generated C17 |
| 80 | |
| 81 | `tools/adapters/c-export` (Omega source `src/adapters/c-u64-export.om`) reads one S1 envelope on stdin |
| 82 | and writes C17 source on stdout, generated from the operation records only (the sidecar's stored bytes |
| 83 | are never read for output; a semantic-only envelope must export identically). Frozen output form: |
| 84 | |
| 85 | ``` |
| 86 | #include <stdint.h> |
| 87 | uint64_t <name>(uint64_t i0, uint64_t i1, ...) { return <expr>; } ("(void)" for 0 inputs) |
| 88 | ``` |
| 89 | |
| 90 | followed by one LF. `<expr>`: input slot s is `i<s>`; a constant is `<decimal>ULL`; a binary op is |
| 91 | `<A> + <B>`, `<A> - <B>` or `<A> * <B>` with single spaces, parenthesised only where C precedence and |
| 92 | left associativity require it to keep the exact SSA tree: with precedence leaf 3, `*` 2, `+`/`-` 1, a |
| 93 | left operand gets parentheses iff its precedence is lower than the parent's, a right operand iff its |
| 94 | precedence is lower than or equal to the parent's (so `a+(b+c)` and `a-(b-c)` keep their tree, a |
| 95 | left-leaning chain `a+a+...+a` is emitted without parentheses). Shared SSA results are expanded as |
| 96 | trees (C has no sharing in this profile); the root per section 4. The output must import under |
| 97 | `c-u64-import-v1` (so: at most 4096 bytes, parenthesis depth at most 16, at most 64 upper operations |
| 98 | after re-import). An export that would break any of these refuses 67 LIMIT with no stdout; it never |
| 99 | writes unimportable C. The other refusals are the same as lowering (section 5): malformed envelope 65, |
| 100 | non-S1 unit 68, bad command or name 64. `<name>` is `calc` unless given (`c-export NAME`, |
| 101 | C-import-profile name rules). |
| 102 | |
| 103 | Required boundaries: every F1 positive and every accepted boundary control of `c_import_controls.py` |
| 104 | (including operation-capacity, the 61-term `a+...+a` chain at 64 operations, and nesting-limit, 16 |
| 105 | redundant parentheses that export without any) must export, re-import to the same semantic identity |
| 106 | (section 4), and evaluate equal. A required boundary that refuses is a FAIL of the export lane, not an |
| 107 | accepted limit. |
| 108 | |
| 109 | ## 7. Process and concurrency rules |
| 110 | |
| 111 | Every tool reads stdin to EOF, writes stdout only on success, names its refusal on stderr, and exits |
| 112 | with the statuses above. The #621 core and the importer use fixed global buffers and are not reentrant: |
| 113 | harnesses call them as separate processes, one at a time per artifact; no in-process sharing. |
| 114 | |
| 115 | ## 8. Fixture identities F1 (frozen) |
| 116 | |
| 117 | F1 = the 35 positive and 48 refusal sources of `tests/universal/c_import_gate.py` at this commit, |
| 118 | identified by the SHA256 of their exact bytes (`tests/universal/translation/fixtures-f1.json`, generated |
| 119 | from that file and checked against it), plus the 15 boundary controls of `c_import_controls.py`. New |
| 120 | fixtures get new IDs in a new fixture set; F1 IDs are never reused or edited. |
| 121 | |
| 122 | ## 9. Lanes and path ownership (one writer per path) |
| 123 | |
| 124 | | lane | owner | paths | |
| 125 | |---|---|---| |
| 126 | | integration, contract, fixtures, build, matrix (#624) | coordinator | `spec/universal/translation-v1.md`, `tests/universal/translation/fixtures-*.json`, `mk/translation.mk`, `docs/universal/MATRIX.md` | |
| 127 | | lowering + native realization (compiler/core) | compiler lane | `src/adapters/upper-lower.om`, `tools/adapters/lower`, `tools/adapters/build-lower.py`, `mk/lower.mk`, `spec/universal/upper-lower-v1.md`, `tests/universal/translation/lower_selftest.py` | |
| 128 | | C export (#622) | C adapter lane | `src/adapters/c-u64-export.om`, `tools/adapters/c-export`, `tools/adapters/build-c-export.py`, `mk/c-u64-export.mk`, `spec/universal/c-u64-export-v1.md`, `tests/universal/translation/c_export_selftest.py` | |
| 129 | | independent validation (#623) | validation lane | `tests/universal/translation/validate*.py`, `tests/universal/translation/mutants/`, `mk/translation-validate.mk` | |
| 130 | | bindings, six callers, artifact manifests | bridge lane | omega-bridge repository | |
| 131 | | Rust (#626), Python (#627), C++ (#739), Zig (#740), Go (#741) | one agent each, after G1 | `src/adapters/<lang>-u64-*.om`, `spec/universal/<lang>-u64-*-v1.md`, `tools/adapters/<lang>-*` | |
| 132 | | upper registry extension for C++/Zig/Go | #621 codec owner only | `src/source-aware/core.om`, `spec/universal/source-aware-v2.md` | |
| 133 | |
| 134 | The validation lane does not author lowering or export code and the authors do not certify their own |
| 135 | work. Shared files above are written only by their owner; other lanes send changes to the owner. |
| 136 | |
| 137 | ## 10. Status vocabulary (matrix) |
| 138 | |
| 139 | Each language x profile x direction carries four separate flags: PLANNED, IMPLEMENTED, TESTED (the |
| 140 | lane's own tests ran), QUALIFIED (independent validation PASS on an exact reviewed head plus |
| 141 | exact-head CI). Evidence is labelled REFERENCE / DIFFERENTIAL / PROOF and NATIVE / EMULATED / |
| 142 | NOT_RUN. Anything not run is NOT_RUN, never PASS. |