Automated Schema Validation Report
Date: 2026-05-05
Result: 25 critical schema drift issues — schema.py is incomplete relative to db/migrations.py
Background
schema.py declares itself as containing "all CREATE TABLE and CREATE INDEX statements" and is referenced by Architectural Invariant #3. However, 11 tables and 14 columns that exist in running databases are absent from schema.py. The system works correctly at runtime due to the double-pass migration pattern (migrations run before and after init_schema), but schema.py is not the authoritative reference it claims to be.
Critical Finding 1: 11 tables exist only in migrations (not in schema.py)
| Table |
Migration |
Feature |
agent_notifications |
agent_notifications |
NOTIF-001 |
subscription_credentials |
subscription_credentials |
SUB-001 |
subscription_rate_limit_events |
subscription_rate_limit_tracking |
SUB-003 |
telegram_bindings |
telegram_bindings |
TELEGRAM-001 |
telegram_chat_links |
telegram_bindings |
TELEGRAM-001 |
telegram_group_configs |
telegram_group_configs |
TGRAM-GROUP |
slack_workspaces |
slack_channel_agents |
SLACK-002 |
slack_channel_agents |
slack_channel_agents |
SLACK-002 |
slack_active_threads |
slack_channel_agents |
SLACK-002 |
whatsapp_bindings |
whatsapp_bindings |
WHATSAPP-001 |
whatsapp_chat_links |
whatsapp_bindings |
WHATSAPP-001 |
Critical Finding 2: 14 columns exist only in migrations (not in schema.py DDL)
agent_ownership (3 columns):
full_capabilities INTEGER DEFAULT 0
voice_system_prompt TEXT (VOICE-005)
max_backlog_depth INTEGER DEFAULT 50 (BACKLOG-001)
agent_schedules (2 columns):
webhook_token TEXT (WEBHOOK-001)
webhook_enabled INTEGER DEFAULT 0 (WEBHOOK-001)
schedule_executions (9 columns):
source_user_id INTEGER, source_user_email TEXT, source_agent_name TEXT, source_mcp_key_id TEXT, source_mcp_key_name TEXT (AUDIT-001)
claude_session_id TEXT (EXEC-023)
queued_at TEXT, backlog_metadata TEXT (BACKLOG-001)
fan_out_id TEXT (FANOUT-001)
Recommended Fix
For each migration-only table: add a matching entry to schema.py TABLES.
For each migration-only column: add it to the relevant schema.py table DDL.
The migration functions remain unchanged (they handle existing databases). The fix is purely additive to schema.py to bring it back in sync with what migrations produce on fresh installs.
Rule going forward: Every new table or column addition must be made in both schema.py (for fresh installs) and migrations.py (for existing installs).
Generated by scheduled /validate-schema run — 2026-05-05
Automated Schema Validation Report
Date: 2026-05-05
Result: 25 critical schema drift issues —
schema.pyis incomplete relative todb/migrations.pyBackground
schema.pydeclares itself as containing "all CREATE TABLE and CREATE INDEX statements" and is referenced by Architectural Invariant #3. However, 11 tables and 14 columns that exist in running databases are absent fromschema.py. The system works correctly at runtime due to the double-pass migration pattern (migrations run before and afterinit_schema), butschema.pyis not the authoritative reference it claims to be.Critical Finding 1: 11 tables exist only in migrations (not in schema.py)
agent_notificationsagent_notificationssubscription_credentialssubscription_credentialssubscription_rate_limit_eventssubscription_rate_limit_trackingtelegram_bindingstelegram_bindingstelegram_chat_linkstelegram_bindingstelegram_group_configstelegram_group_configsslack_workspacesslack_channel_agentsslack_channel_agentsslack_channel_agentsslack_active_threadsslack_channel_agentswhatsapp_bindingswhatsapp_bindingswhatsapp_chat_linkswhatsapp_bindingsCritical Finding 2: 14 columns exist only in migrations (not in schema.py DDL)
agent_ownership(3 columns):full_capabilities INTEGER DEFAULT 0voice_system_prompt TEXT(VOICE-005)max_backlog_depth INTEGER DEFAULT 50(BACKLOG-001)agent_schedules(2 columns):webhook_token TEXT(WEBHOOK-001)webhook_enabled INTEGER DEFAULT 0(WEBHOOK-001)schedule_executions(9 columns):source_user_id INTEGER,source_user_email TEXT,source_agent_name TEXT,source_mcp_key_id TEXT,source_mcp_key_name TEXT(AUDIT-001)claude_session_id TEXT(EXEC-023)queued_at TEXT,backlog_metadata TEXT(BACKLOG-001)fan_out_id TEXT(FANOUT-001)Recommended Fix
For each migration-only table: add a matching entry to
schema.py TABLES.For each migration-only column: add it to the relevant
schema.pytable DDL.The migration functions remain unchanged (they handle existing databases). The fix is purely additive to
schema.pyto bring it back in sync with what migrations produce on fresh installs.Rule going forward: Every new table or column addition must be made in both
schema.py(for fresh installs) andmigrations.py(for existing installs).Generated by scheduled
/validate-schemarun — 2026-05-05