Skip to content

Architecture Validation: 2 critical violations found (Invariants 1 & 3) #351

Closed

Description

@vybe

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 — Direct cursor.execute() with UPDATE statement
  • src/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 statements
  • src/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 statements
  • src/backend/services/process_engine/services/templates.py — 1 CREATE TABLE statement
  • src/backend/services/process_engine/repositories/audit.py — 1 CREATE TABLE statement
  • src/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

  1. [P1] Invariant 1 — Extract SQL from voice.py, triggers.py, processes.py into DB layer modules
  2. [P1] Invariant 3 — Consolidate process engine CREATE TABLE into db/schema.py + migration
  3. [P2] Invariant 7 — Replace fetch() calls in Vue components with api.js calls
  4. [P2] Invariant 11 — Replace polling setInterval with WebSocket event subscriptions
  5. [P3] Invariant 15 — Migrate inline router models to models.py
  6. [P3] Invariant 16 — Evaluate API URL restructuring (breaking change — plan carefully)

Generated by scheduled /validate-architecture run

Activity

  1. added
    priority-p1
    type-bug
    status-in-progress
    on Apr 15, 2026
  2. removed
    status-in-progress
    on Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-p1type-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions