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 / c-u64-import-v1.md
| 1 | # Bounded C-to-Omega importer, first #622 slice |
| 2 | |
| 3 | Status: experimental, author-tested, not merge-approved. This implements import, |
| 4 | not export, OSC lowering, formal translation validation or a C runtime. It is not |
| 5 | completion of #622 or architecture #295. |
| 6 | |
| 7 | ## Source profile and environmental assumptions |
| 8 | |
| 9 | The input starts with the exact bytes `#include <stdint.h>\n`. There is exactly |
| 10 | one function definition, with a `uint64_t` return, either `(void)` or one through |
| 11 | six distinct named `uint64_t` parameters, and a body containing one return |
| 12 | expression. The function name is `calc` or starts with `omega_` and has at least |
| 13 | one following identifier character. Names are at most 32 ASCII bytes, start with |
| 14 | a lowercase letter, contain ASCII letters/digits/underscore, are not C keywords, |
| 15 | and do not begin with `int` or `uint`. `main` is also reserved by this adapter. This intentionally avoids `<stdint.h>` |
| 16 | typedef/macro collisions and C standard-library external namespaces. Other names |
| 17 | are unsupported, not automatically renamed. |
| 18 | |
| 19 | Expressions contain declared parameters, decimal literals of spelling `0ULL` or |
| 20 | `[1-9][0-9]*ULL`, parentheses, and binary `+`, `-`, `*`. Multiplication binds tighter |
| 21 | than addition/subtraction; equal-precedence operations associate left. All values |
| 22 | and results are unsigned 64-bit; operations wrap modulo 2^64. Literals exceeding |
| 23 | UINT64_MAX refuse. The C environment must provide uint64_t and exactly 64-bit |
| 24 | unsigned long long, with the standard header and no additional predefined/user |
| 25 | macros affecting accepted identifiers. Qualification currently uses the recorded |
| 26 | Linux AArch64 GCC environment, not every possible C implementation. |
| 27 | |
| 28 | Spaces, tabs, LF and CR and ordinary block/line comments are retained as source |
| 29 | bytes. Comments can contain non-ASCII bytes; code identifiers cannot. NUL, |
| 30 | backslash bytes anywhere, all nine C trigraph spellings, extra preprocessing, |
| 31 | other includes, additional declarations, storage qualifiers, signed/narrow types, |
| 32 | casts, pointers, effects, calls, division, shifts, branches and loops refuse. |
| 33 | Backslashes/trigraphs are excluded before comment removal: C translation phases |
| 34 | can otherwise splice a line comment and silently change the return expression. |
| 35 | Octal, hexadecimal and alternate literal suffixes are not decimal literals and |
| 36 | refuse. These exclusions are part of the adapter profile, not changes to C. |
| 37 | |
| 38 | Bounds: source at most 4096 bytes, at most six parameters, parenthesis depth at |
| 39 | most 16 and at most 64 upper operations including parameter declarations and two |
| 40 | synthetic return-selection operations. Exactly-at-capacity and over-capacity |
| 41 | controls are executable. This is a whole-input, one-process interface, not a |
| 42 | reentrant/shared-memory parser or sandbox. |
| 43 | |
| 44 | ## Implementation and preserved identities |
| 45 | |
| 46 | `src/adapters/c-u64-import.om` is handwritten seeded Omega. Its lexer, precedence |
| 47 | parser, symbol/slot mapping, arithmetic profile, span tracking, envelope writing |
| 48 | and SHA256 calls run in its static native AArch64 ELF. The SHA256 source is the |
| 49 | unchanged hash-pinned import already used by #621. No C/Rust/Python parser, |
| 50 | transpiler, library or compute fallback constructs the imported graph. |
| 51 | |
| 52 | The adapter produces the existing additive `source-aware-v1.md` OMSB envelope: |
| 53 | profile1/runtime0/abstract-pure ABI1, u64 input/constant/add/sub/mul SSA records, |
| 54 | required obligations, the #625 contract digest, semantic association and the |
| 55 | separate raw-byte source sidecar. Input records preserve distinct argument slots, |
| 56 | even when unused. Literal spans identify their source token; arithmetic spans |
| 57 | identify the operator token; input spans identify declarations. A final synthetic |
| 58 | `root + 0` makes the chosen return root the last SSA result even when the source |
| 59 | returns an earlier parameter. The synthetic zero and add have empty spans. |
| 60 | |
| 61 | Original source bytes are stored exactly, including comments and CRLF body |
| 62 | bytes. Exact replay is a source-storage guarantee, not proof that the imported |
| 63 | semantics correspond to C. Semantic/provenance identities remain separate. |
| 64 | Identical hashes are never treated as behavioral-equivalence proofs. |
| 65 | |
| 66 | No historical OSC encoding, canonical program identity, Omegese/checker2 source or |
| 67 | receipt schema is modified. The existing #621 public decoder, replay command and |
| 68 | legality checker consume each positive imported unit in the gate. Its |
| 69 | LOWERABLE_WITH_OBLIGATIONS result is not a completed lowering or proof. The current |
| 70 | behavioral test evaluates the upper graph in an independent development reference |
| 71 | and compares with compiled original C. It does **not** execute the C computation |
| 72 | through an Omega CPU backend yet. |
| 73 | |
| 74 | ## Commands and clean-source reproduction |
| 75 | |
| 76 | Prerequisites: Linux AArch64; git, bash, Python3 and ordinary POSIX utilities for |
| 77 | host build/dispatch; Node plus GCC for independent tests; a local clone containing |
| 78 | bridge commit `0fc7d8662cb799e7c206b17c18ea4c3ec2b8fea9`. |
| 79 | |
| 80 | From a checkout of this candidate: |
| 81 | |
| 82 | ```sh |
| 83 | # Replace this with the actual local clone containing the exact immutable pin. |
| 84 | export SA_SEED_REPO=/path/to/omega-bridge |
| 85 | make -f mk/c-u64-import.mk test-c-u64-import |
| 86 | # Both targets are also included by the root Makefile. |
| 87 | ``` |
| 88 | |
| 89 | The builder reuses `tools/source-aware/build`, which archives the committed |
| 90 | bridge source and runs its original offline bootstrap, verifies source locks and |
| 91 | requires compiler SHA256 |
| 92 | `191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9`. |
| 93 | It verifies a nonempty correctly targeted ELF before use. No sibling mutable |
| 94 | binary or downloaded compiler is required. Each correctness run uses a fresh |
| 95 | UUID output directory; an existing output directory is refused by the runner. |
| 96 | |
| 97 | ```sh |
| 98 | # Source file contents, not a filename argument, enter the importer. |
| 99 | tools/adapters/c-import < computation.c > caller-owned-temporary.upper |
| 100 | # Existing qualified component, not another decoder: |
| 101 | tools/source-aware/sa replay < caller-owned-temporary.upper > replayed.c |
| 102 | cmp computation.c replayed.c |
| 103 | ``` |
| 104 | |
| 105 | The build script and public dispatch use Python only for filesystem/process/hash |
| 106 | orchestration; this is explicitly **not** a pure-Omega public command boundary. |
| 107 | The public wrapper rejects missing/stale source/artifact identities and unexpected |
| 108 | arguments before dispatch. Parsing failure emits a named stderr diagnostic and no |
| 109 | stdout. Destination management belongs to the caller: shell `>` truncates before |
| 110 | the command starts. For valuable destinations, create a fresh temporary file and |
| 111 | rename only after status zero. OS I/O failure may interrupt a stream. |
| 112 | |
| 113 | Refusals: 65 syntax; 66 unsupported type; 67 capacity; 68 unsupported arithmetic; |
| 114 | 69 unsupported construct; 70 unknown identifier; 71 unsupported signature/name; |
| 115 | 72 unsupported preprocessing/translation phase; 77 I/O. Public dispatch adds |
| 116 | 64 bad command and 78 missing/stale build. Diagnostics do not currently include |
| 117 | line/column detail. |
| 118 | |
| 119 | ## Evidence and limits |
| 120 | |
| 121 | `c_import_gate.py` retains all original 34 programs and 40 refusal fixtures, adds |
| 122 | an accepted `omega_` function and eight source-spelling/namespace regressions. |
| 123 | The original C is compiled and executed by the external native compiler. The |
| 124 | native-produced upper graph is independently decoded/evaluated, and accepted by |
| 125 | the separate existing native #621 component. This is finite differential evidence, |
| 126 | not an exhaustive equivalence proof. Oracle flags suppress unused-parameter |
| 127 | warnings specifically because unused named inputs are valid C and deliberately |
| 128 | exercise the preserved function boundary; all other selected warnings remain |
| 129 | errors. Original fixture-construction failures are preserved, not relabelled. |
| 130 | |
| 131 | `c_import_controls.py` exercises exact and excessive source/operation/depth bounds, |
| 132 | closed stdin, public identity mismatch refusals and five successfully compiled |
| 133 | semantic mutants: add/sub/mul, literal digits, parameter mapping. A mutant counts |
| 134 | only when an actual valid imported graph disagrees with the independent compiled |
| 135 | C result; compile failures/refusals alone cannot count as semantic mutation kills. |
| 136 | |
| 137 | The author found and reproduced three real spelling defects before freezing: |
| 138 | `010ULL` was incorrectly read as decimal, and line-splice/trigraph-splice comments |
| 139 | changed the expression. Native GCC demonstrated the differing values. Their RED |
| 140 | records and new passing refusals are retained. This is why simple successful |
| 141 | arithmetic examples are not a general C qualification. |
| 142 | |
| 143 | Still absent: C exporter, general identifiers/preprocessing, other widths/types, |
| 144 | control flow/memory/runtime features, actual upper-to-OSC lowering, checker-bound |
| 145 | translation receipts, Rust/Python adapters, x86/RV64 backend qualification and GPU |
| 146 | execution. No signed production authority or universal correctness is claimed. |
| 147 | Independent source review and the sole Renda/Spark publication process remain |
| 148 | separate acceptance gates. See the machine-readable adjacent adapter manifest. |