feat(db): migration 0010 — collapse 'builtin' from runtime tables #939
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks#939
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
As a service operator, I want a one-shot migration that drops every
scope='builtin'row and rewrites the table CHECK constraints so they no longer permit'builtin', so that the runtime invariant ("no builtin layer") is enforced by the database itself.This is the load-bearing story of tracker #934. It must land after the constants + wizard stories (otherwise existing installs lose factory data) and before the SQL-filter cleanup (otherwise dropped filters allow stale builtin rows to leak).
Acceptance criteria
Migration
0010_collapse_builtin.sqlagent_type,agent_type_config,agent_type_container,agent_type_routing,mcp_server,plugin_binding,plugin_marketplace,skill,system_prompt,service_config,label_catalog.service_configandlabel_catalog: before deleting the builtin rows, INSERT-OR-IGNORE the deleted values into thescope='global'layer so existing installs keep their factory data. (Wizard story handles fresh installs; this branch is the upgrade path for live DBs.)DELETE FROM <table> WHERE scope='builtin'on every listed table.'builtin'from the allowed scope set. SQLite-friendly approach:CREATE TABLE …_new,INSERT INTO …_new SELECT … FROM …,DROP TABLE …,ALTER TABLE …_new RENAME TO ….Schema files
apps/server/src/infrastructure/database/schema/*.ts) to mirror the new CHECK clauses — drop the "still permits'builtin'" allowance and the comments that justify it.Tests
service_config/label_catalog.scope='builtin') post-migration fails with a CHECK constraint error.apps/server/src/infrastructure/database/migrate.test.tsor similar) still green.Out of scope
NON_BUILTIN_SCOPE_FILTERSQL fragment + Drizzlene(*.scope, "builtin")predicates — that's the next chore. Keeping those filters in place during this migration is intentional defense in depth.References
ConfigScopetype but did not touch CHECK clausesapps/server/src/infrastructure/database/drizzle/0000_init.sql:7-63