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 / src / omega_genesis.h
| 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_GENESIS_H |
| 18 | #define OMEGA_GENESIS_H |
| 19 | |
| 20 | /* VC-GENESIS-1: the Genesis Set of ADR 0029 Decision 8 (VC1 stage 6). |
| 21 | * |
| 22 | * The Genesis Set is the enumerated list of semantic ids (Omega program ids) that may exist in |
| 23 | * the Verified Crumb Store as BOOTSTRAP records, that is, without a receipt. It is the only start |
| 24 | * of trust that does not come from a receipt, so it is part of the trusted computing base and is |
| 25 | * kept as small as the audit allows. The audit record, the members and the reason for each are |
| 26 | * in docs/osc/VC-GENESIS-1.md. |
| 27 | * |
| 28 | * HOW IT IS USED (and the only ways): |
| 29 | * - omega_vcstore.c refuses to insert or to load a BOOTSTRAP record whose semantic id is not |
| 30 | * listed here (OMEGA_VCS_GENESIS_NOT_LISTED); |
| 31 | * - omega_resolve.c refuses omega_resolve_admit_genesis for an unlisted id and refuses to let an |
| 32 | * unlisted BOOTSTRAP record satisfy an import. The resolver has no genesis switch of any kind: whether |
| 33 | * a BOOTSTRAP record counts is decided by membership in this table and by nothing else. |
| 34 | * |
| 35 | * NO WAY AROUND IT: the table is a compile-time constant. There is no flag, no environment |
| 36 | * variable, no preprocessor switch, no file and no store content that adds a member. Changing |
| 37 | * the set means editing this file, and every edit is an ADR-level change reviewed as one (the |
| 38 | * source test tests/test_omega_genesis.c pins the count and the table below, and the audit record). |
| 39 | * |
| 40 | * No wildcard and no prefix match: an id is a member only if all 32 bytes equal a row. The |
| 41 | * all-zero id is never a member, whatever the table holds. */ |
| 42 | |
| 43 | #include <stddef.h> |
| 44 | #include <stdint.h> |
| 45 | #include <string.h> |
| 46 | |
| 47 | #define OMEGA_GENESIS_SET_NAME "VC-GENESIS-1" |
| 48 | |
| 49 | /* Number of members. The audit (docs/osc/VC-GENESIS-1.md, section "Audit") found that neither |
| 50 | * bootstrap caller of the library (src/crumbline/cl_program.c and src/omega_discovery.c) needs a |
| 51 | * record without a receipt, so the set is empty. */ |
| 52 | #define OMEGA_GENESIS_1_COUNT 0u |
| 53 | |
| 54 | /* One row per member, strictly ascending by memcmp. The row after the last member is an all-zero |
| 55 | * terminator that is never a member (so the array is never zero-sized). */ |
| 56 | static const uint8_t OMEGA_GENESIS_1[OMEGA_GENESIS_1_COUNT + 1u][32] = { |
| 57 | { 0 } |
| 58 | }; |
| 59 | |
| 60 | static inline size_t omega_genesis_count(void) |
| 61 | { |
| 62 | return OMEGA_GENESIS_1_COUNT; |
| 63 | } |
| 64 | |
| 65 | /* The i-th member (0 <= i < count), or NULL. */ |
| 66 | static inline const uint8_t *omega_genesis_member(size_t i) |
| 67 | { |
| 68 | const size_t n = OMEGA_GENESIS_1_COUNT; |
| 69 | return i < n ? OMEGA_GENESIS_1[i] : NULL; |
| 70 | } |
| 71 | |
| 72 | /* 1 when id (32 bytes) is a member of VC-GENESIS-1, else 0. NULL and the zero id are not members. */ |
| 73 | static inline int omega_genesis_contains(const uint8_t *id) |
| 74 | { |
| 75 | static const uint8_t zero[32] = { 0 }; |
| 76 | const size_t n = OMEGA_GENESIS_1_COUNT; |
| 77 | if (!id || memcmp(id, zero, 32) == 0) return 0; |
| 78 | for (size_t i = 0; i < n; i++) |
| 79 | if (memcmp(OMEGA_GENESIS_1[i], id, 32) == 0) return 1; |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | #endif /* OMEGA_GENESIS_H */ |