B2.1.4 · dive 4 of 6 · module B2.1
The application boots the contract.
EchoData.Application.start/2: seed the lock-free Snowflake, prove the branded-id contract against a committed vector, then root the tree. Thirteen lines, in that order.
The idea
echo_data · application.exThe OTP application is a system’s first breath, and EchoData.Application.start/2 does three things in order. It starts the lock-free Snowflake so ids can be minted; it runs the branded-id self-check, which proves the codec-and-hash contract before a single system exists; and only then does it root a one_for_one supervisor. The boot proves the contract or it refuses to start — thirteen lines, and the order is the point.
The self-check is the contract made executable. It mints, encodes, decodes, and hashes a known id and asserts the result against a committed vector — the same placement(USR0KHTOWnGLuC) = 234878118 the figures cite — and returns the codec mode, native or the pure-Elixir fallback, so the log records which path served. A node that cannot reproduce the vector never reaches its first message.
Codemojex starts the same way. Before a room can be supervised, the application has proven that every node mints and decodes branded ids identically; a room on one machine and a worker on another agree on what a player’s id means because the contract was checked at boot, not assumed. The application is where the law stops being a claim and becomes a running guarantee.
The source
echo_data · committed, verbatimecho_data/lib/echo_data/application.ex — complete, 13 lines
defmodule EchoData.Application do
@moduledoc false
use Application
require Logger
@impl true
def start(_type, _args) do
:ok = EchoData.Snowflake.start()
{:ok, mode} = EchoData.BrandedId.self_check!()
Logger.info("EchoData: contract self-check passed, codec=#{mode}")
Supervisor.start_link([], strategy: :one_for_one, name: EchoData.Supervisor)
end
endThe 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
- Erlang/OTP — the application behaviourthe start/2 callback that boots a system's contract before it serves
- King — Announcing Snowflake (2010)the lock-free, time-ordered id the codec wraps
- Erlang/OTP — the gen_server behavioura system as a process: one mailbox, one private state, a message-only surface
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus