broker: desec-zone-binding — record CRUD on the deSEC-hosted zone; KeySystemsZone retires (ADR 0118) #234

Closed
opened 2026-07-31 19:26:36 +00:00 by ben · 1 comment
Owner

Parent

Founding spec #11 (ADRs 0047/0048/0049) · ADR 0118 (zone-with-API discharged: matou.nz DNS hosted at deSEC since 2026-07-31, dad3345). Successor to #221's zone lever.

What's true today

  • broker/internal/broker/ (#221) is real behind the Zone port, but its only live binding is KeySystemsZone — the registrar dyndns endpoint that died with the zone migration (it only worked while iwantmyname's DNS served the zone). The port abstraction is exactly right; the binding under it is now a corpse.
  • The zone is served by deSEC with a policy-fenced ourcloud-broker token (default-deny → allow matou.nz → explicit deny on every existing infra subname; fence-tested: 201/204 on community names, 403 on apex/MX/mail/acme/clan-lab, no domain-create, no token-manage). Secret arrives via matou-ops boot injection (never the repo).
  • Founding's rented-subdomain path still writes only the A record. ADR 0118 says the full per-community set is three records: <slug> A, *.<slug> CNAME → <slug>.matou.nz, _acme-challenge.<slug> CNAME → the community's acme-dns registration.

What to build

A DesecZone binding for the existing Zone port (record CRUD over https://desec.io/api/v1/domains/matou.nz/rrsets/), plus the port growing honest create/delete now that a binding can actually do it:

  • API contract facts (paid for, don't rediscover): repoint = PATCH (PUT demands the full representation incl. subname/type); transient 429 (honor its retry-after) and 5xx happen — retry with backoff; wildcard subnames URL-encode as %2A.
  • Eventually-consistent publication: deSEC's frontends publish in ~60–120 s. Point must verify against ns1.desec.io/ns2.desec.org (fits ADR 0049's reachability gate) — never assume a 200 means resolvable.
  • Founding writes the full record set (the three records above); offboard/eject deletes them (previously impossible — no silent leftovers, ADR 0100).
  • KeySystemsZone retires; UnconfiguredZone stays the honest fail-loud default when no token is injected.

Acceptance criteria

  • Given a claimed slug and a gateway IP, When founding points it, Then the A + wildcard CNAME + challenge CNAME exist and Point returns only after the records answer from deSEC's authoritative NS
  • Given deSEC returns 429-then-200, When the broker writes, Then the write succeeds without surfacing a fault (and a hard 4xx surfaces as a typed refusal, never a retry loop)
  • Given an offboarded community, When its records are removed, Then the slugs revert to wildcard behaviour and nothing of the community remains in the zone
  • Given no injected token, Then the composition stays the honest refusal (UnconfiguredZone), never a fabricated success

Task manifest

task: broker:desec-zone-binding
implements_seam: "Zone port's live binding over deSEC (ADR 0118)"
interface: "founding writes the full 3-record community set; offboard deletes it"
seam: "binding tests against a fake deSEC API (429/5xx/eventual-consistency scripted); KeySystemsZone deleted"
acceptance:
  - given: claimed slug + gateway IP; when: founding points; then: 3 records live, verified on authoritative NS
depends_on: []
out_of_scope: [acme-dns account registration flow (gateway side), per-community deSEC tokens (considered+deferred in ADR 0118), the matou-ops secret injection itself]
## Parent Founding spec #11 (ADRs 0047/0048/0049) · **ADR 0118** (zone-with-API discharged: matou.nz DNS hosted at deSEC since 2026-07-31, `dad3345`). Successor to #221's zone lever. ## What's true today - `broker/internal/broker/` (#221) is real behind the `Zone` port, but its only live binding is `KeySystemsZone` — the registrar dyndns endpoint that **died with the zone migration** (it only worked while iwantmyname's DNS served the zone). The port abstraction is exactly right; the binding under it is now a corpse. - The zone is served by deSEC with a policy-fenced `ourcloud-broker` token (default-deny → allow matou.nz → explicit deny on every existing infra subname; fence-tested: 201/204 on community names, 403 on apex/MX/mail/acme/clan-lab, no domain-create, no token-manage). Secret arrives via matou-ops boot injection (never the repo). - Founding's rented-subdomain path still writes only the A record. ADR 0118 says the full per-community set is three records: `<slug>` A, `*.<slug>` CNAME → `<slug>.matou.nz`, `_acme-challenge.<slug>` CNAME → the community's acme-dns registration. ## What to build A `DesecZone` binding for the existing `Zone` port (record CRUD over `https://desec.io/api/v1/domains/matou.nz/rrsets/`), plus the port growing honest create/delete now that a binding can actually do it: - **API contract facts (paid for, don't rediscover):** repoint = **PATCH** (PUT demands the full representation incl. subname/type); transient **429** (honor its retry-after) and **5xx** happen — retry with backoff; wildcard subnames URL-encode as `%2A`. - **Eventually-consistent publication:** deSEC's frontends publish in ~60–120 s. `Point` must verify against `ns1.desec.io`/`ns2.desec.org` (fits ADR 0049's reachability gate) — never assume a 200 means resolvable. - **Founding writes the full record set** (the three records above); **offboard/eject deletes them** (previously impossible — no silent leftovers, ADR 0100). - `KeySystemsZone` retires; `UnconfiguredZone` stays the honest fail-loud default when no token is injected. ## Acceptance criteria - [ ] Given a claimed slug and a gateway IP, When founding points it, Then the A + wildcard CNAME + challenge CNAME exist and `Point` returns only after the records answer from deSEC's authoritative NS - [ ] Given deSEC returns 429-then-200, When the broker writes, Then the write succeeds without surfacing a fault (and a hard 4xx surfaces as a typed refusal, never a retry loop) - [ ] Given an offboarded community, When its records are removed, Then the slugs revert to wildcard behaviour and nothing of the community remains in the zone - [ ] Given no injected token, Then the composition stays the honest refusal (UnconfiguredZone), never a fabricated success ## Task manifest ```yaml task: broker:desec-zone-binding implements_seam: "Zone port's live binding over deSEC (ADR 0118)" interface: "founding writes the full 3-record community set; offboard deletes it" seam: "binding tests against a fake deSEC API (429/5xx/eventual-consistency scripted); KeySystemsZone deleted" acceptance: - given: claimed slug + gateway IP; when: founding points; then: 3 records live, verified on authoritative NS depends_on: [] out_of_scope: [acme-dns account registration flow (gateway side), per-community deSEC tokens (considered+deferred in ADR 0118), the matou-ops secret injection itself] ```
Author
Owner

Landed in 18ebc92 on origin/main.

What shipped: KeySystemsZone (the dead registrar dyndns endpoint) retires; a real DesecZone does record CRUD over deSEC's bulk RRset REST API (PATCH …/domains/matou.nz/rrsets/) behind the policy-fenced ourcloud-broker token (Authorization: Token).

  • Full record set + honest create/delete: the Zone port grew PutRecords/DeleteRecords. Issuer.Point writes <slug> A + *.<slug> CNAME → <slug>.matou.nz + _acme-challenge.<slug> CNAME (the challenge CNAME only when a gateway acme-dns target is supplied — an empty target writes A + wildcard alone, never a fabricated delegation). New Issuer.Offboard (POST /v1/subdomains/offboard) deletes the set and frees the slug; a failed delete keeps the reservation so a name is never freed while records linger.
  • Eventual consistency: PutRecords returns only once the A record answers from deSEC's authoritative NS (ns1.desec.io/ns2.desec.org, queried directly), fitting ADR 0049's reachability gate.
  • Encoded contract: repoint = PATCH; 429 honours Retry-After, 5xx backs off (both retried to success, no fault surfaced); a hard 4xx is a terminal typed ZoneRefusal, never a retry loop.
  • Fail-loud default kept: UnconfiguredZone stays; boot wiring flips MATOU_ZONE_PASSWORD→KeySystemsZone to MATOU_DESEC_TOKEN→DesecZone.

Acceptance evidence — broker/internal/broker/zone_test.go drives the binding against a fake deSEC API: full-set-to-bulk-endpoint + publication-verified, 429-then-200 & 5xx-then-200 retry, hard-403 typed refusal not retried, delete-sends-empty-rrsets, unconfigured-fails-loud-before-any-call. Plus broker_test.go/http_test.go issuer/API full-set + offboard tests. All broker Go stages (build/vet/test/lint) and the full repo gate pass.

Out of scope (ADR 0118, unchanged): the gateway-side acme-dns registration flow, per-community deSEC tokens, the matou-ops secret injection itself.

Landed in `18ebc92` on `origin/main`. **What shipped:** `KeySystemsZone` (the dead registrar dyndns endpoint) retires; a real `DesecZone` does record CRUD over deSEC's bulk RRset REST API (`PATCH …/domains/matou.nz/rrsets/`) behind the policy-fenced `ourcloud-broker` token (`Authorization: Token`). - **Full record set + honest create/delete:** the `Zone` port grew `PutRecords`/`DeleteRecords`. `Issuer.Point` writes `<slug>` A + `*.<slug>` CNAME → `<slug>.matou.nz` + `_acme-challenge.<slug>` CNAME (the challenge CNAME only when a gateway acme-dns target is supplied — an empty target writes A + wildcard alone, never a fabricated delegation). New `Issuer.Offboard` (`POST /v1/subdomains/offboard`) deletes the set and frees the slug; a failed delete keeps the reservation so a name is never freed while records linger. - **Eventual consistency:** `PutRecords` returns only once the A record answers from deSEC's authoritative NS (`ns1.desec.io`/`ns2.desec.org`, queried directly), fitting ADR 0049's reachability gate. - **Encoded contract:** repoint = PATCH; 429 honours `Retry-After`, 5xx backs off (both retried to success, no fault surfaced); a hard 4xx is a terminal typed `ZoneRefusal`, never a retry loop. - **Fail-loud default kept:** `UnconfiguredZone` stays; boot wiring flips `MATOU_ZONE_PASSWORD`→`KeySystemsZone` to `MATOU_DESEC_TOKEN`→`DesecZone`. **Acceptance evidence** — `broker/internal/broker/zone_test.go` drives the binding against a fake deSEC API: full-set-to-bulk-endpoint + publication-verified, 429-then-200 & 5xx-then-200 retry, hard-403 typed refusal not retried, delete-sends-empty-rrsets, unconfigured-fails-loud-before-any-call. Plus `broker_test.go`/`http_test.go` issuer/API full-set + offboard tests. All broker Go stages (build/vet/test/lint) and the full repo gate pass. **Out of scope (ADR 0118, unchanged):** the gateway-side acme-dns registration flow, per-community deSEC tokens, the matou-ops secret injection itself.
ben closed this issue 2026-07-31 21:44:11 +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#234
No description provided.