Skip to content

Architecture

Slack (Socket Mode)
  ├─ @mention  → ReAct agent (LangGraph + pluggable LLM) → guardrails → kubectl
  └─ buttons   → signed-payload verifier → guardrails → kubectl

Kubernetes (any cluster: EKS / GKE / AKS / kind / k3s / on-prem)
  └─ pod watcher (kubernetes_asyncio)
        → on restart: --previous logs + events
        → LLM diagnosis (+ past outcomes)
        → Block Kit alert card to Slack

Components (src/)

File Responsibility
main.py asyncio entrypoint; restart consumer; card lifecycle (regression/resolve/evict)
agent.py LangGraph ReAct agent + checkpointer
slack_handler.py @mention handler
button_handler.py Apply / Skip / Investigate / Run diagnostics / overflow (mute)
analyzer.py LLM diagnosis; controller resolution; arg flattening
proactive_poster.py Block Kit restart card builder
audit.py AuditLogger + 5-min digest buffer
outcomes.py learning-loop store (sqlite/postgres)
selftest.py @karakuri selftest
metrics.py Prometheus exporter
signing.py HMAC signing/verification of button payloads
slack_format.py markdown → Slack mrkdwn
rate_limit.py per-user token bucket
config.py typed settings
llm.py provider factory (groq/openrouter/openai) with retry/backoff
tools/ kubectl runner + read/write tools + guardrails
watchers/ pod_watcher + resource analyzers + prom_watcher (PromQL rules) + dedup/mute + event_bus

Proactive alert flow

  1. pod_watcher detects a restart → emits a RestartEvent on the bus
  2. consumer (_consume_restarts): skip if muted; resolve the owning controller; dedup by controller — if an active card exists, update it in place and stop (no new card, no extra LLM call); otherwise:
  3. skeleton card posts immediately: what broke, where, and that the diagnosis is running. Button-free, because the buttons carry a signed diagnosis_id that does not exist yet. The diagnosis then runs as a task bounded by a semaphore, so one slow incident no longer delays every other one
  4. analyzer fetches --previous logs + events, injects top-3 past outcomes, asks the LLM for {root_cause, fix_kubectl_cmd, confidence, explanation}
  5. proactive_poster builds a Block Kit card; the consumer chat_updates the skeleton into it and records lookup. A diagnosis that fails moves the same card to a needs-triage state instead of leaving it on "in progress"
  6. Buttons drive the lifecycle: Detected → Fix applied → Resolved (auto) / Regressed

The in-memory lookup is bounded — terminal entries are evicted after a retention window, with a hard size cap.

Safety model

Every cluster-mutating path passes through guardrails, and every Apply runs a server-side dry-run preview before the real command. See the Guardrails table in the README and SECURITY.md.

Persistence

  • Checkpointer — LangGraph conversation state (sqlite via AsyncSqliteSaver, or Postgres via an AsyncConnectionPool)
  • Outcomes — apply/skip history feeding future diagnoses

Design docs

The original spec and implementation plan live in docs/superpowers/.