broker: the slug registry forgets every claim on restart — a restart can hand a live community's name to someone else #278

Closed
opened 2026-08-05 23:09:45 +00:00 by ben · 1 comment
Owner

broker/internal/broker/broker.go:96 — NewRegistry returns reserved: map[string]bool{} and nothing in broker/ persists it. After a broker restart, claiming a slug a live community already owns answers available: true, and a subsequent /point upserts over that community's existing A, wildcard and _acme-challenge records on the product zone.

With the idss.nz cut-over in flight (ADR 0128) this is live-infrastructure-shaped: the broker restarting is routine, and the zone writer is deliberately an overwrite-by-id upsert.

Acceptance

  • Claimed slugs survive a broker restart (durable store in the broker's state dir, following the repo's file-ledger idiom; reservedSlugs stays the static fence it is today).
  • A claim for a persisted slug answers unavailable after restart; /point for a slug the registry does not hold is refused rather than upserting blind.
  • Tests cover claim → restart → claim (refused) and restart → point-unknown-slug (refused).

Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code).

`broker/internal/broker/broker.go:96` — `NewRegistry` returns `reserved: map[string]bool{}` and nothing in `broker/` persists it. After a broker restart, claiming a slug a live community already owns answers `available: true`, and a subsequent `/point` upserts over that community's existing A, wildcard and `_acme-challenge` records on the product zone. With the idss.nz cut-over in flight (ADR 0128) this is live-infrastructure-shaped: the broker restarting is routine, and the zone writer is deliberately an overwrite-by-id upsert. **Acceptance** - Claimed slugs survive a broker restart (durable store in the broker's state dir, following the repo's file-ledger idiom; `reservedSlugs` stays the static fence it is today). - A claim for a persisted slug answers unavailable after restart; `/point` for a slug the registry does not hold is refused rather than upserting blind. - Tests cover claim → restart → claim (refused) and restart → point-unknown-slug (refused). --- _Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code)._
Author
Owner

Fixed in c6079e6 (on origin/main).

The broker's reservation set is now durable, following the repo's single-writer file-ledger idiom re-homed into the broker's own Go module (it cannot import the helper's internal/jsonstore):

  • broker/internal/broker/store.go — a new ReservationStore (Memory + File backings): atomic temp+rename write, a versioned document, and a corrupt/unrecognised-version ledger refused loudly on load rather than read as empty (which would forget every live community's name).
  • broker.go — OpenRegistry seeds the reserved set from the store at boot; Claim/Release persist every mutation. A claim that cannot be recorded durably is refused (rolled back in memory too), never reported available (ADR 0100). reservedSlugs stays the static infra fence it was.
  • cmd/broker/main.go — wires a FileReservationStore from BROKER_STATE_DIR (warns loudly when unset), and refuses to boot on an unreadable ledger.

Acceptance covered by red-first tests in store_test.go: claim → restart → re-claim refused (memory and on-disk File stores); restart → point-unknown-slug refused with no blind write; release survives a restart; corrupt/future-version ledgers refused; a non-persistable claim refused. go test/go vet green (broker module); pre-push repo gate green.

Fixed in c6079e6 (on `origin/main`). The broker's reservation set is now durable, following the repo's single-writer file-ledger idiom re-homed into the broker's own Go module (it cannot import the helper's `internal/jsonstore`): - **`broker/internal/broker/store.go`** — a new `ReservationStore` (Memory + File backings): atomic temp+rename write, a versioned document, and a corrupt/unrecognised-version ledger **refused loudly on load** rather than read as empty (which would forget every live community's name). - **`broker.go`** — `OpenRegistry` seeds the reserved set from the store at boot; `Claim`/`Release` persist every mutation. A claim that cannot be recorded durably is refused (rolled back in memory too), never reported available (ADR 0100). `reservedSlugs` stays the static infra fence it was. - **`cmd/broker/main.go`** — wires a `FileReservationStore` from `BROKER_STATE_DIR` (warns loudly when unset), and refuses to boot on an unreadable ledger. Acceptance covered by red-first tests in `store_test.go`: claim → restart → re-claim **refused** (memory and on-disk File stores); restart → point-unknown-slug **refused** with no blind write; release survives a restart; corrupt/future-version ledgers refused; a non-persistable claim refused. `go test`/`go vet` green (broker module); pre-push repo gate green.
ben closed this issue 2026-08-06 03:36:52 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#278
No description provided.