B2.3 · dive 3 of 3
Relations are systems.
A relation is not a field on either entity. It is its own owning process — a row keyed by the pair of branded ids, both ends gated, indexed both ways.
The idea
echo_data · bcs/edge_store.exThe component-system tradition kept a relation as a list of ids embedded in an entity — the fat struct returning by another door. In BCS a relation is a system of its own. EchoData.Bcs.EdgeStore is one owning process for one kind of edge; portfolio holds asset is a row keyed by the tuple of the two branded ids, carrying its own properties, embedded in neither endpoint.
The relation has a type, and the type is enforced at its boundary. The store is configured with a relation and the namespaces it joins; the subject and object ids are gated on the way in, so a mismatched end is refused before the edge is written. A relation can only be drawn between the kinds it is declared to hold, and the wrong-kind edge is a checked error.
An edge store keeps two private :ordered_set indexes, forward and reverse. A subject’s edges are a key-range read on the forward index; an object’s back-references are a key-range read on the reverse one; a delete clears both directions together. The relation is readable and countable from either side, owns itself, and is referenced by id from the entities it joins — never embedded in them.
The three dives are in the module: B2.5 · Relations Are Systems.
The doors
the sibling coursesEchoMQ — the protocol, in depth
The bus B3 narrates, taught rung by rung: the keyspace, the Lua inventory, and the 3.0 Stream Tier — XADD, XREADGROUP, XACK — with conformance on Valkey.
Redis Patterns Applied
The substrate patterns under the bus: sorted sets, atomic Lua moves, locks, and streams — the judgement layer.
/echo-persistenceEcho Persistence — the durable floor
Beneath the volatile tiers: the Graft page engine built twice, the commit-LSN loop, and the stream archive on Tigris. Where Part I says state lives somewhere, this says where it lives durably.
References
sources · relatedSources
- Leonard — Postmortem: Thief: The Dark Projectrelations between two objects as a first-class table
- Erlang/OTP — the ets modulethe two ordered_set indexes the edge store keeps
- Hoare — Record Handling (ALGOL Bulletin 21, 1965)the typed reference the gate enforces on each end
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus