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 / c-u64-import-v1.md

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