Connectors, credentials and model providers are identified by name #2129

Closed
opened 2026-11-23 13:13:57 +00:00 by sam · 1 comment
Owner

The original description is partly stale. There is no connectors.accepted table. connectors.packages already has a UUID primary key and a unique name, and connectors.credentials already has a UUID primary key.

Decision

A connector package's name (for example gitea, telegram) is its catalogue identifier and is immutable. The display label is manifest.display_name. Columns that store the package name stay as they are: judgement.action_types.connector, judgement.decisions.connector, approvals.requests.connector, events.sources.connector, deliveries.messages.channel. Workflows, Cedar rules and channel identity issuers (governance.identity_subjects.issuer, governance.link_codes.issuer) already treat it as permanent.

Replacing them with package_id was rejected:

  • deliveries.messages.channel also holds the built-in composer channel (modules/deliveries/deliveries.go), which has no package row.
  • What runs an action is an installation, not a package. Decisions and requests already store installation_id, and connectors.Get and connectors.Tool (modules/connectors/module.go) resolve an installation.

Re-accepting a package with the same name updates the existing row (ON CONFLICT (name) DO UPDATE in modules/connectors/internal/store/store.go). Deleting a package (DELETE FROM connectors.packages in the same file) frees the name; a later package accepted under that name is the same catalogue entry, which is consistent with the rule.

Installation credential slots (connectors.installations.credentials, slot to credential name) stay by name on purpose: the name resolves per scope (person, then organisation, then instance), so an instance installation uses each organisation's own credential of that name. Out of scope here.

Change

  1. Write the rule down. In 00002_connectors.sql, the comment on connectors.packages says name is the immutable package identifier, never renamed and never given to a different package. Put the same sentence on the Connector fields that store it (modules/judgement, modules/approvals, modules/events store structs).

  2. Model providers get an id. In 00001_governance.sql:

    • governance.model_providers: add id uuid PRIMARY KEY; keep UNIQUE (org_id, name); name becomes an editable label (keep its CHECK).
    • governance.model_roles.provider text becomes provider_id uuid NOT NULL REFERENCES governance.model_providers (id).
    • Update modules/governance/internal/store/store.go: the provider list, get, upsert and delete; the role-by-provider query; both role reads that join p.name = r.provider; the role upsert.
    • The API in modules/governance/models_api.go addresses providers by name: PUT and DELETE /api/settings/model-providers/{name}. Change to POST /api/settings/model-providers (create, returns the id), PUT and DELETE .../{id}, and give the provider view an id. Model role input and view carry provider_id. modules/governance/governance.go builds the provider and role rows (search for store.Provider{ and APIKeyCredential).
    • Dashboard: ui/src/settings/SystemModelsPage.vue and ui/src/lib/api.ts. Run task openapi:generate.
  3. The provider's API key credential is stored by id. governance.model_providers.api_key_credential text becomes api_key_credential_id uuid (nullable, no foreign key: connectors owns the table).

    • modules/connectors/credentials.go: add BearerTokenByID(ctx, id uuid.UUID) beside BearerToken(ctx, name). It must refuse a credential the caller's scope can't use: for an organisation's provider, only that organisation's or an instance credential.
    • modules/governance/governance.go (around the m.credentials.BearerToken(ctx, model.APIKeyCredential) call) uses it.
    • API and dashboard send and show api_key_credential_id, with the credential's name read from connectors for display. The picker is in SystemModelsPage.vue, which sends api_key_credential as the credential name.

Done when

  • connectors.packages.name is documented as an immutable identifier in the schema.
  • governance.model_providers has a UUID primary key, model_roles references it by provider_id, and a provider can be renamed.
  • model_providers references its credential by api_key_credential_id, and renaming the credential doesn't break the provider.
  • task check passes.
The original description is partly stale. There is no `connectors.accepted` table. `connectors.packages` already has a UUID primary key and a unique `name`, and `connectors.credentials` already has a UUID primary key. ## Decision A connector package's `name` (for example `gitea`, `telegram`) is its catalogue identifier and is immutable. The display label is `manifest.display_name`. Columns that store the package name stay as they are: `judgement.action_types.connector`, `judgement.decisions.connector`, `approvals.requests.connector`, `events.sources.connector`, `deliveries.messages.channel`. Workflows, Cedar rules and channel identity issuers (`governance.identity_subjects.issuer`, `governance.link_codes.issuer`) already treat it as permanent. Replacing them with `package_id` was rejected: - `deliveries.messages.channel` also holds the built-in `composer` channel (`modules/deliveries/deliveries.go`), which has no package row. - What runs an action is an installation, not a package. Decisions and requests already store `installation_id`, and `connectors.Get` and `connectors.Tool` (`modules/connectors/module.go`) resolve an installation. Re-accepting a package with the same name updates the existing row (`ON CONFLICT (name) DO UPDATE` in `modules/connectors/internal/store/store.go`). Deleting a package (`DELETE FROM connectors.packages` in the same file) frees the name; a later package accepted under that name is the same catalogue entry, which is consistent with the rule. Installation credential slots (`connectors.installations.credentials`, slot to credential name) stay by name on purpose: the name resolves per scope (person, then organisation, then instance), so an instance installation uses each organisation's own credential of that name. Out of scope here. ## Change 1. Write the rule down. In `00002_connectors.sql`, the comment on `connectors.packages` says `name` is the immutable package identifier, never renamed and never given to a different package. Put the same sentence on the `Connector` fields that store it (`modules/judgement`, `modules/approvals`, `modules/events` store structs). 2. Model providers get an id. In `00001_governance.sql`: - `governance.model_providers`: add `id uuid PRIMARY KEY`; keep `UNIQUE (org_id, name)`; `name` becomes an editable label (keep its CHECK). - `governance.model_roles.provider text` becomes `provider_id uuid NOT NULL REFERENCES governance.model_providers (id)`. - Update `modules/governance/internal/store/store.go`: the provider list, get, upsert and delete; the role-by-provider query; both role reads that join `p.name = r.provider`; the role upsert. - The API in `modules/governance/models_api.go` addresses providers by name: `PUT` and `DELETE /api/settings/model-providers/{name}`. Change to `POST /api/settings/model-providers` (create, returns the id), `PUT` and `DELETE .../{id}`, and give the provider view an `id`. Model role input and view carry `provider_id`. `modules/governance/governance.go` builds the provider and role rows (search for `store.Provider{` and `APIKeyCredential`). - Dashboard: `ui/src/settings/SystemModelsPage.vue` and `ui/src/lib/api.ts`. Run `task openapi:generate`. 3. The provider's API key credential is stored by id. `governance.model_providers.api_key_credential text` becomes `api_key_credential_id uuid` (nullable, no foreign key: `connectors` owns the table). - `modules/connectors/credentials.go`: add `BearerTokenByID(ctx, id uuid.UUID)` beside `BearerToken(ctx, name)`. It must refuse a credential the caller's scope can't use: for an organisation's provider, only that organisation's or an instance credential. - `modules/governance/governance.go` (around the `m.credentials.BearerToken(ctx, model.APIKeyCredential)` call) uses it. - API and dashboard send and show `api_key_credential_id`, with the credential's name read from `connectors` for display. The picker is in `SystemModelsPage.vue`, which sends `api_key_credential` as the credential name. ## Done when - `connectors.packages.name` is documented as an immutable identifier in the schema. - `governance.model_providers` has a UUID primary key, `model_roles` references it by `provider_id`, and a provider can be renamed. - `model_providers` references its credential by `api_key_credential_id`, and renaming the credential doesn't break the provider. - `task check` passes.
sam added the highbug labels 2026-11-23 13:13:57 +00:00
Author
Owner

Landed in 26e19f3de. Verified with task check and against a throwaway PostgreSQL 18 instance (baseline migrations 00001-00012, connectors.packages.name immutability comment, model_providers UUID PK + provider_id FK on model_roles, POST /api/settings/model-providers 201 and PUT/DELETE /api/settings/model-providers/{id} with 409 on duplicate name and in-use delete, credential rename resolution by api_key_credential_id, and 400 refusal of person-scoped credentials on org model providers).

Landed in 26e19f3de. Verified with task check and against a throwaway PostgreSQL 18 instance (baseline migrations 00001-00012, connectors.packages.name immutability comment, model_providers UUID PK + provider_id FK on model_roles, POST /api/settings/model-providers 201 and PUT/DELETE /api/settings/model-providers/{id} with 409 on duplicate name and in-use delete, credential rename resolution by api_key_credential_id, and 400 refusal of person-scoped credentials on org model providers).
sam closed this issue 2026-11-23 19:54:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#2129