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_service.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_service.h -- production continuity on the resident lifecycle |
| 18 | * (native v1 plan P05, cut 1; aienos#35, #31). |
| 19 | * |
| 20 | * Linked only into a CK_SERVICE=1 image (and the host stage test with |
| 21 | * CK_CONT_SERVICE_HOST_TEST). The TEST-ONLY mode selection of |
| 22 | * svc/continuity_boot.c (plan line on the disk, modes 5..11, the TEST |
| 23 | * operator key, the Recovery Core) is never part of this image: the Makefile |
| 24 | * cont_check refuses its symbols and strings in every service image. |
| 25 | * |
| 26 | * What runs, once per Store open (store stage with keys, or `unlock`): |
| 27 | * unprovisioned Store -> PROVISIONED: identity (AgentRoot, genesis |
| 28 | * AgentState, Manifest 1) AND the genesis ALLEN subject (kind 24, |
| 29 | * sequence 1) in ONE Store transaction (svc/continuity_subject_provision.c); |
| 30 | * entropy from the kernel RNDR service, no fallback (NO_ENTROPY refuses). |
| 31 | * provisioned Store -> the ALLEN subject is restored read-only first; absent, |
| 32 | * corrupt, forked or foreign subject: REFUSED, nothing written, never |
| 33 | * minted over. Then cr_resume commits incarnation + 1 (RESUMED), or on a |
| 34 | * degraded mount restores without writing (RESUMED_READONLY: commits refused). |
| 35 | * anything else (Conflict, Corrupt, Limit, Store error) -> REFUSED. |
| 36 | * A REFUSED outcome keeps the lifecycle LOCKED: the Store keys are erased and |
| 37 | * the disk bytes are left as found (svc/store_boot.c). |
| 38 | * |
| 39 | * Genesis inputs (v1, deterministic, public): provenance = SHA-256("AIENOS/ALLEN/PROVENANCE-V1" |
| 40 | * || owner root public key (if the image carries one) || store uuid); cortex |
| 41 | * lineage = SHA-256("AIENOS/ALLEN/CORTEX-LINEAGE-V1" || store uuid): the Cortex of |
| 42 | * this subject is the sealed Store on this disk (CURRENT_EXECUTION_PLAN addendum, |
| 43 | * conflict 3; the Omega CxStore adapter of P06 writes the records). |
| 44 | * |
| 45 | * Not here (limits): Cortex records / the approved note are not yet continuity |
| 46 | * WAL records (P06); no Recovery Core in the service image (its operator key |
| 47 | * is TEST-only); no TPM; hardware NOT_RUN. */ |
| 48 | #ifndef CK_CONTINUITY_SERVICE_H |
| 49 | #define CK_CONTINUITY_SERVICE_H |
| 50 | #include <stddef.h> |
| 51 | #include <stdint.h> |
| 52 | #include "continuity_codec.h" |
| 53 | #include "store_sealed.h" |
| 54 | |
| 55 | enum { |
| 56 | CK_CONT_NONE = 0, /* not started (Store locked / stopped) */ |
| 57 | CK_CONT_PROVISIONED = 1, /* identity + genesis subject minted, one transaction */ |
| 58 | CK_CONT_RESUMED = 2, /* restored; incarnation + 1 committed */ |
| 59 | CK_CONT_RESUMED_READONLY = 3, /* degraded mount: restored, nothing written, commits refused */ |
| 60 | CK_CONT_REFUSED = -1, /* explicit refusal: lifecycle stays LOCKED */ |
| 61 | }; |
| 62 | |
| 63 | /* source: CC_SOURCE_OPERATOR (hardware staging image) or CC_SOURCE_QUALIFICATION |
| 64 | * (TEST-key service image, QEMU). owner_pk/owner_pk_len: the build-time owner |
| 65 | * root public key or NULL/0. Prints its "continuity:" and "allen:" lines. */ |
| 66 | int ck_cont_service_start(ss_store *s, const uint8_t store_uuid[16], const uint8_t *owner_pk, |
| 67 | size_t owner_pk_len, uint8_t source); |
| 68 | int ck_cont_service_state(void); /* CK_CONT_* of the last start (CK_CONT_NONE after stop) */ |
| 69 | int ck_cont_service_writable(void); /* 1 after PROVISIONED or RESUMED */ |
| 70 | /* "continuity=<word> agent=<8 hex> incarnation=<n> subject_seq=<n>" (NUL-terminated). */ |
| 71 | void ck_cont_service_status(char *out, size_t cap); |
| 72 | const uint8_t *ck_cont_service_agent(void); /* 32 bytes, or NULL before a successful start */ |
| 73 | uint64_t ck_cont_service_incarnation(void); /* durable incarnation of this boot, 0 before a successful start */ |
| 74 | void ck_cont_service_stop(void); /* forget the view (the Store keys are gone) */ |
| 75 | #endif |