Skip to content

Schema Validation: 14 critical/high schema drift issues found (1 P0, 13 P1)Β #604

Closed as not planned

Description

@vybe

Automated Schema Validation Report

Date: 2026-04-30
Result: 14 critical/high schema drift issues require attention


πŸ”΄ P0 β€” Ad-hoc CREATE TABLE in Router (Invariant #3 + #1 violation)

File: src/backend/routers/processes.py:781

process_schedules is created via an ad-hoc CREATE TABLE IF NOT EXISTS directly inside a router function that opens a raw sqlite3.connect() to trinity.db. This violates:

Fix: Move DDL to db/schema.py, add a numbered migration in db/migrations.py, and delegate the insert/query logic to a service + db module.


🟠 P1 β€” 9 Tables Only in migrations.py, Missing from schema.py

The following tables are created via migrations but never added to schema.py's TABLES dict. This makes schema.py an incomplete canonical DDL β€” tests, tooling, and documentation generators that rely on it will produce wrong results. Note: subscription_credentials is even listed in schema.py's own header comment but absent from the TABLES dict.

Missing Table Created By Migration
agent_notifications agent_notifications (#13)
subscription_credentials subscription_credentials (#16)
subscription_rate_limit_events subscription_rate_limit_tracking (#29)
slack_workspaces slack_channel_agents (#31)
slack_channel_agents slack_channel_agents (#31)
slack_active_threads slack_channel_agents (#31)
telegram_bindings telegram_bindings (#34)
telegram_chat_links telegram_bindings (#34)
telegram_group_configs telegram_group_configs (#37)

Fix: Add each table's DDL to schema.py's TABLES dict (with IF NOT EXISTS β€” safe because migrations already created them on existing installs).


🟠 P1 β€” 12 Migration-Added Columns Missing from schema.py DDL

agent_ownership β€” 3 columns absent from CREATE TABLE in schema.py:

  • full_capabilities (migration: agent_ownership_full_capabilities)
  • max_backlog_depth (migration: backlog_support)
  • voice_system_prompt (migration: agent_ownership_voice_prompt)

schedule_executions β€” 9 columns absent from CREATE TABLE in schema.py:

  • source_user_id, source_user_email, source_agent_name, source_mcp_key_id, source_mcp_key_name (migration: execution_origin_tracking)
  • claude_session_id (migration: execution_session_tracking)
  • fan_out_id (migration: execution_fan_out_id)
  • queued_at, backlog_metadata (migration: backlog_support)

Fix: Add the missing columns to the CREATE TABLE DDL in schema.py. The columns already exist in production via migrations; updating schema.py is safe and needed for correctness.


Recommended Priority

  1. Immediately: Add the 9 missing tables to schema.py TABLES dict (low-risk, cosmetic)
  2. Immediately: Add the 12 missing columns to the agent_ownership and schedule_executions DDL in schema.py (low-risk, cosmetic)
  3. Next sprint: Refactor process_schedules out of the router and into db/schema.py + a proper migration (requires small refactor)

Generated by scheduled /validate-schema run

Activity

  1. added
    priority-p1
    type-bug
    automated
    on Apr 30, 2026
  2. vybe commented on May 5, 2026

    @vybe
    ContributorAuthor

    Closing as duplicate of #655 (Schema validation). The daily validation process should update a single tracking issue rather than creating new ones each run.

  3. added
    complexity-medium
    theme-reliability
    on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    automatedcomplexity-mediumpriority-p1theme-reliabilitytype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions