Skip to content

feat: introduce organizations and org-scoped credentials#278

Merged
zbigniewsobiecki merged 1 commit intodevfrom
feat/organizations-and-credentials
Feb 16, 2026
Merged

feat: introduce organizations and org-scoped credentials#278
zbigniewsobiecki merged 1 commit intodevfrom
feat/organizations-and-credentials

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

  • Introduces organizations as the top-level entity for multi-tenancy
  • Replaces flat project_secrets with structured credentials table (org-scoped, with metadata and is_default flag)
  • Adds project_credential_overrides for per-project credential overrides that reference credentials by ID
  • Adds org_id FK to projects, cascade_defaults, and agent_configs
  • Migration 0003 handles schema changes + data migration from project_secrets
  • Provider API (getProjectSecret, getProjectSecrets) unchanged — zero changes needed in consumers

Credential Resolution

project_credential_overrides → org default credential → null

Files Changed

New:

  • src/db/schema/organizations.ts — organizations table
  • src/db/schema/credentials.ts — credentials + project_credential_overrides tables
  • src/db/repositories/credentialsRepository.ts — resolution, CRUD, override management
  • src/db/migrations/0003_organizations_and_credentials.sql — migration with data backfill
  • tests/unit/config/configCache.test.ts — 12 tests for new cache paths
  • tests/unit/db/repositories/credentialsRepository.test.ts — 18 tests for all repository functions

Modified:

  • src/db/schema/projects.tsorgId on projects + agent_configs
  • src/db/schema/defaults.tsorgId (NOT NULL, UNIQUE) replacing singleton pattern
  • src/config/provider.ts — uses credentialsRepository instead of secretsRepository
  • src/config/configCache.tsorgIdByProject cache
  • src/db/repositories/configRepository.ts — org-scoped defaults + agent config resolution
  • tools/manage-secrets.ts — rewritten for org-scoped credential management

Test plan

  • npm run typecheck — clean
  • npm run lint — 0 errors (pre-existing warnings only)
  • npm test — 857 tests passing (39 new)
  • New test coverage: provider.ts 100%, configCache.ts 100%, credentialsRepository.ts 100%
  • Run migration against test database with existing data
  • Verify resolve <project-id> returns same credentials as before

🤖 Generated with Claude Code

Replace the flat project_secrets table with a structured credential system
scoped to organizations. Credentials are defined once at org level with
metadata (name, env_var_key, description) and referenced by ID. Projects
can override specific credentials while sharing org-level defaults.

Schema changes:
- New organizations table (top-level entity)
- New credentials table with org FK, is_default flag, partial unique index
- New project_credential_overrides table for per-project overrides
- Add org_id FK to projects, cascade_defaults, and agent_configs
- Migration 0003 with data migration from project_secrets

Credential resolution order:
  project override → org default → null (caller decides fallback)

The provider API (getProjectSecret, getProjectSecrets) is unchanged,
so all webhook handlers, adapters, and backends work without modification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit 8ad95a4 into dev Feb 16, 2026
4 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the feat/organizations-and-credentials branch February 16, 2026 08:54
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