jonnify·bcs /bcs/ideas/identity-contract/the-minting-law-and-the-canon

B1.2 · dive 4 of 4 — the minting law · the gates · the canon

The law that records its own defect.

The minting law exists because an unfaithful port once folded node bits into the counter, and the contract chose to encode the lesson rather than merely fix the port. The counter state is timestamp and sequence only; a drained sequence borrows from the node's own next millisecond, never from a neighbor node's space.

The architectural reading: uniqueness is per-node arithmetic plus fleet-wide node-id assignment, with zero coordination at mint time — the property Twitter's design bought and this contract makes exact.

The counter, stepped by hand — the normative algorithm of content/contract.md §7, replayed by a pure function. The start state sits in the committed reference millisecond (ts 65459497641 = 1769526697641 − epoch), sequence at 4094.
timestamp · 41 bits ms since epoch 1704067200000 seq · 12 bits 4096 per ms, then borrow the counter · state = (ts << 12) | seq — MUST NOT embed the node bits node · 10 bits outside the counter composed only at the end: (ts << 22) | (node << 12) | seq
counter · state = ts 65459497641 · seq 4094. Each mint computes state' = max(now_state, state + 1); two mints from here the sequence drains, and the carry runs into the timestamp field — never into a neighbor node's space.
§1

The minting law, frozen

content/contract.md §7
content/contract.md §7 · minting, normativefrozen
The minter’s mutable state MUST be the pair timestamp ++ sequence — concretely
state = (ts << 12) | seq — and MUST NOT embed the node bits.

Burst borrow: when more than 4,096 ids are minted in one millisecond, state + 1 carries
from the sequence field into the timestamp field — the node borrows ids from its own
future milliseconds. Because node bits are outside the counter, the borrow can never
reassign an id into another node’s space.

Clock regression: when the wall clock moves backward, now_state < state and minting
continues from state + 1; ids never repeat and never decrease.

A state layout with node bits inside the counter exhibits exactly the cross-node failure past sequence exhaustion, and is non-conformant. The clause exists because a port drifted; writing the law into normative text turned one bug into a permanent test surface for every future port.

§2

The gate taxonomy, run by hand

content/contract.md §4, §8, §9 · content/vectors.json

Length, namespace, charset, range — four refusals a gate may speak, so that a 400 can say why without leaking what. The five inputs below are the committed vectors; a pure function replays the gates in the contract's evaluation order and names the refusal in each of its committed spellings — the gate name, the C status, and the BEAM's coarse :invalid.

gate · Select an input. Evaluation order is normative: length, then namespace, then charset, then range — with the range gate a byte-order comparison against MAX_PAYLOAD = "AzL8n0Y58m7", never native overflow.
content/contract.md §9 · the reject vectorsfrozen
reject "USRzzzzzzzzzzz"                  → range
reject "usr0KHTOWnGLuC"                  → namespace
reject "USR0KHTOWnGLu"                   → length
reject "USR0KHTOWnGL!C"                  → charset

One runtime speaks the vocabulary coarsely: the BEAM's parser reports :invalid without subclassification — the Chapter 1.1 decision that refused a second parser. If the taxonomy ever sharpens there, it sharpens in BrandedId once.

§3

The canon

content/contract.md §10–§11

One Rust source, one C reference, one vector file, and a conformance suite per runtime — membership in the fleet is passing the suite, not reimplementing carefully. "Which language" becomes a deployment detail.

content/contract.md §10 · the conformant suitesfrozen
runtimes/elixir/verify.exs           pure and native paths, asserted against each other at boot by self_check!/0
contract/branded-id-rs               the crate suite — make -C contract test runs a one-million-id roundtrip
runtimes/node/bench.ts               + wasm_bench.ts
runtimes/go/brandedid                tests
runtimes/postgres/branded_sql.sql    + the extension’s reject and vector blocks

Any behavioral change arrives spec-first: a version bump in the contract, in vectors.json, and in the crate; new or amended vectors; a same-change update to every conformant suite — in that order. A runtime may lag the canon only while its boot-time self-check still passes the shipped vectors; the moment it cannot, it is out of contract and fails loudly rather than serve.

§4

What it retires

content/bcs1.2.md

The dialect — the translation layers that grow at every polyglot boundary. Identities can be the only thing that crosses because they mean the same thing on every side; this is the property the law's second clause quietly spends. The minting law guards it from beneath: the same fourteen bytes never name two things, on any node, in any millisecond, drained or not.

§5

References

sources · related

Sources

Related