Repository navigation
Description
Automated Schema Validation Report
Date: 2026-04-27
Result: 20 critical (P0-P1) schema drift issues require attention
Critical Findings (P0)
1. process_schedules — Ad-hoc CREATE TABLE in router (routers/processes.py:781)
A process_schedules table is created directly inside a router function against the main trinity.db, with no entry in db/schema.py or db/migrations.py. This violates Architectural Invariant #3 and means the table is invisible to schema management tooling. Fresh installs only get this table if the process scheduling code path is hit.
2. subscription_credentials — FK in schema.py with no DDL definition
agent_ownership in schema.py declares FOREIGN KEY (subscription_id) REFERENCES subscription_credentials(id), but subscription_credentials has no DDL in schema.py. Its table definition only exists in migration subscription_credentials. The schema works today only because the migration runs before init_schema() — an undocumented fragile ordering dependency.
Critical Findings (P1)
3. 12 Columns Missing from schema.py DDL
agent_ownership — 3 columns added by migrations, absent from schema.py:
| Column | Migration |
|---|---|
full_capabilities INTEGER DEFAULT 0 |
agent_ownership_full_capabilities |
max_backlog_depth INTEGER DEFAULT 50 |
backlog_support |
voice_system_prompt TEXT |
agent_ownership_voice_prompt |
schedule_executions — 9 columns added by migrations, absent from schema.py:
| Column | Migration |
|---|---|
source_user_id INTEGER |
execution_origin_tracking |
source_user_email TEXT |
execution_origin_tracking |
source_agent_name TEXT |
execution_origin_tracking |
source_mcp_key_id TEXT |
execution_origin_tracking |
source_mcp_key_name TEXT |
execution_origin_tracking |
claude_session_id TEXT |
execution_session_tracking |
fan_out_id TEXT |
execution_fan_out_id |
queued_at TEXT |
backlog_support |
backlog_metadata TEXT |
backlog_support |
schema.py no longer reflects the actual live table structure. Reading it gives an incomplete picture of both tables.
4. 9 Tables Exist Only in Migrations (not in schema.py)
| Table | Migration |
|---|---|
agent_notifications |
agent_notifications |
subscription_credentials |
subscription_credentials |
subscription_rate_limit_events |
subscription_rate_limit_tracking |
slack_workspaces |
slack_channel_agents |
slack_channel_agents |
slack_channel_agents |
slack_active_threads |
slack_channel_agents |
telegram_bindings |
telegram_bindings |
telegram_chat_links |
telegram_bindings |
telegram_group_configs |
telegram_group_configs |
These are major functional tables (Slack, Telegram, notifications, subscriptions) with no DDL in the authoritative schema file.
5. Process Engine — 7 Tables Created Ad-hoc Outside Schema System
The Process Engine uses a separate trinity_processes.db file and creates all its tables inline in repository/service constructors — bypassing schema.py and migrations.py entirely:
| File | Tables |
|---|---|
services/process_engine/repositories/sqlite_definitions.py |
process_definitions |
services/process_engine/repositories/sqlite_executions.py |
process_executions, step_executions |
services/process_engine/repositories/sqlite_events.py |
execution_events |
services/process_engine/repositories/audit.py |
audit_entries |
services/process_engine/services/templates.py |
process_templates |
services/process_engine/services/alerts.py |
cost_thresholds, cost_alerts |
Note: architecture.md documents process_definitions, process_executions, process_step_executions, and process_approvals as if they are in the main SQLite database — this is incorrect; they live in trinity_processes.db.
Recommended Actions (Prioritized)
-
[P0] Move
process_schedulesintoschema.pyand add a migration — Remove theCREATE TABLEfromrouters/processes.pyand add proper DDL. -
[P0] Add
subscription_credentialsDDL toschema.py— Break the undocumented ordering dependency. Add the full table definition alongside other core tables. -
[P1] Backfill schema.py with missing columns — Add all 12 migration-only columns to the
agent_ownershipandschedule_executionsDDL inschema.pyso the file reflects reality. -
[P1] Add 9 migration-only tables to schema.py —
agent_notifications,slack_workspaces,slack_channel_agents,slack_active_threads,telegram_bindings,telegram_chat_links,telegram_group_configs,subscription_rate_limit_events. -
[P1] Decide on Process Engine database strategy — Either: (a) migrate Process Engine tables into the main schema system with proper DDL/migrations, or (b) document the separate-DB approach explicitly in
architecture.mdand add schema management within the process engine directory. Either way, updatearchitecture.mdto reflect the actual database location.
Generated by scheduled /validate-schema run on 2026-04-27
Activity
pavshulin commentedon May 1, 2026
Superseded by today's daily reports: #603 (architecture), #604 (schema), #605 (config). Closing to keep the latest snapshot canonical.