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 / src / omega_vc_bridge.h

84 lines · 4633 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0
2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef OMEGA_VC_BRIDGE_H
18#define OMEGA_VC_BRIDGE_H
19
20/* omega_vc_bridge: the one in-process way a program enters an OmegaLibrary together with the
21 * Verified Crumb Store (VC1 stage 6, ADR 0029 Decisions 8 and 11).
22 *
23 * Before this existed Crumbline and discovery called omega_library_insert directly with a bare
24 * 32-byte hash. Now every program goes through omega_resolve_admit (the only door into the
25 * store): the bridge builds the canonical Verified Crumb of the program (semantic id =
26 * omega_program_compute_id, contract id = omega_program_contract_id, digest kind IR, the IR of
27 * omega_program_ir.h), writes an evidence receipt for it, and lets the resolver run SPEC 5.1 on
28 * that receipt. Only then is the library entry inserted, with the RECEIPT ID as its evidence hash.
29 *
30 * WHAT THE RECEIPT IS (stated, not hidden): the bridge itself runs omega_program_verify on a private
31 * copy of the program and recomputes the program id from the IR it stores, and refuses (-1) when
32 * either fails. It does NOT trust the caller's is_verified flag or program_id. It then records that
33 * as an EvidenceReceiptV1 of kind host-v1, tier HOST_TEST, with the evidence digest the caller
34 * supplies as its output_digest (the evidence_root). It is still a SELF-MINTED HOST_TEST receipt:
35 * the same code that asks for admission writes it, and no independent verifier re-ran anything.
36 * So the record it makes lists the capability OMEGA_BRIDGE_SELFMINTED_CAPABILITY, which the
37 * build-domain resolver refuses: a bridge record can sit in a store, but it can never satisfy a
38 * build import (oscv --domain build). The dev domain accepts it. Real aien-test receipts for
39 * Crumbline and discovery programs are owed (ADR 0029 Decision 5 and 11) and are not here.
40 *
41 * NOT A GENESIS PATH: the bridge never calls omega_resolve_admit_genesis. Nothing here can create
42 * a BOOTSTRAP record. */
43
44#include <stddef.h>
45#include <stdint.h>
46
47#include "omega_discovery.h"
48#include "omega_library.h"
49#include "omega_program.h"
50#include "omega_resolve.h"
51#include "omega_vcstore.h"
52
53typedef struct { uint8_t id[32]; char *json; size_t len; } OmegaVcBridgeReceipt;
54typedef struct { uint8_t digest[32]; uint8_t *bytes; size_t len; } OmegaVcBridgeBlob;
55
56typedef struct {
57 OmegaVcStore store;
58 OmegaVcBridgeReceipt *receipts; size_t n_receipts, cap_receipts;
59 OmegaVcBridgeBlob *blobs; size_t n_blobs, cap_blobs;
60} OmegaVcBridge;
61
62int omega_vc_bridge_init(OmegaVcBridge *b);
63void omega_vc_bridge_destroy(OmegaVcBridge *b);
64
65/* Receipt and IR sources over the bridge's own tables, in the resolver's fetch signatures
66 * (ctx = the OmegaVcBridge *), so a resolver can be pointed at the same store. */
67int omega_vc_bridge_fetch_receipt(void *ctx, const uint8_t id[32], uint8_t **bytes, size_t *len);
68int omega_vc_bridge_fetch_blob(void *ctx, const uint8_t digest[32], uint8_t **bytes, size_t *len);
69
70/* Admit prog (realized by the caller; verified and id-recomputed here) into the store through omega_resolve_admit,
71 * then into lib with the receipt id as its evidence hash. deps/dep_count are library
72 * dependencies; each must already be admitted through this bridge. evidence is the caller's
73 * non-zero evidence digest (it becomes the record's evidence_root). 0 on success; -1 and nothing
74 * inserted into lib on any refusal (a record that reached the store stays there: records are
75 * immutable and identical bytes are a no-op). */
76int omega_vc_bridge_admit(OmegaVcBridge *b, OmegaLibrary *lib, const OmegaProgram *prog,
77 const SemanticId *deps, size_t dep_count, const uint8_t evidence[32]);
78
79/* Discovery: the abstraction of cand, with the same guards omega_discovery_admit_to_library had
80 * (verified, non-trivial, positive compression). */
81int omega_vc_bridge_admit_abstraction(OmegaVcBridge *b, OmegaLibrary *lib, const OmegaAbstractionCandidate *cand,
82 const uint8_t evidence[32]);
83
84#endif /* OMEGA_VC_BRIDGE_H */