[chat] builtin_actions.py uses raw SQLite while project uses SQLAlchemy ORM #732

Closed
opened 2026-06-03 00:09:28 +02:00 by sleepy · 0 comments
Owner

Problem

src/builtin_actions.py uses raw sqlite3 connections and SQL strings in multiple places:

  • Line 787-791: sqlite3.connect(SCHEDULED_DB) with raw SELECT message_id FROM email_boundaries
  • Line 899-907: Raw INSERT OR REPLACE INTO email_boundaries via c.execute()
  • Line 997-999: Raw SELECT from_address, last_built_at FROM sender_signatures
  • Line 1108: Raw SQL execution
  • Lines 1946-1976: Raw SQLite operations

The project uses SQLAlchemy ORM throughout (core/database.py defines all models). The SCHEDULED_DB is a separate SQLite database, but even so, using raw SQL when the project has an ORM pattern is a violation.

AGENTS.md violations

  • No raw SQL when project uses an ORM

Suggested fix

  1. Define SQLAlchemy models for email_boundaries and sender_signatures tables
  2. Use the standard SessionLocal() pattern for database access
  3. If SCHEDULED_DB must remain separate, at minimum use parameterized queries consistently and wrap in a repository pattern
## Problem `src/builtin_actions.py` uses raw `sqlite3` connections and SQL strings in multiple places: - Line 787-791: `sqlite3.connect(SCHEDULED_DB)` with raw `SELECT message_id FROM email_boundaries` - Line 899-907: Raw `INSERT OR REPLACE INTO email_boundaries` via `c.execute()` - Line 997-999: Raw `SELECT from_address, last_built_at FROM sender_signatures` - Line 1108: Raw SQL execution - Lines 1946-1976: Raw SQLite operations The project uses SQLAlchemy ORM throughout (`core/database.py` defines all models). The `SCHEDULED_DB` is a separate SQLite database, but even so, using raw SQL when the project has an ORM pattern is a violation. ## AGENTS.md violations - **No raw SQL when project uses an ORM** ## Suggested fix 1. Define SQLAlchemy models for `email_boundaries` and `sender_signatures` tables 2. Use the standard `SessionLocal()` pattern for database access 3. If `SCHEDULED_DB` must remain separate, at minimum use parameterized queries consistently and wrap in a repository pattern
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sleepy/odysseus#732
No description provided.