interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / docs / plans / fabric / F5_0_FABRIC_INTERFACE.md

142 lines · 7414 bytes Raw Blame History Rendered
1# Fabric interface F5-0: local loopback, typed records
2
3**NOT A MASTER PLAN.** This is a finite workstream document for the first
4Fabric slice (CURRENT_EXECUTION_PLAN.md §F5, "interface design allowed now").
5`CURRENT_EXECUTION_PLAN.md` owns sequencing and `doctrine/ROADMAP.md` owns
6milestone status. Nothing in this document closes F5 or any milestone.
7
8Status: implemented and tested host-only in omega `src/fabric/` (see §8).
9aienos ADR 0010 (Fabric machine identity and capability advertisement) is
10still **Proposed**; its preconditions (M6 networking, signature scheme,
11operator approval) are not met. F5-0 is a host-side model of the data
12structures and rules, which ADR 0010 §12 permits, and ships in no trusted base.
13
14## 1. What F5-0 is
15
16Membership, capability advertisement, leases and loss detection between
17machines, as typed records keyed by the canonical `AienMachineId`
18(omega#113), carried over an **in-process loopback transport**. It feeds the
19canonical Capability Graph (`rx_capq`, omega#115) through its public header
20only, and answers J-Space placement (`JsHome`, omega#116) for live members.
21
22Out of scope: real networking, placement, topology/latency measurement,
23failure recovery beyond withdrawal, remote J-Space, load telemetry, any
24change 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
38Fixed 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
54Bodies: JOIN = ontology digest (`cq_ontology_digest`, 32) + requested lease
55(u64 us); RENEW = requested lease; ADVERTISE = one 188-byte `rx_capq` wire
56record whose machine must be the sender; LEAVE = empty. The wire record may
57be any `rx_capq` kind (ADVERTISE 1, AVAILABILITY 2, WITHDRAW 3): a machine
58changes or withdraws only its own entries.
59
60## 4. Receive rules (first failure is the verdict; nothing changes, except
61that an authenticated message of the held generation that passed rule 6
62consumes its seq, so a refused message never succeeds on replay)
63
641. form -> `FAB_E_FORMAT`
652. dest is not me, or sender is me -> `FAB_E_MISMATCH`
663. sender not on the roster -> `FAB_E_NOT_ENROLLED`
674. tag fails -> `FAB_E_AUTH` (forged identity, altered bytes)
685. generation below held -> `FAB_E_STALE_GEN`
696. same generation, seq not above last -> `FAB_E_REPLAY`
707. JOIN whose generation is not above held -> `FAB_E_STALE_GEN`
718. non-JOIN from a non-member or another generation -> `FAB_E_NOT_MEMBER`
729. non-JOIN after the lease ended -> `FAB_E_LEASE_EXPIRED` (rejoin with a higher generation)
7310. JOIN with a different operation catalog -> `FAB_E_ONTOLOGY`
7411. ADVERTISE naming another machine -> `FAB_E_MISMATCH` (nobody speaks for a peer)
7512. ADVERTISE the Capability Graph refuses -> `FAB_E_CAPQ`
76
77The node applies the clock (`fab_tick`) before every receive, so loss is a
78function of time only and a recorded run replays bit for bit.
79
80## 5. Leases and loss
81
82The receiver grants `min(requested, max_lease)` from its own clock and gives
83the end to `cq_machine_advertise_id`. At `now >= lease end` the member is
84LOST and every entry it advertised is withdrawn from the receiver's graph.
85Loss is the receiver's view only: the lost machine's identity and its own
86local records are untouched (ADR 0010 invariant 5, partition sovereignty).
87Capability entry generations are `membership_generation << 32 | revision`,
88so 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`;
96views `fab_member`, `fab_member_live`, `fab_home(node, AienMachineId, now,
97JsHome*)` (LOCAL for self, REMOTE_OWNED for a live member, refused
98otherwise); `fab_state_digest`. Rebuild of the capq index after an
99ingested 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
103Fabric authenticates every message itself) and `FabAuth { sign(bytes) ->
104tag[32], verify(claimed AienMachineId, bytes, tag) }`. The real transport
105must also put each send through AEGIS as an outbound effect (ADR 0010 §8);
106F5-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
125Gate `F5_0_FABRIC_LOOPBACK`: three enrolled machines join, advertise (one
126with two capabilities), renew; one goes silent, its lease ends, both peers
127mark it LOST and its capability entries are withdrawn; it rejoins under a
128higher generation. Negatives refused: expired lease, stale generation,
129forged identity (wrong key, altered bytes, unenrolled sender), replayed
130advertisement, machine mismatch (relayed record, misdelivery), after-leave.
131Routing never mints authority: every Fabric candidate returns not held and
132`require_held` filters all of them. The scenario runs twice; transcripts and
133state digests must match.
134
135Command: `make test-fabric` in omega (receipt: `make fabric-receipt`).
136Result: PASS. omega PR #123, merge a18ec6b (tested commit 0fc309c, re-run
137after merging main 5c403f0). `checks 318 (scenario 160 per run), failures 0`,
138ASan/UBSan PASS, purity PASS. Receipt:
139`evidence/F5-0/e419a00b54d52b7307cada39d29e501d8a776a100471e0c2a2c41dfd84753858.json`.
140Codex review: 6 passes, all findings fixed or answered in the PR body.
141Scope: host-only loopback with an HMAC stand-in; no network, no TRUST-1
142signature, no hardware qualification.