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)
- 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.
- Sync missing tables: Add the 9 migration-only tables into
db/schema.py.
- 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
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.routers/processes.py:781process_schedulesservices/process_engine/services/templates.py:117process_templatesservices/process_engine/services/alerts.py:163cost_thresholdsservices/process_engine/services/alerts.py:178cost_alertsFix: Add these 4 tables to
db/schema.pyTABLES dict and add corresponding entries todb/migrations.pyfor existing installs. Remove inlineCREATE TABLEfrom 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, butschema.pyis supposed to be the authoritative DDL.agent_notificationssubscription_credentialssubscription_rate_limit_eventsslack_workspacesslack_channel_agentsslack_active_threadstelegram_bindingstelegram_chat_linkstelegram_group_configsFix: Add all 9 tables to
db/schema.pyTABLES 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 0max_backlog_depth INTEGER DEFAULT 50voice_system_prompt TEXTschedule_executions(9 missing):source_user_id,source_user_email,source_agent_name,source_mcp_key_id,source_mcp_key_nameclaude_session_idqueued_at,backlog_metadatafan_out_idFix: Add these 12 columns to the respective CREATE TABLE statements in
db/schema.py.Recommended Actions (Priority Order)
process_schedules,process_templates,cost_thresholds,cost_alertsintodb/schema.py+ add migrations. Remove inline DDL from service code.db/schema.py.agent_ownershipandschedule_executionsDDL indb/schema.pywith the 12 missing columns.Generated by scheduled /validate-schema run