Repository navigation
Description
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:
- Invariant Feature/vector log retentionΒ #3: All DDL must live in
db/schema.py, changes viadb/migrations.py - Invariant Fix: Add missing Docker labels to system agent containerΒ #1: Routers must hold no business logic (no direct DB connections)
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
- Immediately: Add the 9 missing tables to
schema.pyTABLES dict (low-risk, cosmetic) - Immediately: Add the 12 missing columns to the
agent_ownershipandschedule_executionsDDL inschema.py(low-risk, cosmetic) - Next sprint: Refactor
process_schedulesout of the router and intodb/schema.py+ a proper migration (requires small refactor)
Generated by scheduled /validate-schema run
Activity
vybe commentedon May 5, 2026
Closing as duplicate of #655 (Schema validation). The daily validation process should update a single tracking issue rather than creating new ones each run.