mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-28 02:40:53 +08:00
32 lines
816 B
Go
32 lines
816 B
Go
package server
|
|
|
|
import (
|
|
"database/sql"
|
|
"errors"
|
|
"log/slog"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
// taskOutcome returns one task's production and cost baseline. It is the
|
|
// measurement layer for later RSI comparisons (harness2, Google Research,
|
|
// arXiv 2610.14224): nothing here changes agent behavior.
|
|
func (s *Server) taskOutcome(w http.ResponseWriter, r *http.Request) {
|
|
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
|
if err != nil || id <= 0 {
|
|
writeErr(w, 400, "invalid task id")
|
|
return
|
|
}
|
|
outcome, err := s.m.PG().TaskOutcome(r.Context(), id)
|
|
if errors.Is(err, sql.ErrNoRows) {
|
|
writeErr(w, 404, "task not found")
|
|
return
|
|
}
|
|
if err != nil {
|
|
slog.Error("[tasks] outcome query failed", "task_id", id, "err", err)
|
|
writeErr(w, 500, "outcome query failed")
|
|
return
|
|
}
|
|
writeJSON(w, 200, outcome)
|
|
}
|