Add the chain package and its buckets: builds, rollouts and assignments with history 64 (issue 1089)

internal/chain holds typed Build, Rollout and Assignment and a Backend with no delete or purge, in memory and on the bus. The builds and rollouts buckets are asserted with history 64, no age and values up to just under a mebibyte; the assignments bucket gets the same, keeping its marker age because a stream cannot be made to disallow message ages. Migration 0104 makes the one-row chain_moved switch. The controller keeps no consolidated schema, so 0104 is the whole schema change. Nothing reads the buckets yet.
This commit is contained in:
2026-10-18 02:39:11 +02:00
parent 54070f5bc3
commit fc55785956
15 changed files with 1175 additions and 9 deletions
@@ -0,0 +1,16 @@
-- Builds, rollouts and assignments move to the bus (novox/hq ADR 0408 §8, design 47 milestone 5, issue 1089).
--
-- This migration makes the switch alone. The rows of build, build_request, release_plan, batched_merge, assignment and
-- pending_assignment are written into the chain's buckets by the serving controller at its start, holding the lease,
-- because a migration runs when the store is opened, before any connection to the bus. This row is the switch: while it
-- is absent nothing reads the buckets; once the move has counted every row against the keys it wrote, it is written, and
-- nothing reads the tables. One row at most; never written by a migration, so a delivery alone changes nothing. The
-- controller keeps no consolidated schema, so this migration is the whole of the change; the tables go by a later one.
create table chain_moved (
only_one boolean primary key default true check (only_one),
moved_at timestamptz not null default now(),
-- The counts the move read from the tables and wrote as keys, per kind, and the largest value it wrote: what a
-- reader of the move reads back.
counts jsonb not null,
largest jsonb not null
);