Draft

lathe — SRE Investigation Bot

Internalactive

Internal SRE and bug-investigation bot. SREs invoke it from Slack (@lathe mentions or DMs); a per-invocation Explorer coroutine runs an LLM-driven tool loop, accumulates structured Findings inside a polymorphic Artifact (BugReport), and replies in-thread.

flowchart LR
    SLACK["Slack
@lathe mention"] --> API[lathe
FastAPI · Fargate] API --> EXPLORER["Explorer
LLM tool loop"] EXPLORER --> TOOLS["Tool set
repo / logs / alerts"] EXPLORER --> ARTIFACT["Artifact
BugReport + Findings"] API --> DB[(RDS Postgres
users · runs · artifacts)] API --> SLACK style API fill:#EDEDFF,stroke:#3B54F7 style EXPLORER fill:#F3EDFF,stroke:#8A54E8

Architecture (two patterns coexisting):

  • Pattern A — CRUD state: SQLModel rows, FastAPI routes — Users, ApiTokens, Artifacts, Findings, Repos, RepoSnapshots.

  • Pattern B′ — Background tasks with event-log persistence: async run coroutines (lathe/runs/), tools (lathe/tools/), append-only investigation_event log for crash-survival replay/resume.

  • Stack: Python 3.12+, FastAPI, asyncio, structlog, SQLModel + asyncpg + Alembic, pytest, uv.

  • Deployed on: AWS Fargate behind an ALB; persistence on RDS Postgres.

  • Built on: the ecs-service pattern.

  • Dev: uv sync --extra devuv run ruff check + uv run mypy --strict lathe/ + uv run pytest.