Skip to content

chore: extract shared service methods into SQLiteStore (AC-480)#591

Merged
jayscambler merged 2 commits intomainfrom
chore/extract-service-layer
Mar 31, 2026
Merged

chore: extract shared service methods into SQLiteStore (AC-480)#591
jayscambler merged 2 commits intomainfrom
chore/extract-service-layer

Conversation

@jayscambler
Copy link
Copy Markdown
Contributor

Summary

Added list_runs(), run_status(), and list_solved() service methods to SQLiteStore, then updated 4 consumers to delegate instead of duplicating raw SQL.

Problem

The same "list recent runs" SQL query was duplicated in 4 places:

  • cli.pylist_runs command
  • mcp/knowledge_tools.pylist_runs() tool
  • server/cockpit_api.py/api/runs endpoint
  • server/app.py — WebSocket dashboard endpoint

Each had slightly different LIMIT values and column selections but identical intent.

Changes

New service methods on SQLiteStore

def list_runs(self, *, limit: int = 50) -> list[dict[str, Any]]
def run_status(self, run_id: str) -> list[dict[str, Any]]
def list_solved(self) -> list[dict[str, Any]]

Updated consumers

  • cli.py: store.list_runs(limit=20) replaces raw SQL
  • mcp/knowledge_tools.py: ctx.sqlite.list_runs(limit=20) replaces raw SQL
  • server/app.py: store.list_runs(limit=50) and store.run_status(run_id) replace raw SQL
  • server/cockpit_api.py: store.list_runs(limit=50) replaces raw SQL (enrichment loop kept)

TDD

Added test_service_layer.py with 7 tests covering empty, populated, and limit scenarios.

Verification

  • ruff check src — all checks passed
  • mypy src — zero errors
  • pytest tests/ — all tests pass

Issue

Partially resolves AC-480

Added list_runs(), run_status(), list_solved() to SQLiteStore so
CLI, MCP tools, and HTTP endpoints delegate instead of duplicating
raw SQL queries.

Consumers updated:
- cli.py: list_runs command now uses store.list_runs()
- mcp/knowledge_tools.py: list_runs() delegates to store
- server/app.py: list_runs() and run_status() delegate to store
- server/cockpit_api.py: list_runs() uses store.list_runs()

TDD: Added test_service_layer.py with 7 tests for the new methods.

7 files changed, 114 insertions, 33 deletions
@linear
Copy link
Copy Markdown

linear bot commented Mar 31, 2026

@jayscambler jayscambler merged commit d783b55 into main Mar 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant