chore(db): drop NON_BUILTIN_SCOPE_FILTER + every ne(scope,'builtin') predicate #940

Closed
opened 2026-05-08 08:56:44 +00:00 by claude-desktop · 0 comments
Collaborator

As a maintainer, I want every read-time guard against scope='builtin' removed once migration 0010 is in place, so that the codebase stops carrying a defensive scaffold that no longer protects against anything.

After migration 0010 lands, the CHECK constraint enforces "no builtin rows" at the storage layer. Every Drizzle ne(*.scope, "builtin") predicate, the NON_BUILTIN_SCOPE_FILTER = "scope != 'builtin'" SQL fragment, and the various "skip builtin" branches become dead defensive code that hides the simpler invariant.

Acceptance criteria

Code

  • Delete NON_BUILTIN_SCOPE_FILTER from apps/server/src/domain/agent-config/ladder.ts:164 and remove every caller.
  • Delete every ne(<table>.scope, "builtin") Drizzle predicate in apps/server/src/infrastructure/database/agent-type-config.ts and apps/server/src/infrastructure/database/sr3-m1-migration.ts.
  • Delete the WHERE scope != 'builtin' clauses in apps/server/src/infrastructure/database/sr3-m1-migration.ts.
  • Delete the dead INSERT-from-builtin-defaults branches inside the four agent-types-settings PUT handlers (identity / container / routing — dispatch handler had no such branch).
  • Drop the now-stale "DOB-2 builtin filter" comment blocks. Replace with a one-line link to migration 0010 if context is genuinely useful; otherwise let the diff speak for itself.

Type narrowing

  • ConfigScope (already narrowed) and pickFromLadder / scopePriorityFor get one fewer dead branch — drop the "builtin rows are silently skipped" guard in pickFromLadder.
  • asScope no longer needs to mention builtin in its error message.

Tests

  • Existing tests still green (just qa). Filter removal is mechanical — no new test cases needed.
  • Drop or rename test fixtures that say seedBuiltins or similar.

Out of scope

  • Frontend SCOPE_ORDER cleanup — separate web story.
  • label_catalog handler changes — handled inside the "extract label_catalog presets" story.

References

  • Meta tracker: #934
  • Block-on: feat(db): migration 0010 — collapse 'builtin' from runtime tables
As a maintainer, I want every read-time guard against `scope='builtin'` removed once migration 0010 is in place, so that the codebase stops carrying a defensive scaffold that no longer protects against anything. After migration 0010 lands, the CHECK constraint enforces "no builtin rows" at the storage layer. Every Drizzle `ne(*.scope, "builtin")` predicate, the `NON_BUILTIN_SCOPE_FILTER = "scope != 'builtin'"` SQL fragment, and the various "skip builtin" branches become dead defensive code that hides the simpler invariant. ## Acceptance criteria ### Code - [ ] Delete `NON_BUILTIN_SCOPE_FILTER` from `apps/server/src/domain/agent-config/ladder.ts:164` and remove every caller. - [ ] Delete every `ne(<table>.scope, "builtin")` Drizzle predicate in `apps/server/src/infrastructure/database/agent-type-config.ts` and `apps/server/src/infrastructure/database/sr3-m1-migration.ts`. - [ ] Delete the `WHERE scope != 'builtin'` clauses in `apps/server/src/infrastructure/database/sr3-m1-migration.ts`. - [ ] Delete the dead INSERT-from-builtin-defaults branches inside the four `agent-types-settings` PUT handlers (identity / container / routing — dispatch handler had no such branch). - [ ] Drop the now-stale "DOB-2 builtin filter" comment blocks. Replace with a one-line link to migration 0010 if context is genuinely useful; otherwise let the diff speak for itself. ### Type narrowing - [ ] `ConfigScope` (already narrowed) and `pickFromLadder` / `scopePriorityFor` get one fewer dead branch — drop the "builtin rows are silently skipped" guard in `pickFromLadder`. - [ ] `asScope` no longer needs to mention builtin in its error message. ### Tests - [ ] Existing tests still green (`just qa`). Filter removal is mechanical — no new test cases needed. - [ ] Drop or rename test fixtures that say `seedBuiltins` or similar. ## Out of scope - Frontend `SCOPE_ORDER` cleanup — separate web story. - `label_catalog` handler changes — handled inside the "extract label_catalog presets" story. ## References - Meta tracker: #934 - Block-on: `feat(db): migration 0010 — collapse 'builtin' from runtime tables`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#940
No description provided.