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 / docs / osc / OSC-VC1-IMPORT.md

150 lines · 10893 bytes Raw Blame History Rendered
1# OSC import resolution (VC1 stages 4 and 6)
2
3Authority: ADR 0029 and aien-protocols `specs/verified-crumb/SPEC.md` (sections 5 to 8). This file records what the C
4implementation does and where it stops. Code: `src/omega_resolve.c` (resolver, lock, identity, the admission door),
5`src/omega_receipt.c` (receipt reader), `src/omega_blake3.c`, `src/omega_genesis.h` (the pinned Genesis Set),
6`src/omega_program_ir.c` (the IR the program id is recomputed from), `src/omega_resolve_osc.c` (front end adapter),
7`src/oscv_main.c` (`oscv` driver), `src/omega_vc_bridge.c` (how Crumbline and discovery admit programs).
8Tests: `make test-resolve test-resolve-genesis test-vcstore test-vcstore-genesis test-genesis test-genesis-real
9test-program-ir`.
10
11## Grammar
12
13```
14unit := import* ( struct | fn )*
15import := "import" NAME ";"
16```
17
18Imports come first. `import` is now a keyword (it was a reserved word). More than 64 imports is CAPACITY, a repeated
19name is REDEFINED_NAME, an import after a struct or fn is SYNTAX. `osc_compile` (and `oscc`) refuses a unit with
20imports (UNSUPPORTED). Only `osc_compile_imports` with a resolver hook accepts one, and the hook is called once per
21compile even with zero imports (so a lock line with no import is caught).
22
23## Resolver flow (`omega_resolve_imports`)
24
251. Declaration check, before any store access: every import needs a lock line (DEPENDENCY_NOT_PINNED); every lock line
26 needs an import (UNDECLARED_IMPORT). Direction chosen: an extra lock line is refused, not ignored.
272. Per node: lock line -> store get by semantic id -> identity (the record names the same semantic id) ->
28 source/IR recheck (below) -> the lock's receipt equals the record's receipt -> taint capability -> verifier profile and version -> receipt check (SPEC 5.1 rules 1 to
29 6) -> edges (each dependency repeats the chain; contract ids must match; a node already on the path is
30 DEPENDENCY_CYCLE) -> genesis gate for a BOOTSTRAP record (below, checked last so cycle and dependency refusals
31 still come first).
323. The closure is sorted by semantic id; its digest is `SHA-256("OMEGA.CLOSURE.V1" 0x00 || u32be n || n x (semantic_id ||
33 receipt_id || kind))`. Any refusal returns no closure.
34
35Refusal codes: UNVERIFIED_DEPENDENCY, MISSING_RECEIPT, RECEIPT_HASH_MISMATCH, DEPENDENCY_NOT_PINNED, DEPENDENCY_CYCLE,
36STALE_RECEIPT, UNDECLARED_IMPORT, TAINTED_ARTIFACT, UNKNOWN_VERIFIER_PROFILE, VERIFIER_TOO_OLD (enum in
37`src/omega_resolve.h`). A BOOTSTRAP record that is not on the Genesis Set comes back as UNVERIFIED_DEPENDENCY with the
38store code GENESIS_NOT_LISTED.
39
40## Mandatory source/IR recheck (SPEC 6 step 3)
41
42In the build domain the resolver must be given a source/IR blob store (`fetch_blob`; `oscv` reads `blobs/` next to the
43source, or `--blobs DIR`). Without one, every node is refused ("needs the source or IR store"). For each record:
44
451. The blob named by `source_or_ir_digest` is fetched and SHA-256 of its bytes must equal that digest.
462. A record whose digest kind is OSC source is refused in the build domain: a source digest cannot be turned back into
47 a program id by this resolver, so only an IR digest can satisfy the recheck.
483. For an IR digest, the program id is RECOMPUTED from the IR bytes (`omega_program_ir_recompute_id`, which decodes the
49 IR exactly and calls `omega_program_compute_id`) and compared with the record's semantic id. A mismatch, or bytes
50 that are not a valid IR, are UNVERIFIED_DEPENDENCY ("does not recompute to its semantic id").
51
52The IR layout is in `src/omega_program_ir.h`. It carries exactly the fields the program id binds, so recomputing it is
53possible from the blob alone.
54
55The dev domain may leave the store out. Then none of the three steps runs and the output stays tainted (as every dev
56output is). If a store is given, the dev domain runs steps 1 and 3 too; step 2 (the source kind refusal) is a build
57domain rule only.
58
59## Build identity
60
61`build_id = SHA-256("OSC1.BUILD.V1" 0x00 || ir_digest || domain byte || closure_digest)` in `omega_build_id`. That is
62the one place the closure digest enters a build's identity. `oscv` prints it.
63
64## Domains
65
66`--domain build` (default) and `--domain dev` run the same checks except the blob store requirement above; the domain
67never loosens any other one. omega-dev output is TAINTED: its artifact header says `tainted 1`, its build id commits to
68the domain, and `omega_resolve_admit` refuses to insert it (and refuses any record that lists the capability
69`omega-dev.taint`). A record listing that capability can never satisfy an import in either domain.
70
71## The artifact header is unauthenticated; the receipt is the gate
72
73The text header `omega_artifact_meta_text` writes (domain, tainted mark, IR digest, closure digest, build id) is
74integrity checked only against itself: `omega_artifact_meta_parse` recomputes the build id and checks the taint mark
75agrees with the domain. Anyone who can write the file can rewrite the domain and the mark and recompute the build id,
76and the parse will accept it. Nothing in the store or the resolver trusts that header to GRANT anything. What gates a
77record into the store is the receipt (SPEC 5.1), checked by `omega_resolve_admit`; the `origin` argument of admit is
78optional and only ever makes admission stricter (a tainted origin refuses). So the header is a label and a tripwire,
79not a credential. If it is ever made to gate something, it must be signed or bound to the receipt first; until then it
80must not be read as proof of the domain it names. (ADR 0029 carry item 6: documented, not changed.)
81
82## Genesis (BOOTSTRAP) records
83
84A BOOTSTRAP record is trusted without a receipt, so which ids may be BOOTSTRAP is a pinned list in source:
85`src/omega_genesis.h`, set name VC-GENESIS-1, described and audited in `docs/osc/VC-GENESIS-1.md`. It is currently
86EMPTY (the audit found no program that must exist without a receipt). The list is the only input:
87
88- the store refuses to insert or to load a BOOTSTRAP record whose id is not listed (GENESIS_NOT_LISTED);
89- `omega_resolve_admit_genesis` refuses an unlisted id and is the only code that may create a BOOTSTRAP record;
90- the resolver refuses a BOOTSTRAP record that is not listed, whatever put it in the store.
91
92`allow_genesis` no longer exists in `OmegaResolver`, `oscv` has no genesis option, and nothing is read from a file, a flag
93or the environment. A BOOTSTRAP record may NOT depend on a VERIFIED record (the audited base must be closed over itself);
94a VERIFIED record may depend on BOOTSTRAP.
95
96### The two raw insert functions are private
97
98`omega_vcstore_insert` and `omega_vcstore_insert_bootstrap` are declared only in `src/omega_vcstore_priv.h`. A record
99enters a store only through `omega_resolve_admit` (receipt checked) or `omega_resolve_admit_genesis` (list checked).
100`make test-resolve` scans `src/` and `tools/` and fails if any file other than the store and the resolver names either
101function or includes that header, or if anything names the admit door, the list or a genesis switch outside its owners.
102
103### Crumbline and discovery
104
105`src/crumbline/cl_program.c` and `src/omega_discovery.c` no longer call `omega_library_insert` with a bare hash. Both go
106through `src/omega_vc_bridge.c`, which builds the program's canonical Verified Crumb, mints an evidence receipt of kind
107`host-v1`, tier HOST_TEST, and lets `omega_resolve_admit` check it before the library entry is made (ADR 0029 Decision
10811). The bridge itself runs `omega_program_verify` on a private copy of the program and recomputes the program id from
109the IR it stores, and refuses on failure; it does not trust the caller's `is_verified` flag or `program_id`. The
110receipt is still SELF-MINTED: the code asking for admission writes it, so it proves the record is well formed and
111accepted by the resolver chain, not that an independent verifier re-ran anything. For that reason every record the
112bridge mints lists the capability `omega-bridge.selfminted`, and the build-domain resolver refuses any record that
113lists it: a bridge record can satisfy a dev import (tainted) but never `oscv --domain build`. `make test-vc-bridge`
114reproduces the hand test that found the earlier hole (corrupt the machine code, flip the flags, forge an id) and kills
115four mutants. This is also why VC-GENESIS-1 can be empty (see its audit). The test
116`library-insert-in-src-is-named-only-by-the-library-and-the-bridge` keeps new direct inserts out of `src/`.
117
118## The compiler hook cannot be swapped for another
119
120`osc_compile_imports` takes any function pointer, so the compiler cannot enforce what is installed. The check lives in
121CI: `import-hook-is-installed-only-by-the-real-driver` fails if any file in `src/` or `tools/` other than the compiler
122front end and `oscv` calls it, and `the-real-driver-installs-the-real-resolver-hook` fails unless `oscv` installs
123`omega_osc_import_hook`. `src/compiler` itself is unchanged.
124
125## No escape hatch
126
127`oscv --blobs` points the resolver at a source/IR store. Leaving it out is allowed only in the dev domain, where the
128output is tainted; in the build domain the default `blobs/` is used and a missing store is a refusal.
129
130No `unsafe import`, no skip switch, no environment variable. `make test-resolve` greps the compiler and resolver
131sources for forbidden words and runs `oscv` with unknown switches and with environment variables set.
132
133## Limits (stated, not hidden)
134
135- Receipts are hashes, not signatures. The receipt reader recomputes the BLAKE3 id from the canonical bytes
136 (verified against three receipts written by the Rust implementation) but does not replicate ledger or lease store
137 bindings or chain walking of aien-proof. The Rust cross-check for the lease, ledger and mutation cases the three
138 fixtures do not cover is not in this stage.
139- UNDECLARED_IMPORT still means "lock line the source never imports" here. Reconciling that with SPEC 6 step 8 and
140 aien-closure, and implementing step 8 proper (the record's stored source imports against `dependencies[]`), is not in
141 this stage.
142- A source digest cannot satisfy the build domain (it cannot be recomputed to a program id here), so a record kept only
143 as OSC source needs an IR record beside it.
144- The bridge receipt is self-minted HOST_TEST evidence (see above), not an independent verification. It cannot
145 satisfy a build import. Real aien-test receipts for Crumbline and discovery programs are owed (ADR 0029 Decisions 5
146 and 11), as is a resolver-side minimum profile for the build domain (a host-v1 receipt written by hand still
147 satisfies a build import for a record that does not carry the bridge capability).
148- `omega_library_insert_bootstrap` still exists on the in-memory library and is not tied to the Genesis Set. No code calls
149 it; it is not a way into the Verified Crumb Store.
150- A dependency cycle cannot be built through the store API; it is refused when a tampered store holds one.