Repository navigation
Closed
Labels
Description
Automated Architecture Validation Report
Date: 2026-04-15
Result: 2 critical (P0-P1) violations require attention
Critical Findings (P0-P1)
Invariant 1: Three-Layer Backend (Router → Service → DB)
Raw SQL found directly in router files, bypassing the DB layer entirely:
src/backend/routers/voice.py:177-180— Directcursor.execute()with UPDATE statementsrc/backend/routers/triggers.py:254-259— Direct sqlite3 connection with SELECT/cursor.fetchall()src/backend/routers/processes.py:780-836— Direct sqlite3 connection with CREATE TABLE IF NOT EXISTS and INSERT statementssrc/backend/routers/processes.py:865-869— Direct DELETE via cursor.execute()
Fix: Move all SQL in these routers into the appropriate DB layer modules (db/processes.py, db/triggers.py, etc.). Routers should call service functions; services should call DB functions.
Invariant 3: Schema in db/schema.py, Migrations in db/migrations.py
CREATE TABLE statements found outside the centralized schema files:
src/backend/services/process_engine/services/alerts.py— 2 CREATE TABLE statementssrc/backend/services/process_engine/services/templates.py— 1 CREATE TABLE statementsrc/backend/services/process_engine/repositories/audit.py— 1 CREATE TABLE statementsrc/backend/services/process_engine/repositories/sqlite_definitions.py— 1 CREATE TABLE statement
Fix: Move all table DDL into db/schema.py and add corresponding versioned migrations to db/migrations.py. Remove ad-hoc table creation from service/repository code.
Non-Critical Findings (P2-P3, for awareness)
| Invariant | Status | Summary |
|---|---|---|
| 7: Single API Client | FAIL | ~30 raw fetch() calls in Vue components bypass api.js |
| 11: WebSocket Events for Real-Time | FAIL | 28 setInterval polling patterns in frontend instead of WebSocket |
| 15: Pydantic Models Centralized | FAIL | 29 router files define inline BaseModel subclasses instead of centralizing in models.py |
| 16: API URL Nesting Convention | FAIL | Agent-scoped routes /api/activities, /api/executions, /api/approvals, /api/triggers not nested under /api/agents/{name}/ |
Recommended Actions
- [P1] Invariant 1 — Extract SQL from
voice.py,triggers.py,processes.pyinto DB layer modules - [P1] Invariant 3 — Consolidate process engine
CREATE TABLEintodb/schema.py+ migration - [P2] Invariant 7 — Replace
fetch()calls in Vue components withapi.jscalls - [P2] Invariant 11 — Replace polling
setIntervalwith WebSocket event subscriptions - [P3] Invariant 15 — Migrate inline router models to
models.py - [P3] Invariant 16 — Evaluate API URL restructuring (breaking change — plan carefully)
Generated by scheduled /validate-architecture run
Activity
fix(voice): extract raw SQL to DB layer (Invariant 1)
fix(voice): extract raw SQL to DB layer (Invariant 1) (#353)