aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / docs / milestone-3-spec.md
| 1 | # Specification: Milestone 3 — Physics Effects & Capability Authority (`PHYSICS_EFFECTS`) |
| 2 | |
| 3 | ```text |
| 4 | Document ID: SPEC-PHYSICS-M3 |
| 5 | Milestone: Milestone 3 (PHYSICS_EFFECTS) |
| 6 | Classification: Sovereign Machine Canonical Specification |
| 7 | Target Substrate: Physical Compute Fabric (AArch64 CPU Host, PL011 UART, Physical DRAM Frames) |
| 8 | Status: SPECIFIED / IN PROGRESS (aien-spark/aien-architecture#11) |
| 9 | Lineage: SILICON -> ATLAS (M1) -> PHYSICS (M2/M3) -> OMEGA (M4+) -> AIEN |
| 10 | ``` |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | ## 1. Executive Summary & Foundational Invariant |
| 15 | |
| 16 | Milestone 2 established the **Physics Authority Nucleus** (`PHYSICS_BOOT`): validating ingress parameters from Atlas, adopting current-EL exception vectors, binding physical frame authority, establishing polled diagnostic console telemetry, and synthesizing the genesis root capability record. |
| 17 | |
| 18 | Milestone 3 establishes the **Physics Effects Engine** (`PHYSICS_EFFECTS`): the capability ledger, monotonic attenuation engine, deterministic effect broker, and cryptographic execution receipts. |
| 19 | |
| 20 | The supreme constitutional invariant enforced by Milestone 3 is: |
| 21 | |
| 22 | > **NO PHYSICAL EFFECT OCCURS WITHOUT VALID AUTHORITY, AND EVERY EFFECT ATTEMPT PRODUCES VERIFIABLE EVIDENCE.** |
| 23 | |
| 24 | PHYSICS is the sole physical authority of the Sovereign Machine. |
| 25 | No caller—including future OMEGA synthesis runtimes or AIEN cognitive agents—gains authority merely by knowing a physical memory address, an operation opcode, or a capability data structure layout. All authority derives strictly from validated, kernel-private capabilities, and every attempted transition into physical reality is mediated, authorized, executed, and receipted by Physics. |
| 26 | |
| 27 | --- |
| 28 | |
| 29 | ## 2. Strict Anti-Scope (The Anti-Bloat Law) |
| 30 | |
| 31 | Milestone 3 is an authority and effect governance milestone, **not** a general operating system expansion. |
| 32 | Physics remains an immutable, auditable authority nucleus. |
| 33 | |
| 34 | The following components are **strictly excluded** from Milestone 3: |
| 35 | - Filesystems and Virtual File Systems (VFS) |
| 36 | - Block storage device stacks |
| 37 | - Network protocol stacks, sockets, and interfaces |
| 38 | - Schedulers, threads, processes, and preemptive task management |
| 39 | - POSIX compatibility layers and libc dependencies |
| 40 | - Dynamic loaders and ELF interpreters |
| 41 | - GPU initialization, accelerator drivers, and firmware loading |
| 42 | - Model runtime, neural weights, and tensor engines |
| 43 | - OMEGA semantic runtime and AST compilers |
| 44 | - AIEN cognitive models and world-state graphs |
| 45 | - General unprivileged userspace (EL0 execution remains decoupled) |
| 46 | - Unrestricted device drivers or arbitrary MMIO access |
| 47 | |
| 48 | ### Anti-Bloat Ceilings |
| 49 | - `.text` size $\le 32\text{ KiB}$ |
| 50 | - `PHYSICS_TOTAL_IMAGE_BYTES` $\le 64\text{ KiB}$ (code, rodata, vectors, alignment padding) |
| 51 | - Capability table: static 4 KiB allocation (32 fixed-size records) |
| 52 | - Receipt ledger: static 8 KiB allocation (32 chained receipts) |
| 53 | - Replay cache: static 4 KiB allocation (32 replay slots) |
| 54 | |
| 55 | --- |
| 56 | |
| 57 | ## 3. Tripartite Division of Physical Authority |
| 58 | |
| 59 | Physics enforces an unyielding ontological separation between authority, intent, and evidence: |
| 60 | |
| 61 | ```text |
| 62 | ┌────────────────────────────────────────────────────────────────────────┐ |
| 63 | │ CAPABILITY │ |
| 64 | │ Authority to attempt a bounded class of effects │ |
| 65 | │ Kernel-private, typed handle, non-forgeable, attenuable │ |
| 66 | └───────────────────────────────────┬────────────────────────────────────┘ |
| 67 | │ |
| 68 | Exercised through |
| 69 | │ |
| 70 | ▼ |
| 71 | ┌────────────────────────────────────────────────────────────────────────┐ |
| 72 | │ EFFECT_INTENT │ |
| 73 | │ Structured request to exercise specific authority │ |
| 74 | │ Caller-provided, compact binary, validated upon entry │ |
| 75 | └───────────────────────────────────┬────────────────────────────────────┘ |
| 76 | │ |
| 77 | Evaluated by Effect Broker |
| 78 | │ |
| 79 | ▼ |
| 80 | ┌────────────────────────────────────────────────────────────────────────┐ |
| 81 | │ EFFECT_RECEIPT │ |
| 82 | │ Authoritative cryptographic record of decision and result │ |
| 83 | │ Typed decision, SHA-256 chain, immutable audit trail, non-loss │ |
| 84 | └────────────────────────────────────────────────────────────────────────┘ |
| 85 | ``` |
| 86 | |
| 87 | 1. **`CAPABILITY`**: Represents sovereign authority granted by Physics. A caller never holds a raw kernel pointer; callers hold typed references (`CapabilityId { slot, generation }`). The capability defines resource type, allowed operation bitmask, strict physical address bounds, lifetime, and parent provenance. |
| 88 | 2. **`EFFECT_INTENT`**: Represents an explicit request to act upon physical reality. It specifies the capability to exercise, target resource, operation, spatial bounds, parameters, and constraints. |
| 89 | 3. **`EFFECT_RECEIPT`**: The authoritative output of the effect cycle. Every submitted intent—whether admitted and executed or rejected at any gate—generates an immutable receipt committed to an append-only cryptographic ledger. |
| 90 | |
| 91 | --- |
| 92 | |
| 93 | ## 4. Capability Model & Memory Layout |
| 94 | |
| 95 | ### 4.1 Typed Capability Identifier (`CapabilityId`) |
| 96 | Capabilities are referenced externally exclusively via an 8-byte typed handle: |
| 97 | |
| 98 | ```text |
| 99 | CapabilityId (8 bytes): |
| 100 | +0x00: slot (u32) — Index into PHYSICS_CAPABILITY_TABLE [0..31] |
| 101 | +0x04: generation (u32) — Monotonic slot generation counter [1..2^32-1] |
| 102 | ``` |
| 103 | |
| 104 | **Invariants:** |
| 105 | - A raw memory address is never accepted as a capability handle. |
| 106 | - Handles presenting stale generations are rejected immediately (`REJECTED_STALE_GENERATION`). |
| 107 | - Handles presenting out-of-range slots are rejected immediately (`REJECTED_UNKNOWN_CAP`). |
| 108 | |
| 109 | ### 4.2 Capability Record Layout (`CapabilityRecord`) |
| 110 | Every record in the capability ledger occupies exactly 128 bytes: |
| 111 | |
| 112 | ```text |
| 113 | CapabilityRecord (128 bytes, 64-bit aligned): |
| 114 | +0x00: slot (u32) — Slot index [0..31] |
| 115 | +0x04: generation (u32) — Slot generation counter (1-indexed) |
| 116 | +0x08: principal_id (u64) — Authorized principal identity (e.g. 1 = Physics) |
| 117 | +0x10: resource_type (u32) — Bounded resource class identifier |
| 118 | +0x14: allowed_ops (u32) — Bitmask of authorized operations |
| 119 | +0x18: bound_base (u64) — Physical start address of resource authority |
| 120 | +0x20: bound_size (u64) — Physical byte span of resource authority |
| 121 | +0x28: revocation_state (u32) — 1 = ACTIVE, 2 = REVOKED |
| 122 | +0x2C: attenuation_depth (u32) — Derivation distance from root (0 for CAP_ROOT) |
| 123 | +0x30: provenance_digest (32 bytes) — SHA-256 derivation commitment |
| 124 | +0x50: parent_slot (u32) — Slot index of immediate parent (0xFFFFFFFF for root) |
| 125 | +0x54: parent_generation (u32) — Generation of immediate parent (0xFFFFFFFF for root) |
| 126 | +0x58: lifetime (u64) — Temporal / epoch bound (0 = unbounded) |
| 127 | +0x60: reserved (32 bytes) — Zero-padded alignment space |
| 128 | ``` |
| 129 | |
| 130 | ### 4.3 Capacity & Memory Region |
| 131 | The capability ledger resides strictly within `PHYSICS_CAPABILITY_TABLE` (`0x40206000`–`0x40207000`, 4,096 bytes). |
| 132 | - Record size: 128 bytes ($2^7$ bytes, indexed via `slot << 7`). |
| 133 | - Ledger capacity: exactly 32 records ($32 \times 128 = 4,096$ bytes). |
| 134 | - No dynamic memory allocation. No heap. |
| 135 | |
| 136 | --- |
| 137 | |
| 138 | ## 5. Genesis Root Capability (`CAP_ROOT`) |
| 139 | |
| 140 | `CAP_ROOT` is the sovereign genesis authority established at system awakening: |
| 141 | - **Slot**: 0 |
| 142 | - **Generation**: 1 |
| 143 | - **Principal ID**: `0x0000000000000001` (`PRINCIPAL_PHYSICS`) |
| 144 | - **Resource Type**: `0x00000001` (`RES_UNIVERSAL_ROOT`) |
| 145 | - **Allowed Ops**: `0xFFFFFFFF` (`OP_ALL_AUTHORITY`) |
| 146 | - **Bound Base**: `0x40208000` (`FREE_FRAME_BASE`) |
| 147 | - **Bound Size**: `0x07DF8000` (~125.9 MiB, `DRAM_END - FREE_FRAME_BASE`) |
| 148 | - **Revocation State**: `0x00000001` (`ACTIVE`) |
| 149 | - **Attenuation Depth**: 0 |
| 150 | - **Parent Slot**: `0xFFFFFFFF` (None) |
| 151 | - **Parent Generation**: `0xFFFFFFFF` (None) |
| 152 | - **Lifetime**: 0 (Unbounded) |
| 153 | - **Provenance Digest**: 32-byte canonical SHA-256 digest of `atlas.bin`. |
| 154 | |
| 155 | ### Invariants: |
| 156 | 1. `CAP_ROOT` is **kernel-private, non-transferable, and non-exportable**. |
| 157 | 2. External principals never receive `CAP_ROOT` itself. |
| 158 | 3. Every usable authority held by any caller is derived through monotonic attenuation from `CAP_ROOT` or one of its descendants. |
| 159 | 4. Slot 0 is permanently pinned to `CAP_ROOT` and cannot be reclaimed, overwritten, or reused. |
| 160 | |
| 161 | --- |
| 162 | |
| 163 | ## 6. Monotonic Attenuation Engine |
| 164 | |
| 165 | Authority may only be derived via monotonic attenuation: |
| 166 | |
| 167 | $$\text{derive\_capability}(\text{parent\_id}, \text{child\_principal}, \text{resource\_type}, \text{ops}, \text{base}, \text{size}, \text{lifetime}) \to \text{CapabilityId} \mid \text{Error}$$ |
| 168 | |
| 169 | ### The Monotonic Invariant |
| 170 | $$\begin{aligned} |
| 171 | \text{CHILD RIGHTS} &\subseteq \text{PARENT RIGHTS} \\ |
| 172 | \text{CHILD BOUNDS} &\subseteq \text{PARENT BOUNDS} \\ |
| 173 | \text{CHILD LIFETIME} &\le \text{PARENT LIFETIME} \\ |
| 174 | \text{CHILD AUTHORITY} &\le \text{PARENT AUTHORITY} |
| 175 | \end{aligned}$$ |
| 176 | |
| 177 | ### Attenuation Rules: |
| 178 | 1. **Rights Containment**: |
| 179 | $$( \text{requested\_ops} \land \neg \text{parent.allowed\_ops} ) = 0$$ |
| 180 | A child cannot gain any operation bit that the parent lacks. |
| 181 | 2. **Spatial Bounds Containment**: |
| 182 | All address calculations use checked arithmetic: |
| 183 | $$\begin{aligned} |
| 184 | \text{requested\_base} &\ge \text{parent.bound\_base} \\ |
| 185 | \text{requested\_base} + \text{requested\_size} &\ge \text{requested\_base} \quad (\text{no overflow}) \\ |
| 186 | \text{requested\_base} + \text{requested\_size} &\le \text{parent.bound\_base} + \text{parent.bound\_size} |
| 187 | \end{aligned}$$ |
| 188 | Partial overlap is refused. Complete containment is strictly enforced. |
| 189 | 3. **Resource Type Rule**: |
| 190 | - If `parent.resource_type == RES_UNIVERSAL_ROOT`, child may select any concrete resource class (`RES_MEMORY_FRAME`, `RES_CONSOLE`, `RES_MEASUREMENT`). |
| 191 | - If parent has a concrete resource class, child `resource_type` must equal `parent.resource_type`. |
| 192 | 4. **Lifetime Rule**: |
| 193 | If parent has a finite lifetime ($> 0$), child lifetime must be $\le \text{parent.lifetime}$ and non-zero. |
| 194 | 5. **Anti-Root Equivalence Rule**: |
| 195 | A derived capability can never have `resource_type == RES_UNIVERSAL_ROOT` or `principal_id == 0`. |
| 196 | 6. **Provenance Chain**: |
| 197 | The child's provenance digest is computed deterministically as: |
| 198 | $$\text{child.provenance} = \text{SHA256}(\text{parent.provenance} \parallel \text{child\_fields})$$ |
| 199 | 7. **Ancestry Record**: |
| 200 | $$\text{child.parent\_slot} = \text{parent.slot}, \quad \text{child.parent\_generation} = \text{parent.generation}$$ |
| 201 | $$\text{child.attenuation\_depth} = \text{parent.attenuation\_depth} + 1$$ |
| 202 | |
| 203 | --- |
| 204 | |
| 205 | ## 7. Generation Model & Revocation Lifecycle |
| 206 | |
| 207 | ### 7.1 Slot Lookup Validation |
| 208 | Before any capability can be exercised or attenuated, Physics validates: |
| 209 | 1. $0 \le \text{slot} < 32$ (ledger bounds check). |
| 210 | 2. Record is occupied ($\text{generation} > 0$). |
| 211 | 3. $\text{presented\_generation} == \text{record.generation}$ (stale handle check). |
| 212 | 4. $\text{record.revocation\_state} == \text{ACTIVE}$ (immediate revocation check). |
| 213 | 5. $\text{record.principal\_id} == \text{caller\_principal}$ (principal check). |
| 214 | |
| 215 | ### 7.2 Monotonic Generation Bumping |
| 216 | When a capability slot (1..31) is freed or reallocated: |
| 217 | $$\text{generation} := \text{generation} + 1$$ |
| 218 | - If `generation` reaches `0xFFFFFFFF`, the slot is permanently marked exhausted and fails closed. |
| 219 | - Stale capability handles presenting older generation numbers fail lookup closed. |
| 220 | |
| 221 | ### 7.3 Instantaneous Descendant Revocation (Ancestor-Chain Validation) |
| 222 | Physics enforces **ancestor-chain validation on use**: |
| 223 | - When capability $C$ is evaluated, Physics inspects $C$'s revocation state. |
| 224 | - If $C$ is derived ($\text{slot} \ne 0$), Physics traverses the parent lineage: |
| 225 | For each ancestor $A$ up to `attenuation_depth` (bounded $\le 8$): |
| 226 | - Verify $A.\text{generation} == C.\text{parent\_generation}$. |
| 227 | - Verify $A.\text{revocation\_state} == \text{ACTIVE}$. |
| 228 | - If any ancestor in the provenance chain is revoked or stale, validation immediately fails closed (`REJECTED_REVOKED`). |
| 229 | - Result: Revoking a parent capability immediately and deterministically renders all descendant capabilities unusable across the machine, with zero heap allocations and $O(\text{depth})$ bounded verification. |
| 230 | |
| 231 | --- |
| 232 | |
| 233 | ## 8. M3 Resource Classes & Operations |
| 234 | |
| 235 | Milestone 3 implements the minimal set of physical resources necessary to establish and qualify the authority architecture: |
| 236 | |
| 237 | ```text |
| 238 | ┌──────────────────────────┬────────────┬──────────────────────┬────────────┐ |
| 239 | │ Resource Class │ Type Code │ Operation │ Opcode │ |
| 240 | ├──────────────────────────┼────────────┼──────────────────────┼────────────┤ |
| 241 | │ `RESOURCE_MEMORY_FRAME` │ 0x00000002 │ `FRAME_GRANT` │ 0x00000001 │ |
| 242 | │ │ │ `FRAME_RELEASE` │ 0x00000002 │ |
| 243 | ├──────────────────────────┼────────────┼──────────────────────┼────────────┤ |
| 244 | │ `RESOURCE_CONSOLE` │ 0x00000003 │ `CONSOLE_WRITE` │ 0x00000001 │ |
| 245 | ├──────────────────────────┼────────────┼──────────────────────┼────────────┤ |
| 246 | │ `RESOURCE_MEASUREMENT` │ 0x00000004 │ `MEASUREMENT_READ` │ 0x00000001 │ |
| 247 | └──────────────────────────┴────────────┴──────────────────────┴────────────┘ |
| 248 | ``` |
| 249 | |
| 250 | ### Constraints: |
| 251 | 1. `RESOURCE_MEMORY_FRAME`: |
| 252 | - Target range must be 4 KiB aligned and strictly contained within the capability's `[bound_base, bound_base + bound_size)`. |
| 253 | - `FRAME_GRANT` allocates a 4 KiB page and marks the allocation bitmap. |
| 254 | - `FRAME_RELEASE` clears the bitmap for an allocated frame. |
| 255 | 2. `RESOURCE_CONSOLE`: |
| 256 | - Target address must match the contracted PL011 UART MMIO base (`0x09000000`). |
| 257 | - `CONSOLE_WRITE` outputs a bounded byte sequence. Arbitrary MMIO access is strictly prohibited. |
| 258 | 3. `RESOURCE_MEASUREMENT`: |
| 259 | - Reads sovereign machine telemetry: allocated frame count, receipt sequence counter, machine epoch. |
| 260 | |
| 261 | --- |
| 262 | |
| 263 | ## 9. Effect Intent Binary Format (`EffectIntent`) |
| 264 | |
| 265 | Callers submit effect requests using a compact, fixed-size binary structure: |
| 266 | |
| 267 | ```text |
| 268 | EffectIntent (64 bytes, little-endian, 64-bit aligned): |
| 269 | +0x00: version (u16 = 1) |
| 270 | +0x02: length (u16 = 64) |
| 271 | +0x04: reserved0 (u32 = 0) |
| 272 | +0x08: request_id (u64) — Caller-generated unique request identifier |
| 273 | +0x10: principal_id (u64) — Caller principal identity |
| 274 | +0x18: capability_slot (u32) — Slot of presented capability |
| 275 | +0x1C: capability_generation (u32) — Generation of presented capability |
| 276 | +0x20: resource_type (u32) — Target resource class |
| 277 | +0x24: operation (u32) — Requested operation bitmask |
| 278 | +0x28: target_base (u64) — Target physical address / base |
| 279 | +0x30: target_size (u64) — Target byte length / size |
| 280 | +0x38: param0 (u64) — Operation parameter 0 / constraints (e.g. data byte/address) |
| 281 | ``` |
| 282 | |
| 283 | **Invariants:** |
| 284 | - Fixed 64-byte width. No variable-length strings. No JSON. No textual parsing. |
| 285 | - Unaligned structures or truncated buffers trigger immediate structural refusal. |
| 286 | |
| 287 | --- |
| 288 | |
| 289 | ## 10. Effect Broker & Admission Pipeline |
| 290 | |
| 291 | The Effect Broker owns the single canonical effect-admission path: |
| 292 | |
| 293 | $$\text{submit\_effect}(\text{intent}) \to \text{EffectReceipt}$$ |
| 294 | |
| 295 | Handlers execute only already-admitted operations. Admission and physical execution are strictly decoupled in control flow. |
| 296 | |
| 297 | ```text |
| 298 | EFFECT_INTENT |
| 299 | │ |
| 300 | ▼ |
| 301 | [Stage 1: Structural Validation] ──(Fail)──► REJECTED_STRUCTURAL |
| 302 | │ (Pass) |
| 303 | ▼ |
| 304 | [Stage 2: Principal Validation] ──(Fail)──► REJECTED_WRONG_PRINCIPAL |
| 305 | │ (Pass) |
| 306 | ▼ |
| 307 | [Stage 3: Capability Lookup] ──(Fail)──► REJECTED_UNKNOWN_CAP |
| 308 | │ (Pass) |
| 309 | ▼ |
| 310 | [Stage 4: Generation Check] ──(Fail)──► REJECTED_STALE_GENERATION |
| 311 | │ (Pass) |
| 312 | ▼ |
| 313 | [Stage 5: Revocation Chain Check] ──(Fail)──► REJECTED_REVOKED |
| 314 | │ (Pass) |
| 315 | ▼ |
| 316 | [Stage 6: Operation Rights Check] ──(Fail)──► REJECTED_OPERATION |
| 317 | │ (Pass) |
| 318 | ▼ |
| 319 | [Stage 7: Resource Type Check] ──(Fail)──► REJECTED_RESOURCE |
| 320 | │ (Pass) |
| 321 | ▼ |
| 322 | [Stage 8: Bounds & Overflow Check]──(Fail)──► REJECTED_BOUNDS |
| 323 | │ (Pass) |
| 324 | ▼ |
| 325 | [Stage 9: Replay Cache Check] ──(Conflict)──► REJECTED_REPLAY_CONFLICT |
| 326 | │ ──(Hit: Same)─► Return Cached Receipt (No re-exec) |
| 327 | │ (New Request) |
| 328 | ▼ |
| 329 | [Stage 10: Ledger Space Check] ──(Full)──► REJECTED_EXHAUSTED |
| 330 | │ (Pass) |
| 331 | ▼ |
| 332 | [Stage 11: PHYSICAL EXECUTION] (Only reached after all admission checks pass) |
| 333 | │ |
| 334 | ▼ |
| 335 | [Stage 12: COMMIT TO RECEIPT LEDGER & REPLAY CACHE] |
| 336 | │ |
| 337 | ▼ |
| 338 | EFFECT_RECEIPT |
| 339 | ``` |
| 340 | |
| 341 | **Cardinal Rule:** Any failure before Stage 11 produces zero physical state mutation. |
| 342 | |
| 343 | --- |
| 344 | |
| 345 | ## 11. Effect Receipts & Typed Decisions |
| 346 | |
| 347 | Every intent evaluated by the broker generates an immutable `EffectReceipt`: |
| 348 | |
| 349 | ```text |
| 350 | EffectReceipt (192 bytes, 64-bit aligned): |
| 351 | +0x00: version (u16 = 1) |
| 352 | +0x02: length (u16 = 192) |
| 353 | +0x04: decision (u32) — Typed decision code |
| 354 | +0x08: rejection_reason (u32) — Specific sub-reason code |
| 355 | +0x0C: reserved0 (u32 = 0) |
| 356 | +0x10: request_id (u64) — Mirrored from EffectIntent |
| 357 | +0x18: intent_digest (32 bytes) — SHA-256 of the 64-byte EffectIntent |
| 358 | +0x38: actual_effect (u64) — Physical effect result (e.g. granted frame) |
| 359 | +0x40: output (u64) — Output code / bytes processed |
| 360 | +0x48: capability_slot (u32) — Presented slot |
| 361 | +0x4C: capability_generation (u32) — Presented generation |
| 362 | +0x50: machine_generation (u64) — Current machine monotonic counter |
| 363 | +0x58: measurement (u64) — Hardware measurement / cycle counter |
| 364 | +0x60: previous_receipt_digest (32 bytes) — SHA-256 of prior receipt in chain |
| 365 | +0x80: receipt_digest (32 bytes) — SHA-256 of receipt bytes 0x00..0x7F |
| 366 | +0xA0: reserved1 (32 bytes) — Reserved padding |
| 367 | ``` |
| 368 | |
| 369 | ### Typed Decision Codes: |
| 370 | ```text |
| 371 | ADMITTED = 0x00000001 (Admitted and executed) |
| 372 | REJECTED_STRUCTURAL = 0x00000002 (Bad version, length, reserved bits) |
| 373 | REJECTED_UNKNOWN_CAP = 0x00000003 (Slot out of range or unpopulated) |
| 374 | REJECTED_STALE_GENERATION= 0x00000004 (Presented generation != slot generation) |
| 375 | REJECTED_REVOKED = 0x00000005 (Target cap or ancestor revoked) |
| 376 | REJECTED_WRONG_PRINCIPAL = 0x00000006 (Caller principal mismatch) |
| 377 | REJECTED_OPERATION = 0x00000007 (Requested op not in allowed_ops) |
| 378 | REJECTED_RESOURCE = 0x00000008 (Intent resource != cap resource) |
| 379 | REJECTED_BOUNDS = 0x00000009 (Target outside cap bounds or wraps) |
| 380 | REJECTED_CONSTRAINT = 0x0000000A (Constraint failure) |
| 381 | REJECTED_REPLAY_CONFLICT = 0x0000000B (Same request_id, different intent) |
| 382 | REJECTED_EXHAUSTED = 0x0000000C (Receipt ledger capacity full) |
| 383 | EXECUTION_FAILED = 0x0000000D (Admitted but hardware execution failed) |
| 384 | ``` |
| 385 | |
| 386 | --- |
| 387 | |
| 388 | ## 12. Cryptographic Receipt Chain & Bounded Ledger |
| 389 | |
| 390 | ### 12.1 Digest Binding & Tamper Evidence |
| 391 | - Each receipt binds `previous_receipt_digest`. For the genesis receipt (receipt 0), `previous_receipt_digest` is 32 zero bytes. |
| 392 | - The `receipt_digest` seals all fields from `+0x00` through `+0x7F` (including `previous_receipt_digest`, `intent_digest`, decision, and actual effect) using NIST SHA-256. |
| 393 | - Mutation or reordering of receipts in memory is cryptographically detectable. |
| 394 | |
| 395 | ### 12.2 Ledger Exhaustion Policy (Fail-Closed) |
| 396 | - Capacity: 32 receipts located in `PHYSICS_RECEIPT_LEDGER` (`0x40208000`–`0x4020A000`, 8,192 bytes). |
| 397 | - When the ledger reaches capacity (32 receipts committed), Physics **halts effect admission**. |
| 398 | - Subsequent intents receive `REJECTED_EXHAUSTED` and cause zero physical effect. |
| 399 | - Physics **never silently overwrites evidence**. |
| 400 | |
| 401 | --- |
| 402 | |
| 403 | ## 13. Replay Semantics & Cache |
| 404 | |
| 405 | Physics maintains a bounded 32-entry Replay Cache in `PHYSICS_REPLAY_CACHE` (`0x4020A000`–`0x4020B000`, 4,096 bytes). |
| 406 | |
| 407 | ```text |
| 408 | ReplayRecord (64 bytes): |
| 409 | +0x00: request_id (u64) |
| 410 | +0x08: intent_digest (32 bytes) |
| 411 | +0x28: receipt_slot (u32) |
| 412 | +0x2C: decision (u32) |
| 413 | +0x30: actual_effect (u64) |
| 414 | +0x38: reserved (16 bytes) |
| 415 | ``` |
| 416 | |
| 417 | ### Replay Rules: |
| 418 | 1. **Idempotent Hit**: Same `request_id` AND identical `intent_digest`: |
| 419 | - Returns the previous receipt / semantic result without re-executing the physical effect. |
| 420 | - Example: Repeating a `FRAME_GRANT` returns the previously granted frame address without advancing the frame allocator cursor. |
| 421 | 2. **Replay Conflict**: Same `request_id` AND differing `intent_digest`: |
| 422 | - Rejected immediately with `REJECTED_REPLAY_CONFLICT`. |
| 423 | - Zero physical effect occurs. |
| 424 | - A rejection receipt is committed to evidence. |
| 425 | |
| 426 | --- |
| 427 | |
| 428 | ## 14. Milestone 3 Disjoint Memory Map |
| 429 | |
| 430 | Physics partitions physical memory into strictly disjoint, non-overlapping regions: |
| 431 | |
| 432 | ```text |
| 433 | 0x4000_0000 ┌──────────────────────────────────────────┐ <── DRAM Base (Atlas Staging / DTB) |
| 434 | │ Unused / Staging / Atlas Scratchpad │ |
| 435 | 0x4020_0000 ├──────────────────────────────────────────┤ <── PHYSICS_IMAGE_BASE |
| 436 | │ PHYSICS_IMAGE (.text, .rodata, SHA-256) │ [16 KiB] [0x40200000, 0x40204000) |
| 437 | 0x4020_4000 ├──────────────────────────────────────────┤ <── PHYSICS_VECTOR_TABLE (2 KiB aligned) |
| 438 | │ VBAR Table (16 x 128B slots) │ [2 KiB] [0x40204000, 0x40204800) |
| 439 | 0x4020_4800 ├──────────────────────────────────────────┤ <── PHYSICS_KERNEL_STACK |
| 440 | │ Dedicated Kernel Stack (Initial SP) │ [16 KiB] [0x40204800, 0x40208800) |
| 441 | 0x4020_8800 ├──────────────────────────────────────────┤ <── PHYSICS_BOOT_STATE |
| 442 | │ Ingress Descriptor, Entry & Trap Record │ [2 KiB] [0x40208800, 0x40209000) |
| 443 | 0x4020_9000 ├──────────────────────────────────────────┤ <── PHYSICS_CAPABILITY_TABLE |
| 444 | │ Capability Table (32 x 128B records) │ [4 KiB] [0x40209000, 0x4020A000) |
| 445 | 0x4020_A000 ├──────────────────────────────────────────┤ <── PHYSICS_RECEIPT_LEDGER |
| 446 | │ Receipt Ledger (32 x 192B receipts) │ [8 KiB] [0x4020A000, 0x4020C000) |
| 447 | 0x4020_C000 ├──────────────────────────────────────────┤ <── PHYSICS_REPLAY_CACHE |
| 448 | │ Replay Cache (32 x 64B records) │ [4 KiB] [0x4020C000, 0x4020D000) |
| 449 | 0x4020_D000 ├──────────────────────────────────────────┤ <── PHYSICS_STATIC_DATA |
| 450 | │ Frame Bitmap & Static Allocator Tables │ [12 KiB] [0x4020D000, 0x40210000) |
| 451 | 0x4021_0000 ├──────────────────────────────────────────┤ <── FREE_FRAME_BASE |
| 452 | │ Bounded Free DRAM Frames (Frame Auth) │ [125.9375 MiB = 32,240 frames] |
| 453 | 0x4800_0000 └──────────────────────────────────────────┘ <── DRAM_END |
| 454 | ``` |
| 455 | |
| 456 | Formal Disjointness Invariant: |
| 457 | $$\forall \mathcal{R}_i, \mathcal{R}_j \in \{\text{IMAGE}, \text{VBAR}, \text{STACK}, \text{BOOT\_STATE}, \text{CAP\_TABLE}, \text{RECEIPTS}, \text{REPLAY}, \text{STATIC\_DATA}, \text{FREE\_DRAM}\}: \quad i \neq j \implies \mathcal{R}_i \cap \mathcal{R}_j = \emptyset$$ |
| 458 | |
| 459 | --- |
| 460 | |
| 461 | ## 15. Dynamic Verification Scenario (End-to-End Authority Proof) |
| 462 | |
| 463 | The core dynamic proof for Milestone 3 executes the following sequence: |
| 464 | |
| 465 | ```text |
| 466 | CAP_ROOT (Slot 0, Gen 1) |
| 467 | │ |
| 468 | ├─► Derive Capability A (Slot 1, Gen 1) |
| 469 | │ Principal: 2 |
| 470 | │ Resource: RESOURCE_MEMORY_FRAME |
| 471 | │ Allowed Ops: OP_FRAME_GRANT |
| 472 | │ Bounds: Region R [0x40210000, 0x40220000) (64 KiB = 16 frames) |
| 473 | │ │ |
| 474 | │ ├─► Submit Intent 1 (Request ID 100, Cap A, OP_FRAME_GRANT, Target within R) |
| 475 | │ │ Broker: ADMITTED |
| 476 | │ │ Execution: Frame granted (0x40210000), bitmap updated |
| 477 | │ │ Receipt 1 emitted (decision = ADMITTED, prev_digest = 0) |
| 478 | │ │ |
| 479 | │ ├─► Derive Capability B (Slot 2, Gen 1) from Cap A |
| 480 | │ │ Principal: 3 |
| 481 | │ │ Resource: RESOURCE_MEMORY_FRAME |
| 482 | │ │ Allowed Ops: OP_FRAME_GRANT |
| 483 | │ │ Bounds: Region S [0x40210000, 0x40218000) (32 KiB, strict subset of R) |
| 484 | │ │ │ |
| 485 | │ │ ├─► Submit Intent 2 (Request ID 101, Cap B, Target 0x40219000, OUTSIDE S) |
| 486 | │ │ │ Broker: REJECTED_BOUNDS |
| 487 | │ │ │ Execution: ZERO physical effect, no bitmap change |
| 488 | │ │ │ Receipt 2 emitted (decision = REJECTED_BOUNDS, binds Receipt 1 digest) |
| 489 | │ │ |
| 490 | │ └─► Revoke Capability A (Slot 1) |
| 491 | │ Record 1 marked REVOKED |
| 492 | │ │ |
| 493 | │ ├─► Submit Intent 3 (Request ID 102, Cap A) -> REJECTED_REVOKED |
| 494 | │ ├─► Submit Intent 4 (Request ID 103, Cap B) -> REJECTED_REVOKED (descendant failure) |
| 495 | │ └─► Receipts 3 and 4 emitted in chain; zero physical effects |
| 496 | ``` |
| 497 | |
| 498 | --- |
| 499 | |
| 500 | ## 16. Adversarial Qualification Matrix |
| 501 | |
| 502 | Every adversarial case must prove: **No unauthorized physical effect occurred** via direct state inspection (memory dump verification), not UART text alone. |
| 503 | |
| 504 | | Adversarial Case | Description | Expected Decision | State Verification Proof | |
| 505 | | :--- | :--- | :--- | :--- | |
| 506 | | `FORGED_CAP_SLOT` | Present unallocated slot (e.g. slot 15) | `REJECTED_UNKNOWN_CAP` | No frame allocated; UART unchanged | |
| 507 | | `OUT_OF_RANGE_SLOT` | Present slot $\ge 32$ | `REJECTED_UNKNOWN_CAP` | No frame allocated; ledger bounds intact | |
| 508 | | `STALE_GENERATION` | Present valid slot with old generation | `REJECTED_STALE_GENERATION` | Bitmap untouched; no frame granted | |
| 509 | | `REVOKED_CAP` | Exercise directly revoked capability | `REJECTED_REVOKED` | Bitmap untouched | |
| 510 | | `DESCENDANT_REVOCATION` | Exercise child after parent revoked | `REJECTED_REVOKED` | Bitmap untouched | |
| 511 | | `WRONG_PRINCIPAL` | Present cap with mismatching principal ID | `REJECTED_WRONG_PRINCIPAL` | Zero effect | |
| 512 | | `FORBIDDEN_OP` | Request `FRAME_RELEASE` on grant-only cap | `REJECTED_OPERATION` | Bitmap untouched | |
| 513 | | `WRONG_RESOURCE` | Request `CONSOLE_WRITE` on memory cap | `REJECTED_RESOURCE` | UART MMIO untouched | |
| 514 | | `RIGHTS_WIDENING` | Attempt to derive ops not in parent | Attenuation Error | Child slot unallocated | |
| 515 | | `BOUNDS_WIDENING` | Attempt to derive bounds outside parent | Attenuation Error | Child slot unallocated | |
| 516 | | `LIFETIME_WIDENING` | Attempt to derive longer lifetime than parent | Attenuation Error | Child slot unallocated | |
| 517 | | `BOUNDS_OVERFLOW` | Child base + size wraps 64-bit integer | Attenuation Error | Child slot unallocated | |
| 518 | | `TARGET_OVERFLOW` | Intent target_base + size wraps 64-bit | `REJECTED_BOUNDS` | Bitmap untouched | |
| 519 | | `OUT_OF_BOUNDS_TARGET`| Target outside capability bound | `REJECTED_BOUNDS` | Bitmap untouched | |
| 520 | | `ROOT_EXPORT_ATTEMPT` | External principal attempts to exercise slot 0 | `REJECTED_WRONG_PRINCIPAL` | Root remains private | |
| 521 | | `REUSED_SLOT_OLD_GEN` | Slot reallocated; caller presents old handle | `REJECTED_STALE_GENERATION` | Zero effect | |
| 522 | | `REPLAY_IDENTICAL` | Duplicate request ID with identical intent | Idempotent Return | Frame returned; allocator cursor NOT bumped | |
| 523 | | `REPLAY_CONFLICT` | Duplicate request ID with altered intent | `REJECTED_REPLAY_CONFLICT` | Zero effect; rejection receipt recorded | |
| 524 | | `MALFORMED_VERSION` | Version != 1 in EffectIntent | `REJECTED_STRUCTURAL` | Zero effect | |
| 525 | | `TRUNCATED_INTENT` | Length < 64 in EffectIntent | `REJECTED_STRUCTURAL` | Zero effect | |
| 526 | | `OVERSIZED_INTENT` | Length > 64 in EffectIntent | `REJECTED_STRUCTURAL` | Zero effect | |
| 527 | | `RECEIPT_EXHAUSTION` | Intent submitted when 32 receipts committed | `REJECTED_EXHAUSTED` | Admission halted fail-closed; zero effect | |
| 528 | |
| 529 | --- |
| 530 | |
| 531 | ## 17. Milestone 3 Qualification Gates |
| 532 | |
| 533 | ```text |
| 534 | QUALIFICATION SUITE: MILESTONE 3 (PHYSICS_EFFECTS) |
| 535 | ├── Seam 1: Capability & Ledger Static Proofs |
| 536 | │ ├── [PASS] PHYSICS_CAP_LEDGER_PASS (Fixed-width 128B records, 32 slots in 4 KiB) |
| 537 | │ ├── [PASS] PHYSICS_CAP_ROOT_PRIVATE_PASS (Slot 0 private to Physics, non-exportable) |
| 538 | │ ├── [PASS] PHYSICS_CAP_ATTENUATION_PASS (Monotonic narrowing over rights/bounds/lifetime) |
| 539 | │ ├── [PASS] PHYSICS_CAP_NO_AMBIENT_AUTHORITY_PASS (Zero effect without explicit capability) |
| 540 | │ ├── [PASS] PHYSICS_CAP_GENERATION_PASS (Generation bumped on slot reuse; wrap fail-closed) |
| 541 | │ ├── [PASS] PHYSICS_CAP_REVOCATION_PASS (Target capability immediately unusable) |
| 542 | │ └── [PASS] PHYSICS_CAP_DESCENDANT_REVOCATION_PASS (Ancestor chain check fails all descendants) |
| 543 | │ |
| 544 | ├── Seam 2: Effect Broker & Replay Execution |
| 545 | │ ├── [PASS] PHYSICS_EFFECT_ADMISSION_PASS (Full 10-stage admission pipeline verification) |
| 546 | │ ├── [PASS] PHYSICS_EFFECT_BOUNDS_PASS (Strict containment, checked math, overflow refused) |
| 547 | │ ├── [PASS] PHYSICS_EFFECT_FORGED_CAP_REFUSAL_PASS (Unknown slot refused with zero effect) |
| 548 | │ ├── [PASS] PHYSICS_EFFECT_STALE_CAP_REFUSAL_PASS (Stale generation refused with zero effect) |
| 549 | │ ├── [PASS] PHYSICS_EFFECT_REVOKED_CAP_REFUSAL_PASS (Revoked cap refused with zero effect) |
| 550 | │ ├── [PASS] PHYSICS_EFFECT_WRONG_PRINCIPAL_REFUSAL_PASS (Principal mismatch refused) |
| 551 | │ ├── [PASS] PHYSICS_EFFECT_REPLAY_PASS (Idempotent replay without redundant physical mutation) |
| 552 | │ └── [PASS] PHYSICS_EFFECT_REPLAY_CONFLICT_PASS (Duplicate ID + different intent refused) |
| 553 | │ |
| 554 | └── Seam 3: Receipt Evidence & Full System Emulation |
| 555 | ├── [PASS] PHYSICS_RECEIPT_IDENTITY_PASS (Deterministic 192B receipt with SHA-256 seal) |
| 556 | ├── [PASS] PHYSICS_RECEIPT_CHAIN_PASS (Append-only hash chain binds previous digest) |
| 557 | ├── [PASS] PHYSICS_RECEIPT_EXHAUSTION_PASS (Full ledger halts admission fail-closed) |
| 558 | └── [PASS] PHYSICS_EFFECTS_QEMU_PASS (Clean Atlas -> Physics M3 end-to-end boot and test run) |
| 559 | ``` |
| 560 | |
| 561 | --- |
| 562 | |
| 563 | ## 18. Qualification Receipt Requirements |
| 564 | |
| 565 | The Milestone 3 qualification receipt (`m3_qualification_receipt.json`) must deterministically bind: |
| 566 | - `physics.bin` SHA-256 digest |
| 567 | - `machine_contract.json` (M3 contract) SHA-256 digest |
| 568 | - `docs/milestone-3-spec.md` SHA-256 digest |
| 569 | - Capability implementation source SHA-256 digest |
| 570 | - Effect broker implementation source SHA-256 digest |
| 571 | - Receipt implementation source SHA-256 digest |
| 572 | - Static audit runner digest |
| 573 | - Runtime harness runner digest |
| 574 | - Atlas handoff artifact digest |
| 575 | - Git commit hash |
| 576 | - QEMU binary version and invocation flags |
| 577 | - Exact gate pass/fail results (19/19 passing) |
| 578 | - Anti-bloat byte accounting breakdown |
| 579 | |
| 580 | Milestone 3 is complete **only when** all 19 qualification gates pass under independent state inspection and the signed qualification receipt is committed. |