You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor: split db/schedules.py and replace 15+ param insert signatures with request objects #1027
The DB layer has two structural smells flagged critical/high by a /refactor-audit scan (2026-06-02): an oversized domain file (db/schedules.py, 1,987 logical lines with 26 long functions) and several insert/delegating signatures with 15–16 positional parameters that should take a request object.
Context
db/schedules.py is the second-worst hotspot (38 findings). The wide signatures (database.py, db/sessions.py, db/chat.py) make call sites fragile — positional-argument mistakes are easy and invisible in review. Both follow the class-per-domain DB pattern (Invariant #2), so the splits are mechanical.
Findings (critical/high)
Oversized DB file:
src/backend/db/schedules.py — 1,987 logical lines, 26 long functions, 6 high-complexity
Too many parameters (≥15):
Params
Location
16
src/backend/database.py:982 (delegating method)
16
src/backend/db/sessions.py:138 (session insert)
15
src/backend/database.py:933 (delegating method)
15
src/backend/db/chat.py:106 (chat-message insert)
Acceptance Criteria
db/schedules.py split into focused modules (e.g. schedules_crud / schedule_executions / schedule_webhooks) composed per Invariant Feature/gemini runtime support #2
The 15–16 param insert paths (db/sessions.py, db/chat.py) take a dataclass/Pydantic request object instead of positional args
database.py facade delegating methods updated to match (the facade itself may remain)
No schema change; no behavior change — /test-runner green
/validate-schema and /validate-architecture pass after the split
Technical Notes
Pairs with the orchestration issue: a TaskExecutionRequest model would simplify both execute_task(...) (25 params) and these insert call sites.
Keep all DDL in db/schema.py and migrations in db/migrations.py (Invariant Feature/vector log retention #3) — this is a code-organization refactor, not a schema change.
db/migrations.py (1,998 lines) and db/schema.py (1,123 lines) are intentionally append-only/constant stores — out of scope here.
Activity
refactor(db): SessionMessageInsert request object for add_session_mes…
feat(model): the door serves a reasoning caller's schema-constrained …
feat(model): the door serves a reasoning caller's schema-constrained …
fix(model): a failed call reports the model it asked for (#1027)
feat(model): the door serves a reasoning caller's schema-constrained …
fix(model): a failed call reports the model it asked for (#1027)
feat(model): the door serves a reasoning caller's schema-constrained …
fix(model): a failed call reports the model it asked for (#1027)
feat(model): the door serves a reasoning caller's schema-constrained …
fix(model): a failed call reports the model it asked for (#1027)
feat(model): the door serves a reasoning caller's schema-constrained …
fix(model): a failed call reports the model it asked for (#1027)
feat(model): the door serves a reasoning caller's schema-constrained …
fix(model): a failed call reports the model it asked for (#1027)