Serve API

The read-only JSON surface of pgdba serve.

pgdba serve listens on 127.0.0.1:8420 by default. Every response is JSON (Content-Type: application/json); unknown paths and targets 404 with {"error": ...}; only GET exists (anything else is 405).

GET /health

Liveness plus the server version:

{"ok": true, "version": "0.1.0"}

GET /targets

Configured targets with their latest run (nulls when never run):

[{"name": "prod", "last_exit_code": 1, "last_ts": "2026-09-09T00:00:00+00:00"}]

GET /targets/<name>/report

The target’s latest full pgdba-report.json, byte for byte. Unknown targets 404; known targets with no run yet 404 with a no report ... yet error.

GET /targets/<name>/history

The target’s rotating run journal (newest last, at most 100 entries):

{"target": "prod", "runs": [{"run_id": "abc", "exit_code": 1, "ts": "..."}]}

GET /summary

Fleet-style aggregate over the latest stored reports: per-target grades and counts, fleet_common (findings on strictly more than half of the reachable targets) vs target_specific, and the worst exit code. Targets that never ran list under broken with error "never run" and do not move the exit code.