Files
cleveragents-core/tools/controller/db/__init__.py
T
drew 0bc734c020 style: ruff format the controller-state-machine branch (288 files)
Applies `ruff format` to the accumulated formatting debt on this branch.
Formatting-only — no behavioral changes. Required for CI/lint's format
gate (`nox -s format -- --check`), which the branch was failing on 288
tracked files that drifted from ruff's canonical style.

In-progress WIP files are intentionally excluded so this commit stays a
clean formatting-only diff.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 00:09:17 -04:00

60 lines
1.3 KiB
Python

"""Controller DB layer.
SQLAlchemy 2.0 declarative schema for the workflows, attempts,
events, flake-history, and ci-observations tables. The same schema
serves SQLite (tests + local dev) and Postgres (production; multi-
machine workers per plan v5).
The DB connection is configured by ``CLEVERAGENTS_DB_URL``:
postgresql+psycopg2://user@host:5432/cleveragents
sqlite:///./controller.db
sqlite:///:memory: (tests)
The dequeue helper (``dequeue.py``) abstracts over the two dialects'
different concurrency primitives:
- Postgres: ``SELECT … FOR UPDATE SKIP LOCKED``
- SQLite: ``BEGIN IMMEDIATE`` + serialized UPDATE
"""
from .models import (
Base,
CIObservation,
ControllerEvent,
FlakeHistory,
Workflow,
WorkflowAttempt,
)
from .session import (
build_engine,
create_all,
session_scope,
)
from .dequeue import (
DequeueResult,
dequeue_one,
)
from .payload_guard import (
PayloadTooLargeError,
enforce_input_payload_size,
)
__all__ = [
# models
"Base",
"CIObservation",
"ControllerEvent",
"FlakeHistory",
"Workflow",
"WorkflowAttempt",
# session
"build_engine",
"create_all",
"session_scope",
# dequeue
"DequeueResult",
"dequeue_one",
# payload guard
"PayloadTooLargeError",
"enforce_input_payload_size",
]