Skip to content

feat(agent-configs): remove global/org-level agent configs — project-only migration#788

Merged
zbigniewsobiecki merged 2 commits intodevfrom
feature/project-only-agent-configs
Mar 14, 2026
Merged

feat(agent-configs): remove global/org-level agent configs — project-only migration#788
zbigniewsobiecki merged 2 commits intodevfrom
feature/project-only-agent-configs

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 13, 2026

Summary

  • Database migration (0036): Deletes non-project agent_configs rows, drops org_id column, makes project_id NOT NULL, adds simple UNIQUE(project_id, agent_type) constraint
  • Drizzle schema updated: removed orgId field, project_id is now NOT NULL with cascade delete
  • Repository simplification: listAgentConfigs requires projectId, removed listGlobalAgentConfigs, getMaxConcurrency is now single-query (no 3-tier fallback)
  • configRepository simplified: loadConfigFromDb and findProjectConfigFromDb no longer split global/org agent configs; defaults.agentModels/agentIterations are always empty
  • configMapper: Removed orgId from AgentConfigRow, removed globalAgentConfigs param from mapDefaultsRow
  • tRPC router: Removed listGlobal endpoint and superadmin logic; projectId is now required on list and create
  • CLI: --project-id is now required on cascade agents list and cascade agents create
  • Frontend: Deleted global/settings agent config pages; removed isGlobalScope prop from shared components; updated route-tree and sidebar
  • Tools: seed-prompts.ts no longer seeds agent_configs; resolve-config.ts shows only project-level config layer
  • Model resolution: Removed defaults.agentModels/agentIterations lookups (now always empty)
  • Tests: Updated all unit and integration tests to reflect project-only constraint

Test plan

  • All 266 unit test files pass (4599 tests)
  • TypeScript type checking passes with zero errors
  • Lint passes with zero errors
  • Migration SQL validated (delete non-project rows, drop org_id, make project_id NOT NULL)

Notes

⚠️ Data loss: Global/org-level agent_configs are deleted by the migration. Operators should recreate them as project-level configs before running migration.

Fixes: https://trello.com/c/69b455935a1ea3ca43f118e0

🤖 Generated with Claude Code

@zbigniewsobiecki
Copy link
Copy Markdown
Member

@aaight fix CI

…nly agent configs

The agent config tests were still using the old API signatures (orgId param,
projectId: null, no-arg listAgentConfigs). Updated to match the new
project-only schema after migration 0036.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aaight
Copy link
Copy Markdown
Collaborator Author

aaight commented Mar 13, 2026

Fixed. The settingsRepository.test.ts integration test was using the old agent config API signatures (orgId param, projectId: null for global configs, no-arg listAgentConfigs()). Updated all agent config test cases to use the new project-only API:

  • createAgentConfig now requires projectId (no more orgId/projectId: null)
  • listAgentConfigs now requires { projectId: string }
  • Removed tests for global/org-level config scenarios that no longer exist

All 4599 unit tests pass, typecheck clean, lint clean.

@aaight
Copy link
Copy Markdown
Collaborator Author

aaight commented Mar 13, 2026

CI Failures Resolved

Fixes Applied

  • Updated tests/integration/db/settingsRepository.test.ts to use the new project-only createAgentConfig API. The integration tests were still using old three-tier API signatures removed by migration 0036.

Specific changes:

  • Removed tests for global/org-scoped agent config creation (orgId: null, projectId: null)
  • Removed listAgentConfigs() without filter (no longer supported)
  • Removed listAgentConfigs({ orgId }) filter (no longer supported)
  • Updated all agent config tests to use required projectId: 'test-project'

Verification

  • All 266 unit test files pass (4599 tests)
  • Updated settingsRepository integration tests pass locally
  • Changes pushed to branch

🤖 Generated with Claude Code

@nhopeatall
Copy link
Copy Markdown
Collaborator

nhopeatall commented Mar 13, 2026

⚠️ review agent failed

Agent completed without making changes

Manual intervention may be required.

@zbigniewsobiecki zbigniewsobiecki merged commit bfadade into dev Mar 14, 2026
6 checks passed
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Clean, well-executed migration that removes the global/org-level agent config layers in favor of project-only scoping. The change is architecturally sound — it eliminates a 3-tier fallback system that added complexity without clear value, and the migration path is straightforward. All CI checks pass. 31 files changed across DB schema, backend, CLI, frontend, tools, and tests — all consistent.

Code Issues

Should Fix

  • web/src/components/settings/agent-configs-table.tsx — The deleteMutation.onSuccess builds the query key using configs[0]?.projectId ?? ''. If a race condition empties configs before the callback fires, this invalidates the wrong query key. Consider passing projectId as a prop to AgentConfigsTable rather than deriving it from the data array.

  • web/src/components/settings/agent-config-form-dialog.tsxprojectId: config?.projectId as string is a type assertion that bypasses type safety. If config is undefined, this would send undefined to the API. Safe in practice since the component is only used for edits from AgentConfigsTable, but a defensive check would be cleaner.

Notes

The migration warning about data loss is appropriately documented in the PR description. The DELETE FROM agent_configs WHERE project_id IS NULL is irreversible, which is the correct behavior for this intentional simplification.

@zbigniewsobiecki zbigniewsobiecki deleted the feature/project-only-agent-configs branch March 16, 2026 16:43
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.

3 participants