How jasonmassie01/pg_sage works
pg_sage is an agentic PostgreSQL DBA that monitors one or more databases, turns collected signals into findings and ranked DBA cases, and proposes or executes guarded remediation. Its main user workflow runs from dashboard/API access through database collection, deterministic analysis and optional LLM investigation, then case review and trust-gated actions with verification. The README also documents fleet monitoring, SRE investigations, forecasting, alerting, provider adapters, and shadow mode, represented as distinct capability branches. Relationships are based on README workflow statements and the shown UI excerpts; unsampled implementation details are not asserted.
Main entry points: engine_outcome.go Guarded executor · manager.go Fleet manager · main.go Sidecar runtime · collector.go Metrics collector
Components 21
Access and fleet
- Dashboard UI
sidecar/web/src/App.jsx - REST API
sidecar/internal/api/router.go - Fleet manager
sidecar/internal/fleet/manager.go - Sidecar runtime
sidecar/cmd/pg_sage_sidecar/main.go
Database observation
- Metrics collector
sidecar/internal/collector/collector.go - Cloud adapters
sidecar/internal/cloudtel/runtime.go
Analysis and advice
- Rules and findings
sidecar/internal/analyzer/analyzer.go - DBA cases
sidecar/internal/cases/case.go - SRE investigations
sidecar/internal/sre/slo/engine.go - Query and config advice
sidecar/internal/advisor/advisor.go - LLM service
sidecar/internal/llm/manager.go
Remediation and trust
- Guarded executor
sidecar/internal/executor/engine_outcome.go - Action approvals
sidecar/internal/approvalcard/card.go - Action verification
sidecar/internal/verify/engine.go - Shadow mode
sidecar/cmd/pg_sage_sidecar/shadow_runtime.go
Operations and integrations
- Alert delivery
sidecar/internal/alerting/alerting.go - Health briefings
sidecar/internal/briefing/briefing.go - Prometheus metrics
sidecar/cmd/pg_sage_sidecar/prometheus.go
Other components
- DBA operator
- PostgreSQL
- LLM endpoint
Connections 21
- DBA operator → Dashboard UI: reviews
README.md - Dashboard UI → REST API: requests
- REST API → Sidecar runtime: serves
- Sidecar runtime → Fleet manager: monitors
- Fleet manager → Metrics collector: collects from
- Metrics collector → PostgreSQL: reads metrics
README.md - Metrics collector → Rules and findings: supplies data
README.md - Rules and findings → DBA cases: projects findings
README.md - DBA cases → SRE investigations: investigates
README.md - SRE investigations → LLM service: requests review
README.md - Query and config advice → LLM service: requests analysis
README.md - LLM service → LLM endpoint: calls endpoint
README.md - DBA cases → Guarded executor: proposes actions
README.md - Guarded executor → Action approvals: gates risky actions
README.md - Guarded executor → PostgreSQL: applies actions
README.md - Guarded executor → Action verification: verifies changes
README.md - Guarded executor → Shadow mode: reports policy outcomes
README.md - Fleet manager → Cloud adapters: uses adapters
- Rules and findings → Alert delivery: routes alerts
README.md - Fleet manager → Health briefings: summarizes health
README.md - Sidecar runtime → Prometheus metrics: exposes metrics
README.md