feat(db): extract agents + provider-state aggregates to Drizzle (#844) #864
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!864
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "code-lead/844"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Splits the
agents,agent_provider_state, andagent_provider_eventsCRUD blocks out of thedb.tsgod-file into per-aggregate Drizzle modules. TheregisterOnAgentDeletelifecycle hook is preserved verbatim sodomain/agent/provider-failover.tskeeps scrubbing its in-memory 5xx sliding window on instance delete.schema/agents.tsdeclaresmatch_labels/pluginsastext({ mode: "json" }).$type<string[]>(); the publicAgentRowshape keeps the raw JSON-string form so the resolver layer (deferred to #845) doesn't break. Tri-statepluginssemantics are documented in the schema file.notesstays plaintext()— free-form operator text, JSON encoding adds nothing.Closes #844
Test plan
bun x turbo run typecheckclean across all 5 workspacesbun x @biomejs/biome@^2 format .no diff (3 lint warnings are pre-existing on main)bun run apps/server/scripts/db-check.ts— agents + tasks bothokbun test— 3137 pass / 0 fail across 137 filesagents-store.test.ts(45 tests) +agent-provider.test.ts(10 tests) cover CRUD, hook contract, and cascadeSplits the `agents`, `agent_provider_state`, and `agent_provider_events` CRUD blocks out of the `db.ts` god-file into per-aggregate Drizzle modules. The `registerOnAgentDelete` lifecycle hook is preserved verbatim so `domain/agent/provider-failover.ts` can keep scrubbing its in-memory 5xx sliding window on instance delete. `schema/agents.ts` declares `match_labels` / `plugins` as `text({ mode: "json" }).$type<string[]>()`; the public `AgentRow` shape keeps the raw JSON-string form so the resolver layer (deferred to #845) doesn't break. Tri-state `plugins` semantics (NULL = inherit, [] = empty override, array = explicit list) are documented in the schema file. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>Extraction clean — all ~23 functions moved to
agents-store.ts/agent-provider.ts, callers updated,registerOnAgentDeletehook contract preserved verbatim, Drizzle schemas match the SQL init.decodeAgentRowre-stringify is intentional and correct. 55 new tests cover CRUD, tri-state plugins, cascade, and hook-fires-once. CI green.PR has conflicts — please rebase on main before merging.
f3a43cc424f58707441f