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 / plans / fabric / F5_0_FABRIC_INTERFACE.md
| 1 | # Fabric interface F5-0: local loopback, typed records |
| 2 | |
| 3 | **NOT A MASTER PLAN.** This is a finite workstream document for the first |
| 4 | Fabric slice (CURRENT_EXECUTION_PLAN.md §F5, "interface design allowed now"). |
| 5 | `CURRENT_EXECUTION_PLAN.md` owns sequencing and `doctrine/ROADMAP.md` owns |
| 6 | milestone status. Nothing in this document closes F5 or any milestone. |
| 7 | |
| 8 | Status: implemented and tested host-only in omega `src/fabric/` (see §8). |
| 9 | aienos ADR 0010 (Fabric machine identity and capability advertisement) is |
| 10 | still **Proposed**; its preconditions (M6 networking, signature scheme, |
| 11 | operator approval) are not met. F5-0 is a host-side model of the data |
| 12 | structures and rules, which ADR 0010 §12 permits, and ships in no trusted base. |
| 13 | |
| 14 | ## 1. What F5-0 is |
| 15 | |
| 16 | Membership, capability advertisement, leases and loss detection between |
| 17 | machines, as typed records keyed by the canonical `AienMachineId` |
| 18 | (omega#113), carried over an **in-process loopback transport**. It feeds the |
| 19 | canonical Capability Graph (`rx_capq`, omega#115) through its public header |
| 20 | only, and answers J-Space placement (`JsHome`, omega#116) for live members. |
| 21 | |
| 22 | Out of scope: real networking, placement, topology/latency measurement, |
| 23 | failure recovery beyond withdrawal, remote J-Space, load telemetry, any |
| 24 | change to `src/runtime/`. |
| 25 | |
| 26 | ## 2. Ownership |
| 27 | |
| 28 | | Thing | Owner | F5-0 touches it how | |
| 29 | |---|---|---| |
| 30 | | Roster (who may be a member) | AEGIS / owner-key boundary (caller) | reads only; no call adds to it | |
| 31 | | Membership view (per peer) | the receiving node's `FabNode` | sole writer: `fab_receive`, `fab_tick` | |
| 32 | | Capability entries | `rx_capq` (canonical Capability Graph) | `cq_wire_apply`, `cq_machine_advertise_id`, `cq_withdraw` | |
| 33 | | Authority | World authority view (`CqHeld`) | never; `fabric.o` may not reference authority or World symbols (build check) | |
| 34 | | Machine identity | `aien_machine_id.h` | records carry the 44-byte `AienMachineId`, never a local index | |
| 35 | |
| 36 | ## 3. Message format (version 1) |
| 37 | |
| 38 | Fixed header 120 bytes + body + 32-byte tag; integers little-endian. |
| 39 | |
| 40 | | off | len | field | |
| 41 | |---|---|---| |
| 42 | | 0 | 4 | magic `AFAB` | |
| 43 | | 4 | 1 | version 0x01 | |
| 44 | | 5 | 1 | kind: JOIN 1, RENEW 2, ADVERTISE 3, LEAVE 4 | |
| 45 | | 6 | 2 | body_len (must equal the kind's size) | |
| 46 | | 8 | 44 | sender `AienMachineId` record | |
| 47 | | 52 | 44 | dest `AienMachineId` record | |
| 48 | | 96 | 8 | generation (sender's membership generation, >= 1) | |
| 49 | | 104 | 8 | seq (within the generation, >= 1, rising) | |
| 50 | | 112 | 8 | sent_us (informational) | |
| 51 | | 120 | n | body | |
| 52 | | 120+n | 32 | tag over bytes 0..120+n-1 | |
| 53 | |
| 54 | Bodies: JOIN = ontology digest (`cq_ontology_digest`, 32) + requested lease |
| 55 | (u64 us); RENEW = requested lease; ADVERTISE = one 188-byte `rx_capq` wire |
| 56 | record whose machine must be the sender; LEAVE = empty. The wire record may |
| 57 | be any `rx_capq` kind (ADVERTISE 1, AVAILABILITY 2, WITHDRAW 3): a machine |
| 58 | changes or withdraws only its own entries. |
| 59 | |
| 60 | ## 4. Receive rules (first failure is the verdict; nothing changes, except |
| 61 | that an authenticated message of the held generation that passed rule 6 |
| 62 | consumes its seq, so a refused message never succeeds on replay) |
| 63 | |
| 64 | 1. form -> `FAB_E_FORMAT` |
| 65 | 2. dest is not me, or sender is me -> `FAB_E_MISMATCH` |
| 66 | 3. sender not on the roster -> `FAB_E_NOT_ENROLLED` |
| 67 | 4. tag fails -> `FAB_E_AUTH` (forged identity, altered bytes) |
| 68 | 5. generation below held -> `FAB_E_STALE_GEN` |
| 69 | 6. same generation, seq not above last -> `FAB_E_REPLAY` |
| 70 | 7. JOIN whose generation is not above held -> `FAB_E_STALE_GEN` |
| 71 | 8. non-JOIN from a non-member or another generation -> `FAB_E_NOT_MEMBER` |
| 72 | 9. non-JOIN after the lease ended -> `FAB_E_LEASE_EXPIRED` (rejoin with a higher generation) |
| 73 | 10. JOIN with a different operation catalog -> `FAB_E_ONTOLOGY` |
| 74 | 11. ADVERTISE naming another machine -> `FAB_E_MISMATCH` (nobody speaks for a peer) |
| 75 | 12. ADVERTISE the Capability Graph refuses -> `FAB_E_CAPQ` |
| 76 | |
| 77 | The node applies the clock (`fab_tick`) before every receive, so loss is a |
| 78 | function of time only and a recorded run replays bit for bit. |
| 79 | |
| 80 | ## 5. Leases and loss |
| 81 | |
| 82 | The receiver grants `min(requested, max_lease)` from its own clock and gives |
| 83 | the end to `cq_machine_advertise_id`. At `now >= lease end` the member is |
| 84 | LOST and every entry it advertised is withdrawn from the receiver's graph. |
| 85 | Loss is the receiver's view only: the lost machine's identity and its own |
| 86 | local records are untouched (ADR 0010 invariant 5, partition sovereignty). |
| 87 | Capability entry generations are `membership_generation << 32 | revision`, |
| 88 | so a rejoin always outranks older records. |
| 89 | |
| 90 | ## 6. Interfaces other lanes consume |
| 91 | |
| 92 | **COMPOSITION-2 (Lane 3, runtime integration).** `fabric.h`: |
| 93 | `fab_node_init(FabNode*, const FabConfig*)` with a canonical `CqCatalog`; |
| 94 | `fab_poll` / `fab_receive` (inbound), `fab_tick` (clock), `fab_join`, |
| 95 | `fab_renew`, `fab_advertise(node, CqKey own, CQ_WIRE_*)`, `fab_leave`; |
| 96 | views `fab_member`, `fab_member_live`, `fab_home(node, AienMachineId, now, |
| 97 | JsHome*)` (LOCAL for self, REMOTE_OWNED for a live member, refused |
| 98 | otherwise); `fab_state_digest`. Rebuild of the capq index after an |
| 99 | ingested record is done by the Fabric. |
| 100 | |
| 101 | **Aienux M6 transport (Lane 5).** Two vtables, nothing else: |
| 102 | `FabTransport { send(from, to, bytes), recv(self, buf) }` (untrusted; the |
| 103 | Fabric authenticates every message itself) and `FabAuth { sign(bytes) -> |
| 104 | tag[32], verify(claimed AienMachineId, bytes, tag) }`. The real transport |
| 105 | must also put each send through AEGIS as an outbound effect (ADR 0010 §8); |
| 106 | F5-0 has no such gate. |
| 107 | |
| 108 | ## 7. Known gaps (recorded, not hidden) |
| 109 | |
| 110 | - The loopback authenticator is HMAC-SHA256 with one symmetric key per |
| 111 | machine. A verifier holding that key could sign with it. It stands in for |
| 112 | the TRUST-1 owner-key signature, which must replace it before any real use. |
| 113 | - Advertisement is sent to every roster peer (provisioned-trust set), not |
| 114 | pull-or-respond as ADR 0010 §7 states. Revisit when the transport exists. |
| 115 | - No AEGIS effect evaluation on send (ADR 0010 §8); belongs to the real |
| 116 | transport path. |
| 117 | - No load telemetry class, no Machine Capsule derivation (ADR 0010 §5, §9). |
| 118 | - The held generation and seq live in memory only: a receiver restart |
| 119 | forgets them, and a refused new-generation JOIN is not remembered. |
| 120 | - Not in omega `all`/`test` or the R13 living-system build until |
| 121 | COMPOSITION-2 integrates it. |
| 122 | |
| 123 | ## 8. Evidence |
| 124 | |
| 125 | Gate `F5_0_FABRIC_LOOPBACK`: three enrolled machines join, advertise (one |
| 126 | with two capabilities), renew; one goes silent, its lease ends, both peers |
| 127 | mark it LOST and its capability entries are withdrawn; it rejoins under a |
| 128 | higher generation. Negatives refused: expired lease, stale generation, |
| 129 | forged identity (wrong key, altered bytes, unenrolled sender), replayed |
| 130 | advertisement, machine mismatch (relayed record, misdelivery), after-leave. |
| 131 | Routing never mints authority: every Fabric candidate returns not held and |
| 132 | `require_held` filters all of them. The scenario runs twice; transcripts and |
| 133 | state digests must match. |
| 134 | |
| 135 | Command: `make test-fabric` in omega (receipt: `make fabric-receipt`). |
| 136 | Result: PASS. omega PR #123, merge a18ec6b (tested commit 0fc309c, re-run |
| 137 | after merging main 5c403f0). `checks 318 (scenario 160 per run), failures 0`, |
| 138 | ASan/UBSan PASS, purity PASS. Receipt: |
| 139 | `evidence/F5-0/e419a00b54d52b7307cada39d29e501d8a776a100471e0c2a2c41dfd84753858.json`. |
| 140 | Codex review: 6 passes, all findings fixed or answered in the PR body. |
| 141 | Scope: host-only loopback with an HMAC stand-in; no network, no TRUST-1 |
| 142 | signature, no hardware qualification. |