feat(db): extract service_config / label_catalog / agent_type_* aggregates to Drizzle (#845) #866

Merged
reviewer merged 1 commit from code-lead/845 into main 2026-05-04 23:39:31 +00:00
Collaborator

Splits the resolver hot-path SQL off domain/agent-config/resolver.ts into per-aggregate Drizzle modules (service-config-store, label-catalog, agent-type-config) backed by per-aggregate Drizzle schema files; pure ladder helpers move to domain/agent-config/ladder.ts and the resolver itself becomes a re-export shim plus the SC-6 token resolvers.

Test plan

  • bun x turbo run typecheck clean
  • bun x @biomejs/biome@^2 check . only pre-existing warnings
  • bun x @biomejs/biome@^2 format . clean
  • bun x turbo run test — 3154/3154 pass
  • sql-layer-check passes (no bun:sqlite value imports outside infrastructure/database/)

Closes #845

Splits the resolver hot-path SQL off `domain/agent-config/resolver.ts` into per-aggregate Drizzle modules (`service-config-store`, `label-catalog`, `agent-type-config`) backed by per-aggregate Drizzle schema files; pure ladder helpers move to `domain/agent-config/ladder.ts` and the resolver itself becomes a re-export shim plus the SC-6 token resolvers. ## Test plan - [x] `bun x turbo run typecheck` clean - [x] `bun x @biomejs/biome@^2 check .` only pre-existing warnings - [x] `bun x @biomejs/biome@^2 format .` clean - [x] `bun x turbo run test` — 3154/3154 pass - [x] `sql-layer-check` passes (no `bun:sqlite` value imports outside `infrastructure/database/`) Closes #845
feat(db): extract service_config / label_catalog / agent_type_* aggregates to Drizzle (#845)
All checks were successful
qa / dockerfile (pull_request) Successful in 13s
qa / sql-layer-check (pull_request) Successful in 13s
qa / db-schema (pull_request) Successful in 26s
qa / qa-1 (pull_request) Successful in 44s
qa / qa (pull_request) Successful in 0s
f988c45717
Splits the resolver hot path off `domain/agent-config/resolver.ts` into
per-aggregate Drizzle modules. The resolver becomes a re-export shim plus
the SC-6 token resolvers (which orchestrate decryption + audit log on top
of the moved aggregates and have no raw SQL of their own).

New schema files (Drizzle):
- schema/service-config.ts (service_config + service_settings)
- schema/label-catalog.ts (label_catalog)
- schema/agent-type.ts (agent_type + agent_type_config / container / routing)
- schema/agent-config-scope.ts (skill / system_prompt / plugin_binding /
  plugin_marketplace / mcp_server)

New store modules (one per aggregate, typed Drizzle queries):
- service-config-store.ts owns getServiceConfig, getSpeechConfig,
  getSettings, patchSettingsDb (the latter two moved out of db.ts)
- label-catalog.ts owns getLabelCatalogForRepo
- agent-type-config.ts owns getAgentType, resolveAgentTypeConfig /
  Container / Routing / ConfigsByType plus resolveSkill, resolveSystemPrompt,
  resolvePlugins, resolveMarketplaces, resolveMcpServers

Pure ladder helpers (pickFromLadder, mergeByKey, AgentScope, ScopedRow,
ConfigScope, isCandidateForAgent, isInstanceDisable, scopePriorityFor,
asScope) move to a new ladder.ts so the data-access layer doesn't reach
back into the resolver. resolver.ts and db.ts re-export the moved surface
for backward compat with the 17+ existing call sites.

No raw SQL strings remain in domain/agent-config/resolver.ts for the
extracted tables.
reviewer approved these changes 2026-05-04 23:39:26 +00:00
reviewer left a comment

Clean extraction — resolver.ts is now a pure re-export shim, all five schema files mirror the existing SQL shape, ladder helpers correctly split to ladder.ts, and the _db compat parameter is explicitly ignored in favour of orm(). No raw SQL strings remain in resolver.ts for the moved tables.

Nit: _db parameter accepted-but-ignored on every new function — minor, not blocking.

Clean extraction — resolver.ts is now a pure re-export shim, all five schema files mirror the existing SQL shape, ladder helpers correctly split to `ladder.ts`, and the `_db` compat parameter is explicitly ignored in favour of `orm()`. No raw SQL strings remain in resolver.ts for the moved tables. Nit: `_db` parameter accepted-but-ignored on every new function — minor, not blocking.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!866
No description provided.