ADR 0050 Phase A. Rename the licence's `provider` field to `vendor` — the inventory already uses "provider" for which node answers a brokered provision, and one word must not carry two facts — and route the licence layer's sealing and delivery through a per-vendor adapter selected by that field. The rename touches the Go struct/params/SQL in internal/licences, the operator CLI, and the schema: 0001 (the consolidated schema) now creates the column as `vendor`; a new guarded 0002 renames it on a database that predates the change, and is a no-op on a fresh one. The adapter (internal/licences/adapters) has a `shape` and the two verbs a static-key vendor needs — accept (the generic anonymous-box seal) and deliver (the sealed blob unchanged). refresh/identity/usage are named as optional capability interfaces so the refreshable-grant seam exists before its code. A registry maps vendor→shape (anthropic→static-key for now, with a Phase-B TODO to swap it to refreshable-grant); an unknown vendor is refused clearly. Behaviour is unchanged from the operator's view except the field name. Claude-Session: https://claude.ai/code/session_01LrgweAeERJYBg88c5cKDzF
23 lines
1.1 KiB
SQL
23 lines
1.1 KiB
SQL
-- Vendor, not provider.
|
|
--
|
|
-- novox/hq ADR 0050 renames the licence's vendor field from `provider` to `vendor`. "provider" is
|
|
-- already the word the inventory uses for *which node answers a brokered provision*; reusing it for
|
|
-- *which company sells this licence* would collide two unrelated facts on one word. The consolidated
|
|
-- schema (0001) now creates the column as `vendor`; this migration carries an existing database the
|
|
-- same distance.
|
|
--
|
|
-- **Guarded so it is a no-op on a fresh database.** A database created after 0001 was updated
|
|
-- already has `vendor` and no `provider` column, and PostgreSQL has no `RENAME COLUMN IF EXISTS` --
|
|
-- so the rename is wrapped in an explicit existence check. On a database that predates the rename
|
|
-- the `provider` column is present and is renamed; on a fresh one nothing is done, and both end with
|
|
-- exactly the same schema.
|
|
do $$
|
|
begin
|
|
if exists (
|
|
select 1 from information_schema.columns
|
|
where table_name = 'licence' and column_name = 'provider'
|
|
) then
|
|
alter table licence rename column provider to vendor;
|
|
end if;
|
|
end $$;
|