jonnify·bcs /bcs/elixir-core/archetypes

B2.4 · Archetypes and Composition — manuscript chapter 2.4

An archetype is data.

The part preface promised the Looking Glass move on the BEAM; this chapter performs it. An archetype is an entity under a newly registered ARC namespace whose value is a property bundle, extending at most one parent — and an instrument is a reference plus overrides, composed into a view at read time by a pure fold. No behaviour modules, no protocol dispatch on kind, no hierarchy of code anywhere in the design.

The chapter is content/bcs2.4.md; the rung behind it is bcs_rung_2_4_check.exs, and its committed record closes PASS 5/5. Composition order, amplification, shape guards, ordinary rows, the read cost across three lanes — each gated on stage.

The five gates, mapped to the dives. Drawn in transcript order. Select a gate to read its verbatim line and the dive that teaches it.
A1 order dive 1 A2 amplify dive 2 A3 guard dive 3 A4 rows dive 3 A5 cost dive 3
readout · Select a gate to read its verbatim line and the dive that teaches it. Five gates over the archetype model; the full transcript is frozen in §2 below, the dives are mapped in §3.
§1

Composition over class inheritance

content/bcs2.4.md · Why

Instrument taxonomies are where class hierarchies go to grow teeth: equity, future, option, each sharing margin and settlement machinery, each diverging somewhere — and twenty years of inherited game-engine wisdom says the subclass tree ends in tears. West's component turn was the industry-scale retreat from exactly this shape, and the Gang of Four had stated the principle a decade earlier: favor composition over class inheritance, a judgment Gamma stood by — “I still think it's true even after ten years” — because the base-subclass coupling is implicit and brittle. BCS gives the principle its data-only form, so the trading desk's “all index futures now mark daily” is an edit to one entity, not a redeploy of a class.

ROW

The shared semantics are a row

An archetype bundle lives in the :archetypes store under ARC; it may carry :extends naming one parent — gated by A1 and A3.

REFERENCE

The kind is a reference

An instrument row carries archetype: — the reference — and answers a definition edit at next read, with no fan-out write — gated by A2.

MAP

The specialization is a map

overrides: carries the deltas; overrides carry facts, archetypes carry semantics — the review line the Decisions section states.

REGISTRY

The registry grows by one

ARC, archetype definitions, platform scope — recorded as a decision because registration is the governance act Chapter 1.2 said it is.

§2

The proof

content/bcs2.4.md · quoting bcs_rung_2_4_check.out

The full committed transcript, verbatim — boot, then A1 through A5:

content/echo_data/runtimes/elixir/bcs_rung_2_4_check.out · verbatimfrozen
boot: the registry grows by one -- ARC, archetype definitions as rows
A1 order ok -- composition order proven: tick 0.25 from the instrument, settlement :daily_mark from the archetype, margin true from the base
A2 amplify ok -- one definition edited, a thousand instruments follow: multiplier 100 at next read; an instrument row is 18 words, its composed view 14
A3 guard ok -- the diamond is unrepresentable (one :extends) and the cycle is refused: {:error, :cycle}; depth capped at 8: {:error, :depth}
A4 rows ok -- archetypes are rows: an AST name refused with {:error, :namespace}; ARC pages newest-first like any property
A5 cost ok -- read-time composition over a depth-2 chain: store-lane 5442 ns/op vs snapshot-lane 1048 ns/op; a bare row get is 2653 ns/op
PASS 5/5

The resolver lives at runtimes/elixir/lib/echo_data/bcs/archetypes.ex; it is pure by construction — it takes a fetch function, so the same walk runs against a store boundary or a snapshot, and the fetch-function seam doubles as the test seam. The third lane delivers the chapter's best sentence: the snapshot-lane resolve — the full composition, pure, over a defs snapshot — is cheaper than a single bare get through the boundary. Composition was never the cost; the boundary crossing was. In the Part II arc the module stands between The CHAMP Property Database (B2.3) and Relations Are Systems (B2.5).

§3

The dives

three lessons, fixed by the chapter spec
§4

References

sources · related

Sources

Related