package httpapi

import (
	"net/http"

	"github.com/dtoro/oikos/internal/audit"
)

// serveAuditDrift returns a read-only DB-side drift report: orphan check
// entities, checks on retired targets, probes stuck down/unknown, unmonitored
// declared types, and dangling edges. Companion to the knowledge-graph-audit
// skill. Live-infra discovery (pct/docker/certs) is a follow-up.
func (s *Server) serveAuditDrift(w http.ResponseWriter, req *http.Request) {
	findings, summary := audit.Report(req.Context(), s.pool)
	writeJSON(w, map[string]any{
		"findings": findings,
		"summary":  summary,
		"note":     "read-only DB drift report; live-infra discovery (pct/docker/certs) is a follow-up",
	})
}
