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 / spec / universal / translation-v1.md

142 lines · 10045 bytes Raw Blame History Rendered
1# Translation handoff contract v1 (#624 G0)
2
3Status: FROZEN for the first executable slice (G1, C17 pure u64) on 2026-10-25 by the #624 integration
4coordinator. Additive. It changes no existing format: `semantics.md`, `source-aware-v1.md` (OMSB/OMSA/OMSP
5v1), `c-u64-import-v1.md`, OSC, Omegese, checker2 and every v1 identity stay byte-identical. A change to
6anything 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
21One pure function of 0..6 u64 inputs returning u64; values are integers modulo 2^64; operations are
22constants 0..2^64-1 and add, sub, mul modulo 2^64 (upper ops 1, 2, 3, 4, input op 9). No division,
23shifts, bitwise operators, comparisons, control flow, recursion, memory, calls, effects, exceptions or
24runtime. Representation limits are those of the upper v1 envelope: 1..64 SSA results including inputs
25and constants, the last result is the function result, input slot immediates are a permutation of
260..n-1 (unused inputs are kept), source at most 4096 bytes, envelope input at most 8192 bytes.
27
28An upper unit is in S1 iff it decodes under source-aware v1 with language 1 profile 1 runtime 0 ABI 1,
29and 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
31obligations 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
33profiles are separate. Profile 4 adds obligation 4, source-explicit-masking, to arithmetic.)
34
35## 3. Observable equivalence
36
37Two artifacts agree on S1 iff for every input vector they return the same u64, and both refuse or both
38accept (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
46The C importer appends a synthetic `const 0` (empty span) and `add(root, that const)` so the returned
47value 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
60writes one restricted Omegese function-mode unit on stdout:
61
62```
63note omega.universal.lower.v1 semantic <64 lowercase hex of the unit's semantic identity>
64fn <name> i0 ulong i1 ulong ... to ulong (exactly n inputs, slot order; "fn <name> to ulong" for 0)
65v = new ulong <count> 0
66put v <k> i<slot> (op 9)
67put v <k> <decimal> (op 1)
68put v <k> add|sub|mul get v <a> get v <b> (ops 2, 3, 4)
69ret get v <count-1>
70end
71```
72
73One 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
75byte-deterministic. Refusals: non-S1 unit 68 PROFILE_MISMATCH; malformed envelope 65; bad name 64.
76Native realization = the pinned omc compiling that unit in function mode, bound by the pinned bridge
77generator 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
82and writes C17 source on stdout, generated from the operation records only (the sidecar's stored bytes
83are never read for output; a semantic-only envelope must export identically). Frozen output form:
84
85```
86#include <stdint.h>
87uint64_t <name>(uint64_t i0, uint64_t i1, ...) { return <expr>; } ("(void)" for 0 inputs)
88```
89
90followed 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
92left associativity require it to keep the exact SSA tree: with precedence leaf 3, `*` 2, `+`/`-` 1, a
93left operand gets parentheses iff its precedence is lower than the parent's, a right operand iff its
94precedence is lower than or equal to the parent's (so `a+(b+c)` and `a-(b-c)` keep their tree, a
95left-leaning chain `a+a+...+a` is emitted without parentheses). Shared SSA results are expanded as
96trees (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
98after re-import). An export that would break any of these refuses 67 LIMIT with no stdout; it never
99writes unimportable C. The other refusals are the same as lowering (section 5): malformed envelope 65,
100non-S1 unit 68, bad command or name 64. `<name>` is `calc` unless given (`c-export NAME`,
101C-import-profile name rules).
102
103Required 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
105redundant 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
107accepted limit.
108
109## 7. Process and concurrency rules
110
111Every tool reads stdin to EOF, writes stdout only on success, names its refusal on stderr, and exits
112with the statuses above. The #621 core and the importer use fixed global buffers and are not reentrant:
113harnesses call them as separate processes, one at a time per artifact; no in-process sharing.
114
115## 8. Fixture identities F1 (frozen)
116
117F1 = the 35 positive and 48 refusal sources of `tests/universal/c_import_gate.py` at this commit,
118identified by the SHA256 of their exact bytes (`tests/universal/translation/fixtures-f1.json`, generated
119from that file and checked against it), plus the 15 boundary controls of `c_import_controls.py`. New
120fixtures 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
134The validation lane does not author lowering or export code and the authors do not certify their own
135work. Shared files above are written only by their owner; other lanes send changes to the owner.
136
137## 10. Status vocabulary (matrix)
138
139Each language x profile x direction carries four separate flags: PLANNED, IMPLEMENTED, TESTED (the
140lane's own tests ran), QUALIFIED (independent validation PASS on an exact reviewed head plus
141exact-head CI). Evidence is labelled REFERENCE / DIFFERENTIAL / PROOF and NATIVE / EMULATED /
142NOT_RUN. Anything not run is NOT_RUN, never PASS.