AOI-5: prune stale instance-scope enabled=false rows #734

Closed
opened 2026-05-02 11:01:46 +00:00 by claude-desktop · 0 comments
Collaborator

As an operator upgrading to add-only-inheritance, I want a one-shot migration to clean up any stale instance-scope enabled=false rows, so that the resolver's new behavior does not silently strand orphan rows that no longer take effect, and so AOI-1's CHECK constraints can be added on a clean DB.

Ships before AOI-1. AOI-1's CHECK constraint will fail to apply if these rows still exist.

Acceptance criteria

Migration

  • New migration migrations/00Y-prune-instance-disables.ts (number before AOI-1's migration).
  • Selects all rows from plugin_binding and mcp_server where scope='instance' AND enabled=0.
  • For each row, logs at info:
    AOI-5: pruning stale instance-scope disable: kind=plugin_binding instance_id=42 plugin_name=context7
    AOI-5: pruning stale instance-scope disable: kind=mcp_server instance_id=42 name=penpot
    
  • Deletes the rows.
  • Idempotent: re-running the migration is a no-op (post-AOI-1, validation prevents new rows so the table never refills).

Operator messaging

  • Boot summary line: "AOI-5 pruned <N> stale instance-scope disable rows. To re-disable, edit at agent_type or global scope."
  • If N=0: single line "AOI-5: no stale disables to prune."

Tests

  • Migration test: seed enabled=false rows at scope='instance' for both plugin_binding and mcp_server, run migration, assert rows gone, assert log emitted with correct kind/name.
  • Migration test: seed zero such rows, assert no-op log only.
  • Migration test: seed one such row, run migration twice — second run is a no-op.

Out of scope

  • Backup / export of pruned rows. They are cheap to recreate at agent_type scope; backup adds complexity for marginal value.
  • Migration for skill / system_prompt (no enabled column to prune).
  • AOI-1's CHECK constraint — that lands in AOI-1's own migration.

References

  • AOI-1 (the CHECK constraint that depends on this prune running first).
  • apps/server/src/infrastructure/database/migrations/ (existing migration entry point).
As an operator upgrading to add-only-inheritance, I want a one-shot migration to clean up any stale instance-scope `enabled=false` rows, so that the resolver's new behavior does not silently strand orphan rows that no longer take effect, and so AOI-1's CHECK constraints can be added on a clean DB. **Ships before AOI-1.** AOI-1's CHECK constraint will fail to apply if these rows still exist. ## Acceptance criteria ### Migration - [ ] New migration `migrations/00Y-prune-instance-disables.ts` (number before AOI-1's migration). - [ ] Selects all rows from `plugin_binding` and `mcp_server` where `scope='instance' AND enabled=0`. - [ ] For each row, logs at `info`: ``` AOI-5: pruning stale instance-scope disable: kind=plugin_binding instance_id=42 plugin_name=context7 AOI-5: pruning stale instance-scope disable: kind=mcp_server instance_id=42 name=penpot ``` - [ ] Deletes the rows. - [ ] Idempotent: re-running the migration is a no-op (post-AOI-1, validation prevents new rows so the table never refills). ### Operator messaging - [ ] Boot summary line: `"AOI-5 pruned <N> stale instance-scope disable rows. To re-disable, edit at agent_type or global scope."` - [ ] If `N=0`: single line `"AOI-5: no stale disables to prune."` ### Tests - [ ] Migration test: seed `enabled=false` rows at `scope='instance'` for both `plugin_binding` and `mcp_server`, run migration, assert rows gone, assert log emitted with correct kind/name. - [ ] Migration test: seed zero such rows, assert no-op log only. - [ ] Migration test: seed one such row, run migration twice — second run is a no-op. ## Out of scope - Backup / export of pruned rows. They are cheap to recreate at `agent_type` scope; backup adds complexity for marginal value. - Migration for `skill` / `system_prompt` (no `enabled` column to prune). - AOI-1's CHECK constraint — that lands in AOI-1's own migration. ## References - AOI-1 (the CHECK constraint that depends on this prune running first). - `apps/server/src/infrastructure/database/migrations/` (existing migration entry point).
Sign in to join this conversation.
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#734
No description provided.