jonnify·bcs /bcs/bus/fence-and-keyspace/the-key-grammar

B3.1 · dive 1 — the key grammar

Keys are grammar, scripts are law.

F1 asserts the part's map shape by shape: per-queue keys are emq:{q}:<type>, job rows compose with the identity canon, and the braced base is reserved for cross-queue facts. F2 proves the job position refuses before the wire exists — and the division of labor is stated here so no later chapter blurs it.

Source: content/bcs3.1.md, quoting bcs_rung_3_1_check.out; the grammar is committed at runtimes/elixir/lib/echo_mq/keyspace.ex.

The part's map — the four committed shapes. The keys F1 asserts, drawn left to right as the transcript prints them. Select a shape to read its class and its byte arithmetic.
emq:{orders}:pending a per-queue fact tag + type emq:{orders}:job:ORD0NgWEfAEJfs the job row 17 bytes of grammar + 14 of identity {emq}:version the reserve's tenant the fence {emq}:locks the reserve deployment-scoped
readout · Select a shape. Four keys, two classes: per-queue facts under emq:{q}: and deployment-scoped facts under the braced reserve — the committed line closes 17 bytes before the payload.
§1

The transcript

bcs_rung_3_1_check.out · verbatim · this dive reads F1 and F2
content/echo_data/runtimes/elixir/bcs_rung_3_1_check.out · verbatimfrozen
F1 map ok -- the part's map: emq:{orders}:pending | emq:{orders}:job:ORD0NgWEfAEJfs | {emq}:version | {emq}:locks -- 17 bytes before the payload
F2 gate ok -- the job position is gated: a fourteen-byte decimal and a fourteen-byte slug both raise before any wire is touched; kind policy waits for the enqueue script
F3 fence ok -- the fence holds on a live wire: GET {emq}:version answers echomq:2.0.0 through the fenced connector itself
F4 binary ok -- binary payloads with embedded CRLF and NUL survive 500/500 round trips through job keys in two pipelines
F5 slot ok -- co-location law: pending, active, meta, and the job row of {orders} all answer slot 105; {fills} answers 4165 -- multi-key scripts stay legal on the clustered day (vector 12739 holds)
PASS 5/5
§2

F1 — the map

content/bcs3.1.md · What · How

Two design facts live in F1's line. The branded payload is the long part of a job key by construction — seventeen bytes of grammar, fourteen of identity — which is Chapter 1.3's economy carried onto the bus. And the version fence lives under {emq}: precisely because it is the one fact that is about the deployment rather than about any queue: the version fence is the canonical tenant and loneliness there is a feature.

The whole vocabulary is small enough to quote its heart. Grammar above, gate below, and nothing else — policy lives in scripts:

def queue_key(queue, type) when is_binary(queue) and is_binary(type),
  do: IO.iodata_to_binary(["emq:{", queue, "}:", type])

def job_key(queue, branded) do
  if EchoData.BrandedId.valid?(branded) do
    queue_key(queue, "job:") <> branded
  else
    raise ArgumentError, "job_key requires a valid branded id"
  end
end

The consumer side will speak the same grammar, and the shape ports in a breath, with the same gate in the same position:

func JobKey(queue, id string) (string, error) {
    if _, err := brandedid.Parse(id); err != nil {
        return "", err
    }
    return "emq:{" + queue + "}:job:" + id, nil
}

The full Go keyspace rides with the Go substrate follow-on; the law it must satisfy is already written here. The grammar stays closed: add a key type — never a key family. A new per-queue fact is a new <type> under the existing tag, and the {emq}: reserve admits only facts about the deployment itself. For operators, the grammar is also the inspection language — emq:{orders}:* scans one queue and nothing else.

§3

F2 — the gate at the job position

content/bcs3.1.md · What · Decisions

F2 proves the job position refuses before the wire exists: a fourteen-byte decimal and a fourteen-byte slug both raise before any wire is touched. The division of labor is stated here so no later chapter blurs it: the key function owns wellformedness — fourteen bytes that parse as an identity — while kind policy (which namespaces a queue admits) belongs to the enqueue script, because keys are grammar and scripts are law. B3.2 · Jobs Are Entities collects that obligation.

The key function raises on malformed identity and carries no kind policy; the enqueue script owns admission, where refusals can be typed replies instead of exceptions.

The gate, exercised. A pure model of job_key/2 over the rung's own candidates. Select a candidate for the job position; the readout names the verdict.
readout · Select a candidate. The model runs the committed gate's two clauses: a valid branded id composes the row key; anything else raises before any wire is touched.

Static verdicts — the committed id ORD0NgWEfAEJfs → the row key emq:{orders}:job:ORD0NgWEfAEJfs · a fourteen-byte decimal → ArgumentError · a fourteen-byte slug → ArgumentError · a kind question → not the key's question — kind policy belongs to the enqueue script.

§4

References

sources · related

Sources

Related