From d75a231d8865d9b14fbe3d608c9aa1bffb7ed386 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 16 Mar 2026 04:24:19 +0000 Subject: feat: add deployment status endpoint for tasks Adds GET /api/tasks/{id}/deployment-status which checks whether the currently-deployed server binary includes the fix commits from the task's latest execution. Uses git merge-base --is-ancestor to compare commit hashes against the running version. Co-Authored-By: Claude Sonnet 4.6 --- internal/api/deployment.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 internal/api/deployment.go (limited to 'internal/api/deployment.go') diff --git a/internal/api/deployment.go b/internal/api/deployment.go new file mode 100644 index 0000000..d927545 --- /dev/null +++ b/internal/api/deployment.go @@ -0,0 +1,36 @@ +package api + +import ( + "database/sql" + "net/http" + + "github.com/thepeterstone/claudomator/internal/deployment" +) + +// handleGetDeploymentStatus returns whether the currently-deployed server +// includes the commits that were produced by this task's latest execution. +// GET /api/tasks/{id}/deployment-status +func (s *Server) handleGetDeploymentStatus(w http.ResponseWriter, r *http.Request) { + id := r.PathValue("id") + + tk, err := s.store.GetTask(id) + if err != nil { + writeJSON(w, http.StatusNotFound, map[string]string{"error": "task not found"}) + return + } + + exec, err := s.store.GetLatestExecution(tk.ID) + if err != nil { + if err == sql.ErrNoRows { + // No execution yet — return status with no fix commits. + status := deployment.Check(nil, tk.Agent.ProjectDir) + writeJSON(w, http.StatusOK, status) + return + } + writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()}) + return + } + + status := deployment.Check(exec.Commits, tk.Agent.ProjectDir) + writeJSON(w, http.StatusOK, status) +} -- cgit v1.2.3