aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / svc / continuity_subject_provision.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 | /* continuity_subject_provision.h -- ALLEN genesis at identity provisioning. |
| 18 | * |
| 19 | * ARCH-0035 (PROPOSED) / OS-0018 (PROPOSED). A single-subject installation |
| 20 | * creates its ALLEN subject exactly once: in the SAME Store transaction that |
| 21 | * creates its identity. cs_provision runs cr_provision (OS-0016 provisioning, |
| 22 | * unchanged) over a sink that appends the genesis subject object (kind 24, |
| 23 | * sequence 1) to cr_provision's one transaction (AgentRoot, AgentState, |
| 24 | * Manifest 1): four objects, one ss_transact, one generation. There is no |
| 25 | * second WAL, no second database and no separate write: the subject inherits |
| 26 | * the Store's commit protocol (payload objects, catalog, commit record, |
| 27 | * flushes, superblock, anchor). A crash anywhere leaves either an |
| 28 | * unprovisioned Store or an identity WITH its subject, never one without |
| 29 | * the other. |
| 30 | * |
| 31 | * Restore never comes here. A provisioned Store whose subject is absent, |
| 32 | * corrupt, forked or foreign is reported by cs_resolve and never minted over. |
| 33 | * |
| 34 | * Kernel-side composition only (it needs cr_provision and the entropy |
| 35 | * source); omega links continuity_subject.c without this file. No thread, no |
| 36 | * wait, no clock, no scheduling, no authority. */ |
| 37 | #ifndef CK_CONTINUITY_SUBJECT_PROVISION_H |
| 38 | #define CK_CONTINUITY_SUBJECT_PROVISION_H |
| 39 | |
| 40 | #include <stdint.h> |
| 41 | |
| 42 | #include "continuity_commit.h" |
| 43 | #include "continuity_subject.h" |
| 44 | |
| 45 | #if defined(CK_HARDWARE_STAGING) && defined(CS_MUTANT_PROVISION_SPLIT_TXN) |
| 46 | #error "continuity subject provision mutants are TEST-only and refused under CK_HARDWARE_STAGING" |
| 47 | #endif |
| 48 | |
| 49 | /* What the provisioning request supplies about the subject. */ |
| 50 | struct cs_genesis { |
| 51 | uint8_t provenance[32]; /* nonzero: who/what established the subject */ |
| 52 | uint8_t origin; /* CS_ORIGIN_OPERATOR or CS_ORIGIN_PROMOTED */ |
| 53 | uint8_t cortex[32]; /* memory lineage reference; nonzero required */ |
| 54 | }; |
| 55 | |
| 56 | /* Identity + ALLEN genesis in one transaction. Refusals, in order: null or |
| 57 | * invalid genesis input (CR_E_ARG, nothing read); kind-24 objects already in |
| 58 | * the Store (CR_CORRUPT "subject objects without an agent root" when there is |
| 59 | * no root; a Store with a root is CR_ALREADY_PROVISIONED from cr_provision); |
| 60 | * then every cr_provision refusal unchanged. On success returns CR_RESOLVED |
| 61 | * with the identity view in *out, the genesis subject in *subj and its |
| 62 | * ObjectId in subj_id, after re-resolving both from the Store (post-condition: |
| 63 | * exactly one subject object, sequence 1, bound to this root and agent). */ |
| 64 | int cs_provision(const struct cr_source *src, const struct cr_sink *snk, struct cr_work *w, |
| 65 | struct cr_txwork *tw, struct ck_rng *rng, const uint8_t store_uuid[16], |
| 66 | uint8_t source, const struct cs_genesis *g, struct cr_view *out, |
| 67 | struct cs_subject *subj, uint8_t subj_id[32], const char **why, int *store_rc); |
| 68 | |
| 69 | #endif |