jonnify·redis /redis-patterns/overview/redis-under-portal/reserved-tier

R0.2.3 · Valkey under the Exchange Platform — dive 3

The reserved tier.

The tier this module once placed in reserve is no longer a reservation. EchoMQ is shipped, owned-protocol code: echo/apps/echo_mq, the BCS 2.0 Valkey-native bus — born braced, born branded, born declared — and the convergence target of the EchoMQ program.

Grounding: docs/echo_mq/emq.roadmap.md (the program) · emq.design.md (the protocol canon) · content/bcs3.3.md (the claim script) · bcs3.1.md + bcsA.md (the slot figures) — every figure verbatim from a committed record.

The tier as it stands. Select a part to read its role in the program — the push source, the convergence target, the named consumer, the engine.
the Exchange Platform · the named consumer EchoMQ.Jobs → EchoMQ.Consumer → EchoMQ.Lanes echo/apps/echomq · v1 frozen at 1.3.0 — the push source absorbed EchoMQ · echo/apps/echo_mq the convergence target — born braced (emq:{q}:), born branded, born declared Valkey · the engine, external
readout · Select a part. One program, three movements: all EchoMQ code converges in echo/apps/echo_mq; the frozen v1 line is the push source it absorbs.

Static verdicts — the push source → echo/apps/echomq, frozen at 1.3.0, dissolves when the movements complete · the convergence target → echo/apps/echo_mq, version 2.0.0 · the consumer → the Exchange Platform (docs/exchange/) · the engine → Valkey, the only engine named.

§1

The tier, built

emq.roadmap.md

The earlier life of this page held a seat open: a multi-runtime layer the platform reserved for a bus to grow into. The program has since filled the seat with code. echo/apps/echo_mq is the bus — EchoMQ.*, lib-only, version 2.0.0 — re-derived from first principles by the Branded Component System and shipped as measured, rung-gated code: born braced (emq:{q}:), born branded (JOB ids gated at the key builder), born declared (every Lua key declared or grammar-derived).

The fork behind it was ruled to happen exactly once. The v1 line carried two structural flaws that rode its wire and could not be fixed under compatibility — operand keys built from an ARGV prefix inside script bodies, and an open keyspace with no total parse — so the line froze, and the new bus was born under the v2 laws instead of patched toward them. EchoMQ broke from that v1 line, now frozen at 1.3.0. That frozen line, echo/apps/echomq, is the program’s push source: its capability surface is absorbed over the program’s movements, and the app dissolves when the movements complete.

The tier also has a named tenant now. The Exchange Platform (docs/exchange/) is the program’s named consumer: its specification records settlement, notifications, end-of-day reporting, and reconciliation as EchoMQ.Jobs work drained by EchoMQ.Consumer and shaped by EchoMQ.Lanes.

§2

One atomic move, the real one

content/bcs3.3.md

The defining move of the bus is claiming the next job to work, and the script is committed — quoted verbatim:

content/bcs3.3.md · claim, the token mint · verbatimfrozen
local popped = redis.call('ZPOPMIN', KEYS[1])
if #popped == 0 then return {} end
local id = popped[1]
local jk = ARGV[1] .. id
local att = redis.call('HINCRBY', jk, 'attempts', 1)
redis.call('HSET', jk, 'state', 'active')
local t = redis.call('TIME')
local now = t[1] * 1000 + math.floor(t[2] / 1000)
redis.call('ZADD', KEYS[2], now + tonumber(ARGV[2]), id)
return {id, redis.call('HGET', jk, 'payload'), att}

One script, one claim: ZPOPMIN pops the lex-oldest pending id — score-zero means lex order is mint order — HINCRBY increments attempts, HSET marks the row active, and TIME stamps a lease on the server’s clock into the lease-scored active set. Atomic execution means the pop, the increment, and the lease land together or not at all. The quiet center is one integer doing two jobs: the attempts counter, incremented inside the claim, is the fencing token every other transition verifies — a right token retires the row; a stale token answers EMQSTALE.

The claim, stepped. Run the moves over a three-job queue; hover a structure to read its part. The lease figure is the committed 40 ms from the bcs3.3 crash drill.
emq:{q}:pending job·1 (lex-oldest) job·2 job·3 score-zero · lex = mint order claim emq:{q}:active (empty) scored by lease deadline the job row (hash) state: pending attempts: 0 payload: (cargo) attempts IS the token
readout · Run claim: ZPOPMIN pops the lex-oldest id, HINCRBY mints the token, the lease lands at t+40 ms on the server’s clock — one atomic step.

Static verdicts — claim → ZPOPMIN the lex-oldest, HINCRBY attempts to 1, lease at TIME+40 ms · complete with the right token → retires the row, nothing remains · complete with token 99 → EMQSTALE, the row survives · the committed round trip reads one job, two lives, one counter.

Notes on ValkeyThe clock inside the script is the server’s: TIME reads a frozen value for the script’s duration, and scripts replicate by effects — which is what makes a server-clock lease inside a write script sound, immune to client skew — valkey.io/topics/replication.

content/bcs3.3.md · the fence, performing · committed linesfrozen
complete with the right token retires the row -- nothing remains
EMQSTALE; the lease holder's work survives the zombie's complete
one job, two lives, one counter
§3

One queue, one slot, by grammar

content/bcs3.1.md F5 · bcsA

The claim script touches two keys — the pending set and the active set — plus the job row built from a declared prefix. What makes that multi-key move legal forever is the grammar: the hashtag is the queue name, so every key of one queue answers one cluster slot. The connector gate holds the same arithmetic client-side — slot 105 == 105 against 8507 for the payments queue, with the CRC16 specification vector answering 12739 (bcsA). Per-queue transition scripts are single-slot legal on the clustered day by grammar, not by review.

content/bcs3.1.md · F5, the co-location law · verbatimfrozen
pending, active, meta, and the job row of {orders} all answer slot 105; {fills} answers 4165
§4

The protocol is the contract

bcs3.2 · bcs3.3 · emq.roadmap.md

The reason one bus serves more than one runtime is not a port. It is that the protocol is the contract: the closed emq:{q}:<type> grammar plus the atomic Lua bundle. The same source string yields the same SHA1, and any client on any runtime that loads it speaks identical semantics — the same pop, the same token mint, the same lease arithmetic. A Go consumer is a loop around the same EVALSHA calls the Elixir reference makes (bcs3.3); the program roadmap names a Go sibling in its cross-runtime fleet, and a Node runtime is strictly proposed — not asserted.

the pattern

Reserve a seam for the bus, then fill it with a contract rather than a codebase: a closed grammar and a script bundle any conforming runtime can load.

its EchoMQ application

EchoMQ at echo/apps/echo_mq over Valkey — the convergence target the program extends rung by rung, with the Exchange Platform draining it.

The tier stopped being a reservation the day the bus shipped as owned code: one grammar, one bundle, one fence — and a program that absorbs the frozen line rung by rung.

§5

The doors

live routes · living status

This closes R0.2. The depth on the far side is taught by two courses — both doors are live routes.

§6

References

sources · related

Sources

Related in this course