Files
Agent-System-Backend/internal/server/task_sources.go
T
weichen 13e880feec Publish validated material findings during background work
Why: Real source-backed discoveries should reach the same task card before the slow channel completes.

Evidence: SELF receipts record runtime and manager checkpoint red-green tests, scoped source/version checks, privacy filtering, quota corrections, and SQLite/PG regressions; fixed composition and live comparison follow.

Impact: Adds a local material-only checkpoint sink with no summary model calls, uses version witnesses for source commits, and preserves existing reading and notification paths.

Refs: fast-slow-u2-u3 Tasks 6 and 7; test-only live HTTP harness bounds shared provider requests without approving HITL
2026-10-13 02:29:23 +00:00

55 lines
1.2 KiB
Go

package server
import (
core "agent-system-core"
"crypto/sha256"
"encoding/hex"
"net/http"
)
func (s *Server) taskSource(w http.ResponseWriter, r *http.Request) {
owner := s.owner(r)
c, e := s.st.GetCard(owner, r.PathValue("id"))
if e != nil || c.Task == nil {
http.NotFound(w, r)
return
}
if _, e = s.st.GetConversation(owner, c.ConversationID); e != nil {
http.NotFound(w, r)
return
}
var ref *core.TaskSourceRef
for _, f := range c.Task.Findings {
for _, src := range f.Sources {
if src.ID == r.PathValue("sourceId") {
copy := src
ref = &copy
break
}
}
}
if ref == nil {
http.NotFound(w, r)
return
}
art, e := s.st.GetArtifact(owner, ref.ArtifactID)
if e != nil || art.ProjectID != c.ProjectID {
http.NotFound(w, r)
return
}
data, e := s.st.ArtifactContent(owner, ref.ArtifactID)
if e != nil {
http.NotFound(w, r)
return
}
sum := sha256.Sum256(data)
state := "current"
if hex.EncodeToString(sum[:]) != ref.ContentHash {
state = "changed"
ref.Availability = "changed"
} else {
ref.Availability = "available"
}
writeJSONOr(w, map[string]any{"source": ref, "versionState": state, "artifact": art}, nil)
}