jonnify·bcs /bcs/elixir-core/archetypes/archetypes-are-data

B2.4 · dive 1 — archetypes are data

A row, a reference, a map.

An archetype is data: an entity under the newly registered ARC namespace whose value is a property bundle, extending at most one parent. An instrument is a reference plus overrides. The composed view is a pure fold — bundles folded root-first, overrides applied last, right-most wins.

Source: content/bcs2.4.md, quoting bcs_rung_2_4_check.out; the resolver is committed at runtimes/elixir/lib/echo_data/bcs/archetypes.ex.

The chain, property by property. A1's working chain: the derivative base, the future archetype extending it, the ESZ6 instrument overriding tick. Select a property; the readout names every source that offers it and the right-most one that wins.
the derivative base margin: true · settlement: :t1 tick: 0.01 an ARC row · the root the future archetype settlement: :daily_mark multiplier: 50 an ARC row · :extends the base ESZ6, the instrument archetype: the future overrides: tick: 0.25 a reference plus overrides
readout · Select a property. The composed view matches A1's gated sentence — tick 0.25 from the instrument, settlement :daily_mark from the archetype, margin true from the base: three sources, one map, no ambiguity about who wins.
§1

The transcript

bcs_rung_2_4_check.out · verbatim · this dive reads boot and A1
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
§2

The model

content/bcs2.4.md · What

An archetype bundle lives in the :archetypes store under ARC; it may carry :extends naming one parent. An instrument row carries archetype: (the reference) and overrides: (the deltas). The composed view is compose(chain, overrides) — bundles folded root-first, overrides applied last, right-most wins — produced by a resolver that 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.

No behaviour modules, no protocol dispatch on kind, no hierarchy of code anywhere in the design. A1 builds the working chain — the derivative base (margin: true, settlement: :t1, tick: 0.01), a future extending it (settlement: :daily_mark, multiplier: 50), and the ESZ6 instrument overriding tick — and gates the exact view: tick 0.25 from the instrument, settlement :daily_mark from the archetype, margin true from the base.

§3

The fold, in Elixir and in Go

content/bcs2.4.md · How · lib/echo_data/bcs/archetypes.ex

The whole mechanism is four lines, and pure:

def compose(chain, overrides) when is_list(chain) and is_map(overrides) do
  chain
  |> Enum.reduce(%{}, &Map.merge(&2, &1))
  |> Map.merge(overrides)
  |> Map.delete(:extends)
end

The walk above it carries the seen-set and the depth cap; the store's own gate supplies a guard the resolver does not re-implement — an :extends pointing outside ARC meets the archetype store's namespace refusal before any bundle loads. The Go counterpart — the same fold, the same one-:extends law, over the owner's map:

func Compose(chain []map[string]any, over map[string]any) map[string]any {
    out := map[string]any{}
    for _, b := range chain {
        maps.Copy(out, b)
    }
    maps.Copy(out, over)
    delete(out, "extends")
    return out
}
The fold, stepped. The same pure fold run over A1's fixed chain, one merge at a time. Step through; the readout shows the accumulated map, so right-most-wins is visible as it happens.
readout · Select a step. The static walk: %{} → merge the base → merge the future archetype → merge the ESZ6 overrides → drop :extends — four properties out, matching A1's gated view.

The chain arrives root-first, so each merge lets the later bundle win; the overrides merge last and win over everything; :extends is bookkeeping, not a property, and the final Map.delete keeps it out of the view.

§4

The ARC registration as a governance act

content/bcs2.4.md · Decisions

Archetypes are entities. 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. The boot line carries it verbatim: boot: the registry grows by one -- ARC, archetype definitions as rows. A namespace registers when a kind needs identity and lifecycle of its own, and definitions qualified because they are edited, audited, and one day replayed.

Definitions live in the :archetypes property store today — the store family Property Stores on ETS (B2.2) built — and in the forest of The CHAMP Property Database (B2.3) the day history is asked for; same key, both homes.

§5

References

sources · related

Sources

Related