- ApprovalService (core/app/approval.go) + ApprovalRepo (postgres adapter) with
full decide transaction: HMAC token verify, approval flip, execution un-gate,
session-scoped window keys (+session suffix matching GovernanceStore gate),
nomos session flip, audit+event on failure abort. httpapi DecideApproval now
a thin presenter delegating to the service. ListPending payload format fixed
(json.Unmarshal not raw-wrap).
- execlog folded into postgres adapter: internal/execlog deleted, NewExecutionLog
/ ReadExecutionLog live in the db package, callers updated (mcp, httpapi).
- execworker poller over ExecutionService.DispatchQueued: advisory lock leak
fixed (defer/recover per execution), correlation_id preserved via Finalize
event emission (ExecRunRepo.Finalize now emits execution.{status} with
correlation_id from the row).
- Phase 8 session export-rename completed: Store, New, and all 53 methods
exported; cmd/nomos/ agent.go fixed to use session.PendingContinuation etc.
- Coverage gates: ExecutionService.Submit 93.1%, PolicyService.Decide 100%.
- Plans index updated, VERSION bumped to 0.36.0.
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/dtoro/oikos/internal/adapters/postgres"
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// serveExecutionLogs returns an execution's streamed command output.
|
|
//
|
|
// Registered as a carve-out rather than through the OpenAPI codegen for the
|
|
// same reason as /activity/recent: it is a recency-ordered projection with no
|
|
// schema type yet. Without this the execution_logs rows would be write-only —
|
|
// which is the exact shape of the bugs this whole change set has been about.
|
|
func (s *Server) serveExecutionLogs(w http.ResponseWriter, req *http.Request) {
|
|
ctx := req.Context()
|
|
|
|
rawID := chi.URLParam(req, "id")
|
|
execID, err := uuid.Parse(rawID)
|
|
if err != nil {
|
|
writeProblem(w, req, http.StatusBadRequest, "invalid execution id", rawID)
|
|
return
|
|
}
|
|
|
|
limit := 1000
|
|
if l := req.URL.Query().Get("limit"); l != "" {
|
|
if n, perr := strconv.Atoi(l); perr == nil && n > 0 && n <= 5000 {
|
|
limit = n
|
|
}
|
|
}
|
|
|
|
chunks, err := db.ReadExecutionLog(ctx, s.pool, execID, limit)
|
|
if err != nil {
|
|
writeProblem(w, req, http.StatusInternalServerError, "query failed", err.Error())
|
|
return
|
|
}
|
|
|
|
// Also hand back the concatenation, since that is what a caller tailing
|
|
// output actually wants to render.
|
|
var combined strings.Builder
|
|
for _, c := range chunks {
|
|
combined.WriteString(c.Chunk)
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
|
"items": chunks,
|
|
"combined": combined.String(),
|
|
})
|
|
}
|