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 / upper-lower-v1.md
| 1 | # Upper S1 lowering v1 (#624 G1, compiler/core lane) |
| 2 | |
| 3 | Implements `translation-v1.md` section 5 (contract sha256 `063f1d63…de86e`, branch |
| 4 | `universal/624-translation-g0` @ `82cd7692f`). It adds no format and changes no existing one. |
| 5 | |
| 6 | ## Tool |
| 7 | |
| 8 | `tools/adapters/lower [NAME] < envelope > unit.om`. The wrapper is transparent host dispatch: it |
| 9 | checks `build/L831/build.json` (compiler sha, the sha of each closure source, the binary sha) and |
| 10 | refuses 78 `LOWER_STALE_OR_MISSING_BUILD` when anything has drifted. It then execs the native |
| 11 | binary with the same arguments. All validation, hashing and text generation run in seeded Omega. |
| 12 | |
| 13 | Build (`make -f mk/lower.mk lower`, `tools/adapters/build-lower.py`): |
| 14 | - The compiler is the section-1 native realization compiler, omc sha256 `734f0a39…6b61`, named by |
| 15 | `OMEGA_NATIVE_OMC` (required; no `$HOME` default). |
| 16 | - It compiles the concatenation of three unchanged or owned sources: |
| 17 | - `src/source-aware/vendor/sha256.om` (hash-checked by `tools/source-aware/imports.sha256`); |
| 18 | - the #621 core `src/source-aware/core.om`; |
| 19 | - `src/adapters/upper-lower.om`. |
| 20 | - The core is the #621 owner's file. It is prepended unchanged, never edited. |
| 21 | - This compiler is used, not the importer's `191b776e`, because only `734f0a39` has argv |
| 22 | (`argcnt`, `argread`), which `lower NAME` needs. |
| 23 | |
| 24 | ## Behaviour |
| 25 | |
| 26 | 1. The tool reads stdin to EOF, up to 8192 bytes. A 8193rd byte means 65. |
| 27 | 2. The core's `decode` validates the whole envelope as source-aware v1, sidecar included. It is |
| 28 | linked in-process, one envelope per process; its fixed globals are not reentrant, so harnesses |
| 29 | must run separate processes, one at a time. |
| 30 | 3. The unit must also be S1: language 1, profile 1, runtime 0, ABI 1, and every op of type 1 with |
| 31 | effects 0 and alias 0, with exactly these fields: |
| 32 | |
| 33 | | op | meaning | attribute | obligations | |
| 34 | |---|---|---|---| |
| 35 | | 9 | input | 0 | 1 | |
| 36 | | 1 | constant | 1 | 0 | |
| 37 | | 2, 3, 4 | add, sub, mul | 1 | 1 | |
| 38 | |
| 39 | Input slots must form the permutation 0..n-1. The core guarantees uniqueness and slot ≤ 5, and |
| 40 | this tool checks slot < n. The core already checks operand index < own index. |
| 41 | 4. The output is the section-5 unit, byte-deterministic, one LF after every line including `end`. |
| 42 | - The note's hex is the unit's semantic identity, `SHA256("omega.source.semantic.v1" || |
| 43 | semantic bytes)`, the same digest as `sa identity`. |
| 44 | - Constants are printed in unsigned decimal, from 0 to 18446744073709551615. |
| 45 | 5. Output is fully buffered and written only after acceptance. A refusal writes nothing to stdout |
| 46 | and one named line to stderr. |
| 47 | |
| 48 | | status | stderr | cause | |
| 49 | |---|---|---| |
| 50 | | 64 | `LOWER_BAD_COMMAND` | more than one argument, or a bad NAME | |
| 51 | | 65 | `LOWER_MALFORMED` | input over 8192 bytes, or any core decode failure other than 68 (65/66/67/69..78) | |
| 52 | | 68 | `LOWER_PROFILE_MISMATCH` | core decode 68, or a valid v1 unit that is not S1 (for example op 5, profile 2, a slot gap) | |
| 53 | | 77 | `LOWER_IO` | an OS read or write failure, not a semantic status | |
| 54 | |
| 55 | When NAME is absent the tool uses `calc`. NAME must match `[A-Za-z_][A-Za-z0-9_]{0,62}`, and it |
| 56 | must not be "reserved". For this grammar, reserved means the 150 identifier keywords of omc |
| 57 | `734f0a39` (for example `get`, `u64`, `argcnt`) plus `v`, `i0`..`i5` and `main`. The reason, measured |
| 58 | with omc 734f: |
| 59 | - `v` clashes with the array local (error 7). |
| 60 | - `i0`..`i5` clash with the parameters (error 10). |
| 61 | - `main` switches the unit to program mode (error 9). |
| 62 | |
| 63 | The coordinator approved this meaning of "reserved" on 2026-10-25. |
| 64 | |
| 65 | ## Native realization |
| 66 | |
| 67 | 1. The pinned omc compiles the unit in function mode. |
| 68 | 2. omega-bridge `src/native.om` at `012860db` (source sha256 `2c2c53f6…3940`) binds it as |
| 69 | `uint32_t omega_<NAME>(uint64_t *result, uint64_t i0, ...)`. |
| 70 | |
| 71 | A 64-result unit (`new ulong 64`) with six inputs compiles and runs. No register or size limit was |
| 72 | hit. |
| 73 | |
| 74 | ## Self-test |
| 75 | |
| 76 | `make -f mk/lower.mk test-lower` builds `lower` and the unchanged importer, then runs |
| 77 | `tests/universal/translation/lower_selftest.py`. It requires `OMEGA_NATIVE_OMC` and `SA_SEED_REPO` (a |
| 78 | clone holding the pinned bridge seed commit); `OMEGA_BRIDGE_REPO` (a clone holding omega-bridge |
| 79 | `012860db`) defaults to `SA_SEED_REPO`. None of them has a `$HOME` default. It covers: |
| 80 | - every F1 positive; |
| 81 | - the four accepted `c_import_controls` boundaries, including the 61-term chain at 64 operations; |
| 82 | - crafted semantic-only units: permuted input records, lone constants 0 and 2^64-1, a 64-result |
| 83 | six-input unit, and a 63-byte name. |
| 84 | |
| 85 | What it checks: |
| 86 | - The unit bytes must match a host rebuild of the section-5 form. |
| 87 | - The semantic-only envelope must lower identically. |
| 88 | - The native results must equal a Python bigint evaluation of the records, on boundary and seeded |
| 89 | random vectors. |
| 90 | - Each refusal must give its status, an empty stdout and the named stderr line. |
| 91 | |
| 92 | Evidence class: TESTED by this lane, DIFFERENTIAL + REFERENCE, NATIVE. It is not qualification. |