Skip to content

Schema Validation: 13 critical drift issues found (schema.py out of sync) #413

Description

@vybe

Automated Schema Validation Report

Date: 2026-04-20
Result: 13 critical schema drift issues require attention (P0/P1)


P0 Critical — Ad-Hoc Tables in Main DB (Invariant #3 Violations)

Tables created directly in service/router code, bypassing the schema system entirely. All write to the main trinity.db.

File Table Issue
routers/processes.py:781 process_schedules Created ad-hoc in router function
services/process_engine/services/templates.py:117 process_templates Created ad-hoc in service
services/process_engine/services/alerts.py:163 cost_thresholds Created ad-hoc in service
services/process_engine/services/alerts.py:178 cost_alerts Created ad-hoc in service

Fix: Add these 4 tables to db/schema.py TABLES dict and add corresponding entries to db/migrations.py for existing installs. Remove inline CREATE TABLE from service/router code.


P1 Critical — Tables Only in migrations.py (Missing from schema.py)

9 tables exist on running databases via migrations but are absent from schema.py. The two-pass migration system works for fresh installs, but schema.py is supposed to be the authoritative DDL.

  • agent_notifications
  • subscription_credentials
  • subscription_rate_limit_events
  • slack_workspaces
  • slack_channel_agents
  • slack_active_threads
  • telegram_bindings
  • telegram_chat_links
  • telegram_group_configs

Fix: Add all 9 tables to db/schema.py TABLES dict.


P1 Critical — Columns Missing from schema.py DDL

Running databases have these columns (added by migrations) but they are absent from the schema.py CREATE TABLE statements.

agent_ownership (3 missing):

  • full_capabilities INTEGER DEFAULT 0
  • max_backlog_depth INTEGER DEFAULT 50
  • voice_system_prompt TEXT

schedule_executions (9 missing):

  • source_user_id, source_user_email, source_agent_name, source_mcp_key_id, source_mcp_key_name
  • claude_session_id
  • queued_at, backlog_metadata
  • fan_out_id

Fix: Add these 12 columns to the respective CREATE TABLE statements in db/schema.py.


Recommended Actions (Priority Order)

  1. Fix P0 ad-hoc tables: Move process_schedules, process_templates, cost_thresholds, cost_alerts into db/schema.py + add migrations. Remove inline DDL from service code.
  2. Sync missing tables: Add the 9 migration-only tables into db/schema.py.
  3. Sync missing columns: Update agent_ownership and schedule_executions DDL in db/schema.py with the 12 missing columns.

Generated by scheduled /validate-schema run

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions