interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / adr / 0016-continuity-objects-over-store-v1.md

102 lines · 6472 bytes Raw Blame History Rendered
1# ADR 0016: Continuity objects over System Store v1
2
3Status: **Proposed.** Implemented as a QEMU qualification only. The object
4encodings below are a durable data format, so they are not frozen until the
5operator approves (escalation trigger: irreversible data formats). Until then
6every object carries format version 0 and every store holding them is
7disposable test media.
8
9Related: ADR 0003 (minimal object store), ADR 0006 (Recovery Core),
10ADR 0007 (provisioning once), ADR 0015 (System Store v1 format),
11docs/CONTINUOUS_EXISTENCE_AMENDMENT.md (Class A state, commit-before-observation).
12
13## Context
14
15System Store v1 (ADR 0015) gives AIENOS a crash-safe, generation-numbered,
16content-addressed object store over the native NVMe driver, qualified in
17QEMU at 4096- and 512-byte LBA (#134, #136). It stores opaque objects; it does
18not know what AIEN is. ADR 0007 requires that a normal boot locate, verify
19and resume one durable `LogicalAgentId`, and never mint a replacement. M4 is
20not done when storage works; it is done when a cold restart returns the same
21identity and the same committed memory.
22
23## Decision
24
25Continuity state is a small set of Store v1 objects with canonical,
26fixed-layout little-endian encodings (no serde, no JSON, `no_std`), defined in
27`aienos_kernel::continuity`. Every Store transaction that changes Class A
28state also writes a new `ContinuityManifest`, so each Store generation has
29exactly one continuity view.
30
31Object kinds (Store v1 `kind`; Store `version` is 1 because Store v1 rejects
32version 0; each object's own 16-byte header carries `format_version = 0`
33while this ADR is Proposed, and decoders reject any other value):
34
35| kind | name | written | content |
36|---|---|---|---|
37| 16 | `AgentRoot` | once, at provisioning | magic, `LogicalAgentId` (32 B), `genesis_store_uuid` (16 B) it was provisioned into, root `LogicalBranchId`, provisioning generation, provisioning source (operator / test) |
38| 17 | `ContinuityManifest` | every Class A commit | magic, `AgentRoot` ObjectId, `previous_manifest_id` (zero for the first or migration boundary), `migration_parent_id` (zero normally; points to `MigrationManifest` on the first manifest of a migrated store), sequence (previous + 1), incarnation (boot counter), ObjectIds of: agent-state checkpoint, Cortex checkpoint, Cortex WAL segments (bounded list), admission receipts (bounded list) |
39| 18 | `AgentStateCheckpoint` | when branch state changes | canonical branch table: branch id, parent, agent id, depth, fork counter |
40| 19 | `CortexCheckpoint` | when Cortex compacts | canonical committed records |
41| 20 | `CortexWalSegment` | on each committed Cortex update | append-only records since the checkpoint |
42| 23 | `MigrationManifest` | once, on store migration | magic, `AgentRoot` ObjectId, `genesis_store_uuid`, `origin_store_uuid`, `target_store_uuid`, origin `SecurityManifest` and `ContinuityManifest` IDs, origin sequence/incarnation/epoch, origin rollback-anchor digest, migration sequence, offline owner authorization signature |
43
44Boot resolution (deterministic, no model, no network):
45
461. Open the Store (ADR 0015). A `DegradedRecovery` mount is read-only: resume
47 is allowed for inspection, but no new incarnation is committed; report
48 `CONTINUITY: DEGRADED`.
492. Count `AgentRoot` objects in the catalog.
50 - 0 and provisioning was explicitly requested for this boot: create one
51 `LogicalAgentId` from the boot entropy source, commit `AgentRoot` and the
52 first manifest in one transaction, report `CONTINUITY: PROVISIONED`.
53 - 0 otherwise: **stop** with `CONTINUITY: UNPROVISIONED` (Recovery Core).
54 Never mint.
55 - more than 1: **stop** with `CONTINUITY: CONFLICT` (Recovery Core).
56 - exactly 1: continue.
573. The current manifest is the unique catalog manifest that no other manifest
58 names as previous, whose chain reaches either the genesis first manifest
59 (`previous_manifest_id = 0, migration_parent_id = 0`) or a validated migration
60 boundary (`previous_manifest_id = 0, migration_parent_id = MigrationManifest ID`)
61 with strictly consecutive sequence numbers and the same `AgentRoot` id.
62 Anything else (fork, gap, dangling reference, foreign root, undecodable object)
63 stops with `CONTINUITY: CORRUPT` (Recovery Core), never with a new identity.
644. Resume: verify every object the manifest names decodes; commit a new
65 manifest with `incarnation + 1` (commit-before-observation: the new
66 incarnation is durable before AIEN acts on it); report
67 `CONTINUITY: RESUMED agent=<id> incarnation=<n> sequence=<s>`.
68
69Provisioning is only reachable from an explicit request (QEMU control block
70today; an operator-authenticated Recovery Core action on hardware later,
71ADR 0006). The normal boot path contains no code that writes an `AgentRoot`.
72
73## Qualification (QEMU)
74
75`CONTINUITY_QEMU: PASS` requires, over the real NVMe path at 4096-byte LBA:
76
77- provision → commit Cortex facts and a branch fork → cold restart → same
78 `LogicalAgentId`, same facts, same branch lineage, incarnation + 1;
79- a second restart advances the incarnation again and changes nothing else;
80- SIGKILL at every Store checkpoint of a continuity commit → reopen resumes
81 the old or the new manifest, never a third state, same identity;
82- identity-loss refusal: an unprovisioned store booted normally stops with
83 `UNPROVISIONED` and writes nothing; a store with two roots stops with
84 `CONFLICT`; a broken manifest chain stops with `CORRUPT`;
85- `DegradedRecovery` mounts resume read-only and commit nothing.
86
87## Consequences
88
89- M4 continuity is proven in QEMU without freezing the encodings; freezing is a
90 separate operator decision that turns version 0 into version 1 with golden
91 vectors, as ADR 0015 did.
92- The host crates `aienos-agent-state` and `aienos-cortex` remain the richer
93 std models; their persisted form becomes these canonical objects.
94- Encryption (M5) wraps these objects later; this ADR fixes structure, not
95 confidentiality.
96- The Store v1 catalog is append-only and bounded (4096 entries), and every
97 Class A commit adds a manifest, so continuity needs catalog compaction before
98 long-running use. Out of scope here; tracked as follow-up.
99- Provisioning entropy is `RNDR` (FEAT_RNG). If the CPU does not implement it,
100 provisioning fails closed (`CONTINUITY: NO_ENTROPY`); it never falls back to
101 a predictable identity. Whether Machine 1's cores implement FEAT_RNG is a
102 hardware fact to record at the qualification wave.