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-compose-v2.md
| 1 | # Translation composition contract v2 (#624 G3) |
| 2 | |
| 3 | Status: FROZEN for G3 (C++, Zig, Go) on 2026-10-25 by the #624 integration coordinator. Additive: |
| 4 | `translation-v1.md` and `translation-compose-v1.md` stay unchanged and govern everything this file does |
| 5 | not extend. Envelope: `source-aware-v2.md` (#621 v2, ledger L832, branch `universal/621-source-aware-v2`, |
| 6 | spec sha256 `ea2e1465…ce1c` at 02283530): semantic header version 2 for profiles 7/8/9 only. |
| 7 | |
| 8 | ## 1. Extended S1 family |
| 9 | |
| 10 | | member | OMSA version | language / profile / runtime / ABI | op dialect | arithmetic obligations | |
| 11 | |---|---|---|---|---| |
| 12 | | C | 1 | 1 / 1 / 0 / 1 | 1 | 1 | |
| 13 | | Rust | 1 | 2 / 2 / 0 / 1 | 2 | 1 | |
| 14 | | Python | 1 | 3 / 4 / 0 / 1 | 3 | 5 | |
| 15 | | C++ | 2 | 5 / 7 / 0 / 1 | 5 | 1 | |
| 16 | | Zig | 2 | 6 / 8 / 0 / 1 | 6 | 1 | |
| 17 | | Go | 2 | 7 / 9 / 0 / 1 | 7 | 1 | |
| 18 | |
| 19 | Inputs and constants have the fields of `translation-v1.md` section 2 in every member. Division (op 5) |
| 20 | is outside the family although profiles 7/8/9 can represent it; every family tool refuses it with 68. |
| 21 | |
| 22 | ## 2. R, N and the retarget tool |
| 23 | |
| 24 | `R(U, M)` (compose-v1 section 2) additionally sets the OMSA version byte to M's version, and always |
| 25 | yields a semantic-only envelope (sidecar length 0). A sidecar binds the source member's semantic bytes |
| 26 | and source text, so carrying it across a retarget would bind the wrong language; provenance stays with |
| 27 | U. `N(U) = R(U, C)` is a v1 C unit for every member, so the language-neutral identity, the lowering and |
| 28 | every G1 tool are unchanged, and `N(R(U, M)) = N(U)` for all six members. |
| 29 | |
| 30 | `tools/adapters/retarget M` (Omega source `src/adapters/upper-retarget.om`, built on the v2 codec |
| 31 | `src/source-aware/core-v2.om`) reads one envelope of any family member and writes `R(U, M)`; |
| 32 | `M` is one of `c rust python cpp zig go`. Refusals: malformed 65 (or the decoder's status 66..78), |
| 33 | not in the family 68, bad command 64. Output is byte-deterministic. |
| 34 | |
| 35 | ## 3. Exporters and importers |
| 36 | |
| 37 | - C++/Zig/Go importers emit units of their own member (version 2) with an OMSP sidecar, as v1 |
| 38 | importers do, and declare whether they append a normalization pair (compose-v1 section 3). |
| 39 | - C++/Zig/Go exporters decode with the v2 codec and accept every member of the extended family. |
| 40 | - The v1-core tools (`c-import`, `lower`, `c-export`, Rust and Python adapters) are unchanged and keep |
| 41 | refusing version 2 units with empty stdout: the v1 codec `sa` with 66 (UNKNOWN_VERSION); the tools |
| 42 | with 65 (`*_MALFORMED`), because translation-v1 sections 5 and 6 map every decode failure other |
| 43 | than 68 to 65. (Amended 2026-10-25 after the Go lane measured 65; the first text said 66 for all.) |
| 44 | A composition into a v1-core exporter, and the native realization, use `retarget`: |
| 45 | `export_B(R(U_A, B))` and `lower(N(U_A))`. Moving those tools onto the v2 codec is a separate change |
| 46 | and not part of G3. |
| 47 | |
| 48 | ## 4. Compositions and evidence |
| 49 | |
| 50 | Compose-v1 sections 4 and 5 apply unchanged to all 30 directed compositions of the six members, with |
| 51 | `retarget` inserted where section 3 requires it. Fixture sets: `fixtures-f2-cpp.json`, |
| 52 | `fixtures-f2-zig.json` and `fixtures-f2-go.json` (IDs `F2-<lang>-<F1 id>`). Oracles, declared and |
| 53 | pinned in each profile spec: g++ (`-std=c++17 -O2 -Wall -Werror`), Zig 0.17.0, Go 1.27.3 (user-space |
| 54 | toolchains in `~/.local/toolchains`, sha256 verified against the official release indexes). |
| 55 | |
| 56 | Semantics each importer must establish before emitting ops 2/3/4 (`source-aware-v2.md` section 2): |
| 57 | - C++17: both operands exactly `std::uint64_t` or `uint64_t`; no integral promotion, no mixed types. |
| 58 | - Zig: only the wrapping operators `+%`, `-%`, `*%`; plain `+ - *` refuse (checked illegal behavior). |
| 59 | - Go: `uint64` operands; `+ - *` are modulo 2^64 by the language specification; untyped constant |
| 60 | expressions are exact and arbitrary precision at compile time, so any expression with no `uint64` |
| 61 | variable operand must refuse or be shown to fit (decide in the Go profile spec, and test). |
| 62 | |
| 63 | ## 5. Ownership (adds to the earlier tables) |
| 64 | |
| 65 | | lane | paths | |
| 66 | |---|---| |
| 67 | | retarget (compiler/core lane) | `src/adapters/upper-retarget.om`, `tools/adapters/retarget`, `tools/adapters/build-retarget.py`, `mk/retarget.mk`, `tests/universal/translation/retarget_selftest.py` | |
| 68 | | C++ (#739) | `src/adapters/cpp-u64-*.om`, `tools/adapters/cpp-*`, `tools/adapters/build-cpp-*.py`, `mk/cpp-u64.mk`, `spec/universal/cpp-u64-v1.md`, `tests/universal/translation/cpp_selftest.py`, `fixtures-f2-cpp.json` | |
| 69 | | Zig (#740) | the same pattern with `zig` | |
| 70 | | Go (#741) | the same pattern with `go` | |
| 71 | | v2 reference decoder and G3 composition validation (#623) | `tests/universal/source-aware/v2_reference*`, `tests/universal/translation/validate_compose*.py` | |