Skip to content
Toolkit

ADR-0078 — The catalogue serves what a registry vouches for

  • Status: Accepted
  • Date: 2026-08-28
  • Deciders: Track 004 phase 04
  • Follows: ADR-0013 (plan quotas resolve from the plan), ADR-0030 (identity vocabularies are generated packages, runtime data is served), ADR-0077 (the current plan is an identity, not a price)

Context

GET /api/v1/plans returned models.Plan unprojected, so plans.settings reached every signed-in account whole — the operator's affiliate_commission_percentage beside the quotas and capabilities, and anything else anyone had ever written into the blob. Anonymous callers get 401, so this was over-serving rather than a public leak, and it cost nothing while nothing read the blob.

Phase 04 made the catalogue read it. A surface that draws from a field is a reason to decide what that field contains, and "whatever the row happens to hold" is not a decision — it is the absence of one. plans.settings is JSONB and an operator's working space: it grows by writing, never by declaring, so nobody adding a key to it is thinking about who can read it.

Decision

The catalogue is served a projection: the registered capabilities (models.Capabilities) and the registered quotas (models.PlanQuotas), by key, and nothing else. A key neither registry defines is operator bookkeeping — not part of what a plan is sold as — and stays server-side until some registry vouches for it. models.CatalogueSettings is the projection; Plan.ForCatalogue returns a copy carrying it, because the caller holds a repository-owned pointer and the admin surfaces are entitled to the whole blob.

Values are copied, never coerced, and absence is never filled in. Whether a capability is granted is the reader's test to make — Allows on the server, === true on the page — and a projection that normalised a non-boolean to false would be a second, softer answer to the question the gate answers. An absent key stays absent because absence is meaningful on both halves and means opposite things: an absent quota unlimits, an absent capability denies.

An empty blob projects to {}, not null, so a client reads it without a null check.

Alternatives

Leave it and shape the page instead. The page already ignores what it does not draw, so nothing would look different. But "the client does not render it" is not a statement about who can read it, and the fix belongs where the data leaves the building.

A hand-written DTO with an explicit field list. It would say what the catalogue serves in one readable struct, and it would drift the first time a capability is minted: a second list of keys is exactly the defect Q5 and rule C4 exist to refuse, wearing Go. The registries are already the list.

Project on the way out of the repository. Then no caller can forget — and neither can the admin surfaces, which need the whole blob. The narrowing is a property of this endpoint's audience, so it lives at the endpoint.

Also drop translations, taxes, status and order from the response. Defensible, and a different question: those are columns on a declared type, readable in the API contract, not an undeclared blob. Narrowing them is a breaking change to a described shape and belongs under /api/v2/ if it is wanted at all.

Consequences

A new key in plans.settings is invisible to the catalogue until it is registered as a capability or a quota. That is the intended direction — the registries are how a key becomes part of the product — but it is a real constraint on anyone who expects to add a field and see it on the page.

The response's settings shape is now narrower than the Plan type suggests. The API contract already describes it as an open object, so nothing there becomes untrue; a reader of models.Plan alone would still guess wrong, which is why the projection sits in plan_catalogue.go beside the two registries it reads rather than inside the handler.

Source: docs/decisions/0078-the-catalogue-serves-what-a-registry-vouches-for.md

Library