Skip to content

Workspaces phase 4a: schema for provider keys, MATE_SECRET_KEY required in production (#277) - #347

Merged
antiv merged 1 commit into
mainfrom
workspaces-phase-4a
Nov 14, 2026
Merged

antiv merged 1 commit into
mainfrom
workspaces-phase-4a

Conversation

@antiv

@antiv antiv commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Phase 4a of the 2.0 plan (#277): the schema for provider keys per workspace, and MATE_SECRET_KEY becomes required in production.

Schema (V049, all three dialects)

  • workspace_provider_keys holds a workspace's key for one model provider, with an optional base_url.
    • The pair (workspace_id, provider) is unique, and the row is deleted along with its workspace.
    • api_key is EncryptedText, so the auth server's startup pass encrypts a value stored in the clear, as it does the other secret columns (_secret_columns).
    • The plan names the column encrypted_value. It is api_key here because the model reads it decrypted, as with agents_config.model_api_key.
  • workspace_settings: a workspace's own value for an installation setting, keyed by (workspace_id, setting_key). It replaces the plan's system_settings.workspace_id, as 2.0 plan: phase 4 split into seven PRs (#277) #346 decided.

Nothing reads or writes either table yet. 4b and 4d read them, and 4e adds the routes that write them.

MATE_SECRET_KEY

secret_box.check_key_at_startup(enforce) raises when the key is missing and the auth server enforces secure defaults. That happens with MATE_ENV=production, unless MATE_ALLOW_INSECURE_DEFAULTS is set. Otherwise it only warns, as before.

For the 2.0 release notes: a production installation without MATE_SECRET_KEY no longer starts.

Tests

  • TestProviderKeySchema checks one key per provider per workspace, one value per setting, and that a create_all schema followed by the migrations matches.
  • test_secret_box covers the new secret column and the production refusal.
  • Mutation checks, each made to fail by removing:
    • the unique constraint;
    • the column from _secret_columns;
    • the refusal.
  • The full suite passes: 1979 tests, 1 skipped.
  • All migrations were run from scratch on PostgreSQL 16 and MySQL 8.0 in throwaway containers, now removed. V049 applied on both, the unique constraint refused a second key, and deleting the workspace removed its key and setting rows.
  • test_client_contract.py passes unchanged.

Docs

  • docs/dev/deployment.md (production checklist, secrets at rest), docs/dev/database-and-migrations.md (V049), .env.example, the README and the regenerated reference are updated.
  • drift lists docs/dev/architecture.md for auth_server.py. It doesn't describe the startup checks, so it still holds.

…ed in production (#277)

V049 adds workspace_provider_keys (a workspace's key per provider, encrypted
with MATE_SECRET_KEY, unique per workspace and provider) and workspace_settings
(a workspace's own value for an installation setting). Nothing reads them yet.

The provider key column joins the secret columns the auth server encrypts at
startup. With MATE_ENV=production the auth server refuses to start without
MATE_SECRET_KEY, unless MATE_ALLOW_INSECURE_DEFAULTS is set.
@antiv
antiv merged commit 3a09f67 into main Nov 14, 2026
2 checks passed
@antiv
antiv deleted the workspaces-phase-4a branch November 14, 2026 11:32
@antiv antiv mentioned this pull request Nov 14, 2026
22 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant