Files
archie/internal/webui/api_curators.go
T
sam da28ddb5e6 refactor(ui): sever the archie-ui binary from every daemon runtime package
Completes the objective deletion gate for the UI Service
(archie-core-8cda.5.6): go list -deps ./cmd/archie-ui now links zero
banned packages -- no modernc.org/sqlite, no internal/store, gateway,
channels, memory, secret, agentexec, tools, skill, yaegiutil, curator,
or the workflow engine. The closure shrinks from 68 to 26 archie-core
packages. Each cut is a producer-side move; no consumer-side defensive
shims.

- Store contracts (TaskStore family, value types, sentinels) moved from
  internal/store to internal/domain/storecontract -- the approved contract
  location per state-store-contract rev. 2d, and NOT internal/contracts:
  that tree is buf generate output and tools/proto.sh check deletes
  hand-written files there. internal/store keeps aliases; sentinel
  message strings are byte-identical and remain the wire contract.
- Chat contracts (ChatContract, sessions, turns, streaming, commands)
  moved from internal/gateway to internal/domain/messaging; gateway keeps
  aliases. ToolCallEvent rendering helpers become gateway functions
  (methods cannot live on alias types).
- Task vocabulary (Task, statuses, mid-run Store, Definition) split into
  internal/domain/workflow/task; the pipeline engine stays in package
  workflow with aliases, so daemon-side callers are unchanged.
- overlay.DeniedKeys moved to internal/infrastructure/configuration:
  webui referenced the constant and that dragged the overlay SQLite
  store in.
- webui.Server's concrete runtime handles become webui-owned view
  interfaces with daemon-side bootstrap adapters: channel lifecycle
  (internal/channels/status), MemoryStatus, CuratorStatus, and a
  SkillCatalog seam replacing the direct skill.DefaultRoots/CatalogRoots
  calls. Each degrades to an empty page when unwired.
- config.SecretRef moved into internal/config (config vocabulary);
  internal/secret keeps an alias and Registry.Resolve absorbs the
  zero-value short-circuit.

Docs: state-store-contract rev. 2d relocation record; ui-service-boundary
deletion gate marked satisfied; ARCHITECTURE.md package map rows.
2026-09-10 03:03:33 +10:00

104 lines
3.4 KiB
Go

package webui
import (
"context"
"net/http"
"time"
)
// CuratorActionView is one recorded curator action, as shown on the
// dashboard's curator activity view: what changed and why.
type CuratorActionView struct {
At time.Time `json:"at"`
Type string `json:"type"`
Detail string `json:"detail"`
Reason string `json:"reason"`
}
// CuratorStatus is the webui-owned surface over the running curator
// registry: the names, point-in-time health, and recent activity the
// dashboard's curator view renders. It is deliberately narrower than the
// registry itself -- whose engine contract drags in the agent toolchain --
// so the UI process holds the view without linking it
// (archie-core-8cda.5.6). Whoever owns the registry supplies an adapter at
// bootstrap.
type CuratorStatus interface {
Names() []string
Health(ctx context.Context) map[string]CuratorHealthView
Activity(name string) (CuratorActivity, bool)
}
// CuratorActivity is one curator's recent run history, as the webui
// renders it.
type CuratorActivity struct {
LastRunAt time.Time
LastRunActions int
Recent []CuratorActionView
}
// CuratorView is one registered curator's observable state: identity,
// health, and recent activity. Backed by CuratorStatus -- see
// handleCurators.
type CuratorView struct {
Name string `json:"name"`
Health CuratorHealthView `json:"health"`
// LastRunAt is a pointer so a curator that has never run omits the
// field entirely instead of serializing time.Time's zero value
// ("0001-01-01T00:00:00Z") -- json's "omitempty" does not treat a
// zero-valued struct as empty, and a non-empty string is truthy to
// the dashboard's "has this run yet" check.
LastRunAt *time.Time `json:"last_run_at,omitempty"`
LastRunActions int `json:"last_run_actions"`
RecentActions []CuratorActionView `json:"recent_actions"`
}
// CuratorHealthView mirrors curator.Health for the wire.
type CuratorHealthView struct {
Status string `json:"status"`
Message string `json:"message,omitempty"`
}
// handleCurators reports which curators are registered, their point-in-time
// health, and their recent activity -- which curators exist, when each last
// ran, what it changed, and why (archie-core-1786637489932-6). The registry
// is the sole source of truth; this handler is transport only.
func (s *Server) handleCurators(w http.ResponseWriter, r *http.Request) {
if s.Curators == nil {
writeJSON(w, map[string]any{"curators": []CuratorView{}})
return
}
names := s.Curators.Names()
health := s.Curators.Health(r.Context())
views := make([]CuratorView, 0, len(names))
for _, name := range names {
h := health[name]
view := CuratorView{
Name: name,
Health: CuratorHealthView{
Status: h.Status,
Message: h.Message,
},
RecentActions: []CuratorActionView{},
}
if activity, ok := s.Curators.Activity(name); ok && !activity.LastRunAt.IsZero() {
at := activity.LastRunAt
view.LastRunAt = &at
view.LastRunActions = activity.LastRunActions
view.RecentActions = make([]CuratorActionView, 0, len(activity.Recent))
for _, a := range activity.Recent {
view.RecentActions = append(view.RecentActions, CuratorActionView{
At: a.At,
Type: a.Type,
Detail: a.Detail,
Reason: a.Reason,
})
}
}
views = append(views, view)
}
writeJSON(w, map[string]any{"curators": views})
}