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 / source-aware-v1.md

177 lines · 11517 bytes Raw Blame History Rendered
1# Source-aware upper layer v1
2
3Issue #621. Parent contract: omega.universal.semantics.v1 at stacked base
469790fb4ad1e803ca79245430745b96129d1dcf4. This additive, finite interchange
5contract does not change OSC, Omegese, checker2, policy or receipt formats.
6Independent review is pending. No general importer, converter or proof claim.
7
8## Bounds and identities
9
10A unit is a straight-line typed expression with 1..64 SSA results. Its last
11result is the unit result. At most six distinct input slots, no functions,
12branches, recursion, heap, floating point, exceptions implemented as execution,
13concurrency, arbitrary dialect extensions or native FFI. Source at most 4096
14bytes. Input at most 8192 bytes. Oversized values refuse before indexing.
15
16Semantic identity = SHA256(`omega.source.semantic.v1` || canonical semantic
17bytes). These bytes include every language/profile/runtime/ABI/dialect/version,
18operation/type/attribute/effect/alias/obligation/operand/immediate field and the
1932-byte hash of spec/universal/semantics.md. Formatting, spans, raw source and
20target selection are excluded. Provenance identity = SHA256(
21`omega.source.provenance.v1` || complete canonical envelope). No target
22realization identity is minted here. These are intensional content identifiers,
23not proofs of behavioral equivalence, and SHA256 collision resistance is an
24assumption. Changing profile definitions requires a new version, not reusing IDs.
25
26Raw bytes, source encoding and byte spans live only in the sidecar. Verified
27association checks both semantic and source SHA256. This detects inconsistent
28association, not a malicious importer's false claim that text means an IR.
29No parser establishes that claim in this slice. Private source must remain local.
30Exact replay exports stored bytes; it never reconstructs source from lower IR.
31
32## Canonical wire format
33
34All integers unsigned little endian, all lengths exact; no padding, varints,
35implicit NUL or trailing bytes. Numbers below are offsets from each record.
36
37Envelope: ASCII OMSB (0..3), version=1 (4), semantic length u32 (5), sidecar
38length u32 (9), semantic bytes (13), optional sidecar bytes. Sidecar length zero
39means absent, not empty source. Semantic-only units may decode/encode/identify;
40replay returns PROVENANCE_MISSING. Input total must equal 13+both lengths.
41
42Semantic header (44 bytes): ASCII OMSA (0), version=1 (4), language (5), profile
43(6), dialect version=1 (7), runtime (8), ABI (9), operation count u16 (10),
44SHA256 of exact parent semantics.md bytes (12). Then count 20-byte operations.
45
46Operation: importer dialect (0), op version=1 (1), opcode (2), result type (3),
47arithmetic attribute (4), effects bitset (5), alias set (6), obligations bitset
48(7), operand A u16 (8), operand B u16 (10), immediate u64 (12). Result index is
49record order. An operand must reference an earlier result of the specified type.
50Unused operands MUST be 65535; unused immediate MUST be zero. There are no ignored
51fields. Input slot immediates 0..5 must be unique in the unit.
52
53Sidecar: ASCII OMSP (0), version=1 (4), encoding (5), source length u32 (6),
54SHA256 of semantic bytes (10), SHA256 of source bytes (42), count pairs of
55(start u32,end u32) (74), then exact source bytes. Spans are half-open byte offsets
560<=start<=end<=source length; empty/synthetic span is [0,0]. UTF8 spans must be on
57codepoint boundaries. Encoding 0 preserves arbitrary bytes including invalid
58UTF8; encoding 1 validates strict UTF8 (no overlong, surrogate or >U+10FFFF).
59Raw source may contain NUL, high bytes, CRLF and invalid text sequences.
60
61## Typed registry
62
63Languages/dialects: 1=C17, 2=Rust2021, 3=Python3, 4=OSC5. Each operation's dialect
64must equal its header language. Types: 1=u64, 2=Python builtin arbitrary-precision
65int, 3=Python object (operator overloads preserved), 4=symbolic byte-view binding.
66Byte-view is an upper symbolic input; it never becomes an invented OscScalar.
67
68Profiles: 1=c17-uint64-pure-v1 (language1); 2=rust-u64-wrapping-pure-v1 (language2);
693=cpython-int-pure-v1 (language3); 4=python-explicit-u64-pure-v1 (language3);
705=osc-v5-u64-pure-v1 (language4); 6=python-dynamic-retained-v1 (language3).
71Profile6 is a retention-only extension: dynamic calls, symbolic byte access,
72exceptions and unknown effects remain unresolved. It supplies no executable
73Python semantics. Profile1/2/4/5 permit only u64 inputs/constants/arithmetic.
74Profile3 permits only builtin-int inputs/constants/arithmetic. Profile6 permits
75all registry types but u64 arithmetic remains explicit-mask semantics.
76
77Runtime: 0=none; 1=CPython3.12 model; 2=CPython3.13 model. ABI: 1=abstract-pure-v1,
782=cpython-object-v1 (symbolic only, no layout/FFI support). Profiles1/2/4/5 require
79runtime0 ABI1; profile3 requires runtime1 or2 ABI1; profile6 requires runtime1 or2
80ABI2. These versioned models do not claim support for arbitrary Python releases.
81
82Arithmetic attributes: 0=none; 1=modulo2^64; 2=builtin-bigint; 3=dynamic;
834=byte-access. Effects: read1,write2,allocation4,IO8,exception16,unknown32.
84Alias sets: 0=none, 1..8=importer-declared may-alias partition, 255=unknown/top.
85Different nonzero partitions are not a proof of disjointness. Obligations:
861=input-domain, 2=nonzero-divisor, 4=source-explicit-masking,
878=runtime-model, 16=alias-and-bounds-validation. Obligations are required exactly,
88never a caller-controlled 'proved' flag. There is no discharge mechanism here.
89
90| Op | Meaning | Required shape |
91|---|---|---|
92| 1 | constant | type1 or2; attr1 or2 respectively; effects/alias/obligations0; unused operands; u64 magnitude (nonnegative bigint subset) |
93| 2/3/4/5 | add/sub/mul/div | type1 or2; same typed A/B; immediate0; attr1/2; u64 effects0 alias0, bigint effects20 alias255; obligations below |
94| 6 | Python dynamic call | profile6, type3 attr3 effects63 alias255 obligations8; A object, unused B, immediate0 |
95| 7 | symbolic byte read | profile6, type1 attr4 effects17 alias1..8 or255 obligations24; A view, B u64, immediate0 |
96| 8 | symbolic byte write | profile6, type1 attr4 effects19 alias1..8 or255 obligations24; A view, B u64, immediate=earlier type1 SSA value-to-store; no execution/lowering |
97| 9 | external input | attr0 effects0; no operands; immediate unique slot0..5; type4 alias1..8 or255, otherwise alias0; obligations1 |
98
99Arithmetic obligations: u64 1, plus2 for div, plus4 for profiles4/6; bigint8,
100plus2 for div. Bigint division means Python floor division including negative
101input/results. No wrapped-u64 substitution. Type2 constants here are restricted
102to unsigned64 magnitudes; negative/large constants need a future version.
103Op8 returns the written u64 value, with a pending byte-range obligation in addition
104to its alias/bounds/runtime obligations. Legality is always UNSUPPORTED to OSC.
105
106## Native core API and commands
107
108Production core src/source-aware/core.om is handwritten seeded Omega. It uses
109fixed global input/output buffers and typed operation arrays. `decode n` validates
110the complete unit and leaves output length zero on failure; `encode` reconstructs
111the canonical bytes from validated fields. `perform mode n` resets output first,
112decodes, and prepares all output before any write. Return code zero means success.
113This whole-unit interface matches the qualified grammar; no shared-object ABI,
114thread safety or reentrant library is claimed. External adapters must serialize
115calls. Failed decode may leave private scratch fields; no result may be used.
116
117`tools/source-aware/sa encode|decode|identity|provenance|replay|legality` reads a
118canonical envelope on stdin and writes bytes on stdout. encode/decode produce
119identical canonical envelopes. identity/provenance emit 32 raw digest bytes.
120legality uses four prefix bytes before the envelope: target(1=upper retention,
1212=OSC), available runtime(0..2), ABI(1..2), allowed effects(0..63). The reply is
122one pair (legality,obligations) per operation. Invalid target capabilities refuse.
123Statuses: 1=LEGAL (upper retention only); 2=REQUIRES_RUNTIME;
1243=LOWERABLE_WITH_OBLIGATIONS; 4=UNSUPPORTED. Missing runtime on bigint/dynamic
125operations returns2; provided runtime never makes them lowerable to OSC.
126For target2 only u64 inputs/constants and modulo u64 arithmetic can return3,
127with their exact obligations; all others return4. Missing ABI or effect allowance
128returns4 first. No status certifies a lowering or grants capability authority.
129
130Named refusals/status: 64=BAD_COMMAND, 65=MALFORMED, 66=UNKNOWN_VERSION,
13167=LIMIT, 68=PROFILE_MISMATCH, 69=UNKNOWN_OPERATION, 70=TYPE_MISMATCH,
13271=EFFECT_ALIAS_MISMATCH, 72=OBLIGATION_MISMATCH, 73=PROVENANCE_MISSING,
13374=PROVENANCE_MISMATCH, 75=SOURCE_SPAN, 76=SOURCE_ENCODING, 77=IO,
13478=CONTRACT_MISMATCH. Semantic failure produces no stdout; named message on stderr.
135The CLI buffers output into an exclusive temporary directory before stdout copy.
136Direct native code validates everything before output. OS I/O failure can of
137course interrupt a stream; no atomic multi-byte pipe write is claimed. Neither
138command manages destination paths: shell redirection truncates before invocation.
139Use caller-owned temporary files and rename on success for durable destinations.
140
141## Existing lower interfaces and trust boundary
142
143Omegese's `osc_compile` produces existing OscUnit values. Existing
144`osc_ir_encode`, `osc_ir_decode`, `osc_ir_validate` and `c2_check_bytes` remain the
145only lower serializers/checkers. Upper bytes are never passed as OSC and never
146labelled lower proof. A future importer must fill these typed upper records;
147a future lowering must consume legality obligations, produce unchanged OSC,
148and submit that OSC through both existing decoder/validator and checker2.
149The test-only C adapter exercises exactly these existing APIs, using legacy
150host orchestration openly. No production C compiler/runtime is added.
151
152Issue #623 owns source-to-upper/OSC translation validation and signed receipts.
153This layer provides exact semantic/provenance digests to bind there, but cannot
154mint an approved receipt or certify source correspondence. Target/transform,
155source profile, obligations and validation status must be bound by that future
156adapter through reviewed existing receipt versioning. Full local judge and
157independent API review remain publication gates.
158
159## Qualification plan
160
161Seeded native compile only, pinned immutable source archive and existing bootstrap
162entry; existing native SHA256 core imported without edits and hash-checked.
163Independent Node buffers/crypto generate and check 10000 valid and 100000
164structurally malformed requests, with category membership, consumed-input hashes,
165per-response actual counts, replay/identity/output assertions and declared seeds.
166Test-only framed native entry calls the same core. Public commands and direct
167core failure-after-success probes must leave no partial semantic output or stale
168PASS receipt. Compiled semantic mutants must compile and run before being counted;
169byte corruptions test source/span/profile/version/effect/runtime/length refusals.
170Legacy fixture hashes are compared to pinned-base encodings through unchanged
171OSC and checker2. Receipts are unsigned development evidence only.
172
173The build defaults to build/L574. SA_BUILD may select a child of that scratch
174area; symlinks, hardlinked files and special files there refuse before writes.
175SA_SEED_REPO may point to another local clone containing the exact pinned bridge
176commit. Only committed archived sources are consumed. This is an explicit pinned
177source dependency, not an embedded or silently downloaded compiler binary.