package ai import ( "net/http" "github.com/go-chi/chi/v5" "github.com/missionworkforce/missionmatch/internal/platform/security" ) // THE CAPTURE READINESS ROUTE, WHICH THE COMPOSITION NEVER HAD. // // answerCaptureReadiness has existed and been reachable only by ASKING FOR IT IN WORDS: the graph router // recognises a natural language question about a pursuit and dispatches to it. That is a fine way to answer // a question and a useless way to build a screen on, because a button cannot phrase a sentence and hope the // router parses the right opportunity out of it. // // The consequence was concrete and it was mine. Phase 3 stores the readiness band and win probability AS // THEY STOOD when a bid decision was made, which is the whole point of the snapshot. Nothing could fetch // them for a given pursuit, so the capture review screen offered a decision form with no numbers on it and // every decision it recorded snapshotted NULL. The record existed and the thing it was supposed to record // against did not reach it. // // This is a READ of the same composition, on the same capability as the brain query, returning the score, // the band and the ordered factor contributions. It computes no per candidate score and it is not an // employment decision number; the frozen engine remains the only per candidate scorer. func (h *Handler) CaptureRoutes(r chi.Router) { r.With(security.RequireCapability(security.CapBrainQuery)). Get("/ai/capture-readiness/{opportunityID}", h.captureReadiness) } func (h *Handler) captureReadiness(w http.ResponseWriter, r *http.Request) { if h.orch == nil { // The graceful posture the rest of this module takes when the inference plane is unconfigured: // report unavailable rather than pretend, and never invent a number. writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "the brain is not configured on this node"}) return } id := chi.URLParam(r, "opportunityID") if id == "" { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "an opportunity id is required"}) return } resp, err := h.orch.answerCaptureReadiness(r.Context(), id) if err != nil { // A pursuit in another organization is invisible under RLS and reports as not found, which is the // correct disclosure: it does not exist FOR YOU. writeJSON(w, http.StatusNotFound, map[string]string{"error": "that pursuit has no readiness to report"}) return } writeJSON(w, http.StatusOK, resp) }