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.
This commit is contained in:
sam committed 2026-09-10 03:03:33 +10:00
1 parent 3699f51f9b
commit da28ddb5e6
84 files changed
+1492 -1053

No files matched your search

+8 -8
View File
@@ -6,8 +6,8 @@ import (
"net/http"
"strconv"
storev1 "github.com/samcharles93/archie-core/internal/contracts/store/v1"
"github.com/samcharles93/archie-core/internal/domain/binding"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
)
// bindingRequest is the wire shape POST /api/bindings and
@@ -72,7 +72,7 @@ func (s *Server) handleBindingCreate(w http.ResponseWriter, r *http.Request) {
}
id, err := s.Bindings.InsertBinding(r.Context(), b)
if err != nil {
if errors.Is(err, storev1.ErrBindingOverlap) {
if errors.Is(err, storecontract.ErrBindingOverlap) {
http.Error(w, "binding source overlaps an existing binding", http.StatusConflict)
return
}
@@ -150,9 +150,9 @@ func (s *Server) handleBindingUpdate(w http.ResponseWriter, r *http.Request) {
}
if err := s.Bindings.UpdateBinding(r.Context(), b); err != nil {
switch {
case errors.Is(err, storev1.ErrBindingNotFound):
case errors.Is(err, storecontract.ErrBindingNotFound):
http.Error(w, "binding not found", http.StatusNotFound)
case errors.Is(err, storev1.ErrBindingOverlap):
case errors.Is(err, storecontract.ErrBindingOverlap):
http.Error(w, "binding source overlaps an existing binding", http.StatusConflict)
default:
s.Log.Error("update binding", "err", err, "id", id)
@@ -181,7 +181,7 @@ func (s *Server) handleBindingDelete(w http.ResponseWriter, r *http.Request) {
return
}
if err := s.Bindings.DeleteBinding(r.Context(), id); err != nil {
if errors.Is(err, storev1.ErrBindingNotFound) {
if errors.Is(err, storecontract.ErrBindingNotFound) {
http.Error(w, "binding not found", http.StatusNotFound)
return
}
@@ -204,11 +204,11 @@ func (s *Server) handleBindingApprove(w http.ResponseWriter, r *http.Request) {
}
if err := s.Bindings.ApproveBinding(r.Context(), id); err != nil {
switch {
case errors.Is(err, storev1.ErrBindingNotFound):
case errors.Is(err, storecontract.ErrBindingNotFound):
http.Error(w, "binding not found", http.StatusNotFound)
case errors.Is(err, storev1.ErrBindingTransition):
case errors.Is(err, storecontract.ErrBindingTransition):
http.Error(w, "binding cannot be approved from its current state", http.StatusConflict)
case errors.Is(err, storev1.ErrBindingOverlap):
case errors.Is(err, storecontract.ErrBindingOverlap):
http.Error(w, "binding source overlaps an existing binding", http.StatusConflict)
default:
s.Log.Error("approve binding", "err", err, "id", id)
+1 -1
View File
@@ -22,7 +22,7 @@ func (s *Server) handleCapabilities(w http.ResponseWriter, _ *http.Request) {
"sections": map[string]bool{
"chat": s.Chat != nil && s.Chat.Contract != nil,
"logs": s.LogFeed != nil,
"skills": s.Cfg != nil,
"skills": s.Skills != nil,
"memory": s.Memory != nil,
"curators": s.Curators != nil,
"channels": s.Channels != nil || s.Cfg != nil,
+20 -21
View File
@@ -13,7 +13,6 @@ import (
"github.com/google/uuid"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/gateway"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
@@ -21,7 +20,7 @@ import (
// Handlers depend on the Gateway-owned contract and never retain Gateway
// implementation objects.
type ChatService struct {
Contract gateway.ChatContract
Contract messaging.ChatContract
Updates ChatUpdateService
Dangerous *DangerousService
updateMu sync.Mutex
@@ -73,11 +72,11 @@ type chatUpdateRequest struct {
}
type chatTurnView struct {
TurnID string `json:"turn_id"`
AssistantMessageID string `json:"assistant_message_id,omitempty"`
Status gateway.TurnStatus `json:"status"`
Error string `json:"error,omitempty"`
ToolCalls []chatToolView `json:"tool_calls,omitempty"`
TurnID string `json:"turn_id"`
AssistantMessageID string `json:"assistant_message_id,omitempty"`
Status messaging.TurnStatus `json:"status"`
Error string `json:"error,omitempty"`
ToolCalls []chatToolView `json:"tool_calls,omitempty"`
}
type chatToolView struct {
@@ -127,7 +126,7 @@ func (s *Server) handleChatSessions(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
out := make([]gateway.SessionContext, 0, len(snapshot.Sessions))
out := make([]messaging.SessionContext, 0, len(snapshot.Sessions))
active := make(map[string]string)
for _, session := range snapshot.Sessions {
if session.Source.Platform == "web" {
@@ -152,14 +151,14 @@ func (s *Server) handleChatSessions(w http.ResponseWriter, r *http.Request) {
})
}
func chatCommandSpecs(chat *ChatService) []gateway.CommandSpec {
specs := gateway.LocalCommandSpecs()
func chatCommandSpecs(chat *ChatService) []messaging.CommandSpec {
specs := messaging.LocalCommandSpecs()
if chat.Dangerous != nil {
specs = append(
specs,
gateway.CommandSpec{Command: "/rollback", Description: "Request approval to restore a filesystem checkpoint", Usage: "/rollback [number]"},
gateway.CommandSpec{Command: "/stop", Description: "Request approval to terminate a background process", Usage: "/stop <process-name>"},
gateway.CommandSpec{Command: "/deny", Description: "Deny a pending dangerous action", Usage: "/deny <action-id>"},
messaging.CommandSpec{Command: "/rollback", Description: "Request approval to restore a filesystem checkpoint", Usage: "/rollback [number]"},
messaging.CommandSpec{Command: "/stop", Description: "Request approval to terminate a background process", Usage: "/stop <process-name>"},
messaging.CommandSpec{Command: "/deny", Description: "Deny a pending dangerous action", Usage: "/deny <action-id>"},
)
}
return specs
@@ -233,16 +232,16 @@ func (s *Server) handleChatTurns(w http.ResponseWriter, r *http.Request) {
writeJSON(w, views)
}
func (s *Server) decodeChatMessage(w http.ResponseWriter, r *http.Request) (gateway.Inbound, bool) {
func (s *Server) decodeChatMessage(w http.ResponseWriter, r *http.Request) (messaging.Inbound, bool) {
var req chatMessageRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, "invalid chat message", http.StatusBadRequest)
return gateway.Inbound{}, false
return messaging.Inbound{}, false
}
req.Text = strings.TrimSpace(req.Text)
if req.Text == "" || req.ChannelID == "" {
http.Error(w, "text and channel_id are required", http.StatusBadRequest)
return gateway.Inbound{}, false
return messaging.Inbound{}, false
}
if req.SourceID == "" {
req.SourceID = newChatSourceID()
@@ -250,7 +249,7 @@ func (s *Server) decodeChatMessage(w http.ResponseWriter, r *http.Request) (gate
// The browser has no threading, so the conversation is the channel
// alone. Page is the route the operator is looking at, and stays out
// of the record.
return gateway.Inbound{
return messaging.Inbound{
Message: messaging.Message{
SourceID: req.SourceID,
ConversationID: messaging.ConversationID{ChannelID: req.ChannelID},
@@ -303,7 +302,7 @@ type chatStreamEvent struct {
Label string `json:"label,omitempty"`
}
// chatStreamSink adapts the stream writer to gateway.TurnStream so text and
// chatStreamSink adapts the stream writer to messaging.TurnStream so text and
// tool activity reach the browser through one ordered path.
//
// showToolCalls gates ToolCall the same way Telegram's liveReply gates its
@@ -322,13 +321,13 @@ func (s chatStreamSink) Delta(text string) {
s.write(chatStreamEvent{Type: "delta", Text: text})
}
func (s chatStreamSink) ToolCall(event gateway.ToolCallEvent) {
func (s chatStreamSink) ToolCall(event messaging.ToolCallEvent) {
// A dashboard_navigate call is an explicit point-the-operator-there
// result, not tool narration, so it renders a clickable chip even when
// ShowToolCalls is off. Parse the resolved path/label from the tool's
// JSON result and emit a dedicated navigate frame.
if event.Name == "dashboard_navigate" && event.Err == "" {
var result gateway.DashboardNavigateResult
var result messaging.DashboardNavigateResult
if err := json.Unmarshal([]byte(event.Output), &result); err == nil && result.Path != "" {
s.write(chatStreamEvent{
Type: "navigate",
@@ -364,7 +363,7 @@ func (s chatStreamSink) ToolCall(event gateway.ToolCallEvent) {
// path, silence here meant the model announced a file it had sent and
// nothing arrived -- the precise defect send_file was built to end,
// reappearing on the channel that cannot deliver.
func (s chatStreamSink) Media(event gateway.MediaEvent) {
func (s chatStreamSink) Media(event messaging.MediaEvent) {
att := event.Attachment
switch {
case att.URL != "":
+17 -18
View File
@@ -10,11 +10,10 @@ import (
"strconv"
"strings"
"github.com/samcharles93/archie-core/internal/channels"
"github.com/samcharles93/archie-core/internal/channels/status"
"github.com/samcharles93/archie-core/internal/config"
storev1 "github.com/samcharles93/archie-core/internal/contracts/store/v1"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
"github.com/samcharles93/archie-core/internal/secret"
)
// Sentinel errors for handleConfigUpdate status classification. The
@@ -82,7 +81,7 @@ func (s *Server) handleChannelReload(w http.ResponseWriter, r *http.Request) {
http.Error(w, "channel reload unavailable", http.StatusNotImplemented)
return
}
var status *channels.Status
var status *status.Status
for _, candidate := range s.Channels.Snapshot() {
if candidate.ID == id {
status = &candidate
@@ -100,7 +99,7 @@ func (s *Server) handleChannelReload(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"ok": true, "channel": id})
}
func channelViewFromStatus(status channels.Status) ChannelView {
func channelViewFromStatus(status status.Status) ChannelView {
view := ChannelView{
ID: status.ID, Name: status.Name, Configured: status.Configured, Detail: status.Detail,
State: string(status.State), ReloadSupported: status.ReloadSupported,
@@ -119,20 +118,20 @@ func channelViewFromStatus(status channels.Status) ChannelView {
return view
}
func channelStateDetail(state channels.State, configured bool) string {
func channelStateDetail(state status.State, configured bool) string {
if !configured {
return "Not configured."
}
switch state {
case channels.StateConfigured:
case status.StateConfigured:
return "Configured; waiting for the daemon to start it."
case channels.StateStarting:
case status.StateStarting:
return "Starting."
case channels.StateRunning:
case status.StateRunning:
return "Running."
case channels.StateDegraded:
case status.StateDegraded:
return "Running with a degraded capability."
case channels.StateFailed:
case status.StateFailed:
return "Failed to start."
default:
return "Stopped."
@@ -140,7 +139,7 @@ func channelStateDetail(state channels.State, configured bool) string {
}
func telegramChannelView(t config.TelegramConfig) ChannelView {
configured := t.Token != (secret.SecretRef{}) || strings.TrimSpace(t.TokenEnv) != ""
configured := t.Token != (config.SecretRef{}) || strings.TrimSpace(t.TokenEnv) != ""
detail := "Not configured."
if configured {
n := len(t.AllowedUserIDs)
@@ -159,7 +158,7 @@ func telegramChannelView(t config.TelegramConfig) ChannelView {
Configured: configured,
Detail: detail,
Description: "Talk to Archie and approve its work from your phone.",
State: string(channels.StateConfigured),
State: string(status.StateConfigured),
ReloadSupported: true,
}
}
@@ -198,9 +197,9 @@ func emailChannelView(e config.EmailConfig) ChannelView {
func staticChannelState(configured bool) string {
if configured {
return string(channels.StateConfigured)
return string(status.StateConfigured)
}
return string(channels.StateStopped)
return string(status.StateStopped)
}
// ConfigView is the read-only, secret-free projection of config.Config
@@ -319,7 +318,7 @@ type WebView struct {
//
// This handler builds ConfigView field by field from an explicit allowlist
// rather than marshalling config.Config and stripping fields afterward:
// config.Config carries secret.SecretRef values (forge tokens, provider API
// config.Config carries config.SecretRef values (forge tokens, provider API
// keys) and there is no way to guarantee a strip-after-marshal approach
// keeps working as fields are added to Config in the future. An allowlist
// fails safe -- a new secret field added upstream is simply absent here
@@ -359,7 +358,7 @@ func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
// LocalConfigView builds the projection from the configuration this process
// holds. It is what the daemon serves and, byte for byte, what it publishes
// for the UI process to render (see storev1.ConfigSnapshot).
// for the UI process to render (see storecontract.ConfigSnapshot).
//
// Every value here is read from one config snapshot taken up front: under the
// Holder a reload swaps the whole value, which is what a read-only view
@@ -437,7 +436,7 @@ func (s *Server) LocalConfigView(ctx context.Context) (ConfigView, bool, error)
// RemoteConfigView reads the projection the configuration owner published.
// The reading process cannot edit it: it has no update path, and the page is
// told so rather than offering a control that would 503.
func RemoteConfigView(snapshots storev1.ConfigSnapshotStore) ConfigViewSource {
func RemoteConfigView(snapshots storecontract.ConfigSnapshotStore) ConfigViewSource {
return func(ctx context.Context) (ConfigView, bool, error) {
snapshot, found, err := snapshots.ConfigSnapshot(ctx)
if err != nil || !found {
+33 -6
View File
@@ -9,11 +9,9 @@ import (
"strings"
"testing"
"github.com/samcharles93/archie-core/internal/channels"
"github.com/samcharles93/archie-core/internal/channels/status"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/curator"
"github.com/samcharles93/archie-core/internal/logging"
"github.com/samcharles93/archie-core/internal/memory"
"github.com/samcharles93/archie-core/internal/secret"
"github.com/samcharles93/archie-core/internal/store"
)
@@ -595,7 +593,7 @@ func TestHandleChannelsNilConfig(t *testing.T) {
func TestHandleChannelsUsesRuntimeManager(t *testing.T) {
srv := newTestServer(t)
srv.Cfg = configWithFakeSecrets()
srv.Channels = channels.NewManager([]channels.Descriptor{{
srv.Channels = status.NewManager([]status.Descriptor{{
ID: "telegram", Name: "Telegram", Configured: true, ReloadSupported: true,
}})
srv.Channels.MarkFailed("telegram", "token rejected")
@@ -729,8 +727,9 @@ func TestCapabilitiesReportWhatThisProcessCanServe(t *testing.T) {
wired := newTestServer(t)
wired.Cfg = config.NewHolder(config.Config{})
wired.LogFeed = logging.NewFeed(10)
wired.Memory = &memory.Manager{}
wired.Curators = &curator.Registry{}
wired.Memory = stubMemory{}
wired.Curators = stubCurators{}
wired.Skills = stubSkillCatalog{}
got := get(wired)
for _, section := range []string{"logs", "memory", "curators", "skills", "channels"} {
if !got[section] {
@@ -738,3 +737,31 @@ func TestCapabilitiesReportWhatThisProcessCanServe(t *testing.T) {
}
}
}
// stubMemory satisfies the webui-owned MemoryStatus view for tests.
type stubMemory struct{}
func (stubMemory) Builtin() MemoryProviderHandle { return stubMemoryProvider{} }
func (stubMemory) External() MemoryProviderHandle { return nil }
type stubMemoryProvider struct{}
func (stubMemoryProvider) Name() string { return "builtin" }
func (stubMemoryProvider) IsAvailable() bool { return true }
func (stubMemoryProvider) ToolViews() []MemoryToolView {
return []MemoryToolView{{Name: "remember", Description: "store a fact"}}
}
// stubCurators satisfies the webui-owned CuratorStatus view for tests.
type stubCurators struct{}
func (stubCurators) Names() []string { return []string{"wired"} }
func (stubCurators) Health(_ context.Context) map[string]CuratorHealthView {
return map[string]CuratorHealthView{"wired": {Status: "healthy"}}
}
func (stubCurators) Activity(string) (CuratorActivity, bool) { return CuratorActivity{}, false }
// stubSkillCatalog satisfies the webui-owned SkillCatalog view for tests.
type stubSkillCatalog struct{}
func (stubSkillCatalog) Skills() []SkillView { return []SkillView{{Name: "demo"}} }
+24 -2
View File
@@ -1,6 +1,7 @@
package webui
import (
"context"
"net/http"
"time"
)
@@ -14,8 +15,29 @@ type CuratorActionView struct {
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 curator.Registry -- see
// health, and recent activity. Backed by CuratorStatus -- see
// handleCurators.
type CuratorView struct {
Name string `json:"name"`
@@ -55,7 +77,7 @@ func (s *Server) handleCurators(w http.ResponseWriter, r *http.Request) {
view := CuratorView{
Name: name,
Health: CuratorHealthView{
Status: string(h.Status),
Status: h.Status,
Message: h.Message,
},
RecentActions: []CuratorActionView{},
+35 -2
View File
@@ -66,7 +66,7 @@ func TestHandleCuratorsReportsNamesHealthAndActivity(t *testing.T) {
})
srv := newTestServer(t)
srv.Curators = registry
srv.Curators = curatorStatusAdapter{registry}
w := httptest.NewRecorder()
srv.Handler().ServeHTTP(w, httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/curators", nil))
@@ -113,7 +113,7 @@ func TestHandleCuratorsReportsRegisteredCuratorWithNoActivityYet(t *testing.T) {
}
srv := newTestServer(t)
srv.Curators = registry
srv.Curators = curatorStatusAdapter{registry}
w := httptest.NewRecorder()
srv.Handler().ServeHTTP(w, httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/curators", nil))
@@ -142,3 +142,36 @@ func TestHandleCuratorsReportsRegisteredCuratorWithNoActivityYet(t *testing.T) {
t.Fatalf("response leaks zero-value time.Time: %s", body)
}
}
// curatorStatusAdapter adapts the real registry to the webui-owned
// CuratorStatus view, mirroring the daemon's bootstrap adapter.
type curatorStatusAdapter struct{ r *curator.Registry }
func (a curatorStatusAdapter) Names() []string { return a.r.Names() }
func (a curatorStatusAdapter) Health(ctx context.Context) map[string]CuratorHealthView {
health := a.r.Health(ctx)
views := make(map[string]CuratorHealthView, len(health))
for name, h := range health {
views[name] = CuratorHealthView{Status: string(h.Status), Message: h.Message}
}
return views
}
func (a curatorStatusAdapter) Activity(name string) (CuratorActivity, bool) {
activity, ok := a.r.Activity(name)
if !ok {
return CuratorActivity{}, false
}
view := CuratorActivity{
LastRunAt: activity.LastRunAt,
LastRunActions: activity.LastRunActions,
Recent: make([]CuratorActionView, 0, len(activity.Recent)),
}
for _, a2 := range activity.Recent {
view.Recent = append(view.Recent, CuratorActionView{
At: a2.At, Type: a2.Type, Detail: a2.Detail, Reason: a2.Reason,
})
}
return view, true
}
+4 -4
View File
@@ -7,8 +7,8 @@ import (
"net/http"
"strconv"
storev1 "github.com/samcharles93/archie-core/internal/contracts/store/v1"
"github.com/samcharles93/archie-core/internal/domain/mapping"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
)
// mappingRequest is the wire shape POST /api/mappings and
@@ -109,7 +109,7 @@ func (s *Server) handleMappingUpdate(w http.ResponseWriter, r *http.Request) {
return
}
if err := s.Mappings.UpdateMapping(r.Context(), m); err != nil {
if errors.Is(err, storev1.ErrMappingNotFound) {
if errors.Is(err, storecontract.ErrMappingNotFound) {
http.Error(w, "mapping not found", http.StatusNotFound)
return
}
@@ -137,7 +137,7 @@ func (s *Server) handleMappingDelete(w http.ResponseWriter, r *http.Request) {
return
}
if err := s.Mappings.DeleteMapping(r.Context(), id); err != nil {
if errors.Is(err, storev1.ErrMappingNotFound) {
if errors.Is(err, storecontract.ErrMappingNotFound) {
http.Error(w, "mapping not found", http.StatusNotFound)
return
}
@@ -192,7 +192,7 @@ func (s *Server) handleMappingPreview(w http.ResponseWriter, r *http.Request) {
// exactly one reader, the dashboard list view, so a by-ID lookup was never
// needed until preview), so this scans the newest window rather than
// adding a new store method for a single low-volume caller.
func (s *Server) captureByID(ctx context.Context, id int64) (*storev1.CapturedEvent, error) {
func (s *Server) captureByID(ctx context.Context, id int64) (*storecontract.CapturedEvent, error) {
captures, err := s.Captures.ListCaptures(ctx, mappingCaptureScanWindow(s.CaptureMaxEvents))
if err != nil {
return nil, err
+22 -11
View File
@@ -1,10 +1,26 @@
package webui
import (
"net/http"
import "net/http"
"github.com/samcharles93/archie-core/internal/memory"
)
// MemoryProviderHandle is the webui-owned view source for one memory
// provider: the memory page renders a name, a readiness flag, and the
// provider's tool vocabulary by name. It is deliberately narrower than
// memory.MemoryProvider -- whose GetToolSchemas returns runtime tool
// entries -- so the UI process holds the view without linking the memory
// runtime (and, transitively, the agent toolchain). Whoever owns the
// memory runtime supplies adapters at bootstrap (archie-core-8cda.5.6).
type MemoryProviderHandle interface {
Name() string
IsAvailable() bool
ToolViews() []MemoryToolView
}
// MemoryStatus is the webui-owned surface over the running memory runtime:
// the two providers the memory page renders, by role.
type MemoryStatus interface {
Builtin() MemoryProviderHandle
External() MemoryProviderHandle
}
// MemoryProviderView describes one memory provider for the dashboard.
type MemoryProviderView struct {
@@ -48,18 +64,13 @@ func (s *Server) handleMemory(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"providers": views, "enabled": true})
}
func providerView(p memory.MemoryProvider, role string) MemoryProviderView {
func providerView(p MemoryProviderHandle, role string) MemoryProviderView {
view := MemoryProviderView{
Name: p.Name(),
Role: role,
Available: p.IsAvailable(),
Tools: []MemoryToolView{},
}
for _, t := range p.GetToolSchemas() {
view.Tools = append(view.Tools, MemoryToolView{
Name: t.Name,
Description: t.Description,
})
}
view.Tools = append(view.Tools, p.ToolViews()...)
return view
}
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"net/http"
"strings"
"github.com/samcharles93/archie-core/internal/secret"
"github.com/samcharles93/archie-core/internal/config"
)
// SetupStep is one item in the dashboard's getting-started checklist.
@@ -79,6 +79,6 @@ func (s *Server) handleSetup(w http.ResponseWriter, r *http.Request) {
// one is the honest signal here.
func (s *Server) hasChannel() bool {
cfg := s.Cfg.Get()
return cfg.Chat.Telegram.Token != (secret.SecretRef{}) || strings.TrimSpace(cfg.Chat.Telegram.TokenEnv) != "" ||
return cfg.Chat.Telegram.Token != (config.SecretRef{}) || strings.TrimSpace(cfg.Chat.Telegram.TokenEnv) != "" ||
strings.TrimSpace(cfg.Chat.WebhookAddr) != ""
}
+13 -49
View File
@@ -1,10 +1,6 @@
package webui
import (
"net/http"
"github.com/samcharles93/archie-core/internal/skill"
)
import "net/http"
// SkillView is one catalogued skill as shown on the dashboard's Skills page:
// what it does, in plain language, and where it was discovered.
@@ -15,55 +11,23 @@ type SkillView struct {
Source string `json:"source"`
}
// SkillCatalog is the webui-owned source of the dashboard's skill
// catalogue. It is deliberately a view over already-discovered entries, not
// the discovery machinery: the cataloguer (internal/skill) drags the agent
// toolchain in, and the UI process must not link it (archie-core-8cda.5.6).
// Whoever owns the runtime -- the daemon, via its config -- supplies an
// adapter at bootstrap; an unwired catalog degrades to an empty page.
type SkillCatalog interface {
Skills() []SkillView
}
// handleSkills reports the skill catalogue -- what Archie can actually do,
// beyond what is in the source. It answers the same question a fresh
// operator would ask by reading internal/skill/, without the reading.
//
// The catalogue layers project, explicitly shared, and user-global skills.
// Earlier roots win when names collide. Missing roots are legitimate and
// produce an empty or partial catalogue rather than a failed dashboard.
func (s *Server) handleSkills(w http.ResponseWriter, r *http.Request) {
if s.Cfg == nil {
if s.Skills == nil {
writeJSON(w, map[string]any{"skills": []SkillView{}})
return
}
cfg := s.Cfg.Get()
roots := skill.DefaultRoots(cfg.WorkDir, cfg.SkillsDir)
catalog, err := skill.CatalogRoots(roots...)
if err != nil {
http.Error(w, "failed to read skill catalogue: "+err.Error(), http.StatusInternalServerError)
return
}
views := make([]SkillView, 0, len(catalog))
for _, entry := range catalog {
views = append(views, SkillView{
Name: entry.Name,
Description: entry.Description,
Workflow: entry.Workflow,
Source: skillSource(entry.Root, cfg.WorkDir, cfg.SkillsDir),
})
}
// Each skill already carries its own Source, which is what the page
// renders. A top-level dir/dirs pair had no consumer and implied the
// catalog came from one place when it is merged from several.
writeJSON(w, map[string]any{"skills": views})
}
// skillSource labels where a skill was loaded from.
//
// sharedDir is checked first: when it equals workDir the roots collapse to one
// entry, and matching workDir first labelled every shared skill as a project
// skill.
func skillSource(root, workDir, sharedDir string) string {
switch root {
case sharedDir:
return "shared skills"
case workDir:
return "project skills"
default:
return "user-global skills"
}
writeJSON(w, map[string]any{"skills": s.Skills.Skills()})
}
+6 -6
View File
@@ -13,9 +13,9 @@ import (
"strings"
"github.com/samcharles93/archie-core/internal/config"
storev1 "github.com/samcharles93/archie-core/internal/contracts/store/v1"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/domain/taskactions"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/taskstate"
)
@@ -63,14 +63,14 @@ func (s *Server) handleTasks(w http.ResponseWriter, r *http.Request) {
}
type taskView struct {
workflow.Task
task.Task
Actions []taskstate.Action `json:"actions"`
RepoURL string `json:"repo_url,omitempty"`
IssueURL string `json:"issue_url,omitempty"`
PRURL string `json:"pr_url,omitempty"`
}
func (s *Server) taskURLs(task workflow.Task) (repoURL, issueURL, prURL string) {
func (s *Server) taskURLs(task task.Task) (repoURL, issueURL, prURL string) {
if s.Cfg == nil {
return "", "", ""
}
@@ -92,7 +92,7 @@ func (s *Server) taskURLs(task workflow.Task) (repoURL, issueURL, prURL string)
return repoURL, issueURL, prURL
}
func forgeConfigForTask(cfg config.Config, task workflow.Task) config.Forge {
func forgeConfigForTask(cfg config.Config, task task.Task) config.Forge {
for _, identity := range cfg.Identities {
if task.Identity != "" && identity.Name == task.Identity {
return identity.Forge
@@ -152,7 +152,7 @@ func (s *Server) handleTaskAction(w http.ResponseWriter, r *http.Request) {
switch {
case errors.Is(err, taskactions.ErrNotFound):
http.Error(w, "task not found", http.StatusNotFound)
case errors.Is(err, taskactions.ErrConflict), errors.Is(err, storev1.ErrStaleTransition):
case errors.Is(err, taskactions.ErrConflict), errors.Is(err, storecontract.ErrStaleTransition):
http.Error(w, err.Error(), http.StatusConflict)
case errors.Is(err, taskactions.ErrUnavailable):
http.Error(w, err.Error(), http.StatusServiceUnavailable)
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"net/http"
"strings"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/gateway"
)
// handleWorkflows returns per-workflow and per-stage statistics: run counts,
@@ -78,7 +78,7 @@ func (s *Server) handleWorkRequest(w http.ResponseWriter, r *http.Request) {
http.Error(w, "workflow is not enabled", http.StatusConflict)
return
}
taskID, err := s.WorkRequests.CreateTask(r.Context(), gateway.SpawnRequest{
taskID, err := s.WorkRequests.CreateTask(r.Context(), messaging.SpawnRequest{
Identity: request.Identity, Repo: request.Repository, Workflow: request.Workflow,
Title: request.Title, Body: request.Instructions,
})
+4 -4
View File
@@ -10,7 +10,7 @@ import (
"github.com/google/uuid"
"github.com/samcharles93/archie-core/internal/gateway"
"github.com/samcharles93/archie-core/internal/domain/messaging"
)
const (
@@ -22,7 +22,7 @@ const (
// interactive approval workflow. It intentionally has no host process or
// filesystem access of its own.
type DangerousService struct {
Authority gateway.DangerousCommandAuthority
Authority messaging.DangerousCommandAuthority
mu sync.Mutex
actions map[string]dangerousAction
@@ -44,7 +44,7 @@ type DangerousActionView struct {
ExpiresAt time.Time `json:"expires_at"`
}
func NewDangerousService(authority gateway.DangerousCommandAuthority) *DangerousService {
func NewDangerousService(authority messaging.DangerousCommandAuthority) *DangerousService {
return &DangerousService{
Authority: authority,
actions: make(map[string]dangerousAction),
@@ -59,7 +59,7 @@ func (s *DangerousService) enabled() error {
return nil
}
func (s *DangerousService) Checkpoints(ctx context.Context) ([]gateway.CheckpointInfo, error) {
func (s *DangerousService) Checkpoints(ctx context.Context) ([]messaging.CheckpointInfo, error) {
if err := s.enabled(); err != nil {
return nil, err
}
+16 -15
View File
@@ -16,21 +16,19 @@ import (
"sync"
"sync/atomic"
"github.com/samcharles93/archie-core/internal/channels"
"github.com/samcharles93/archie-core/internal/channels/status"
"github.com/samcharles93/archie-core/internal/config"
storev1 "github.com/samcharles93/archie-core/internal/contracts/store/v1"
"github.com/samcharles93/archie-core/internal/domain/curator"
"github.com/samcharles93/archie-core/internal/domain/health"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/gateway"
"github.com/samcharles93/archie-core/internal/logging"
"github.com/samcharles93/archie-core/internal/memory"
"github.com/samcharles93/archie-core/ui"
)
type Server struct {
Store storev1.TaskStore
Store storecontract.TaskStore
Log *slog.Logger
// Cfg backs the setup checklist and configuration views. Optional: the
@@ -52,10 +50,10 @@ type Server struct {
ConfigSource ConfigViewSource
// Workflows is the executable registry snapshot supplied by composition.
Workflows []workflow.Definition
Workflows []task.Definition
// WorkRequests admits dashboard requests through the same task-creation
// boundary used by chat; it never invokes a workflow runner directly.
WorkRequests gateway.TaskCreator
WorkRequests messaging.TaskCreator
// LogFeed is the daemon diagnostic stream. It is separate from Events,
// which contains persisted task lifecycle activity only.
LogFeed *logging.Feed
@@ -108,7 +106,7 @@ type Server struct {
// Channels reports actual adapter lifecycle, independently of configuration
// presence. Nil preserves the configuration-only fallback for tests and
// minimal embedding.
Channels *channels.Manager
Channels *status.Manager
// ReloadChannel invokes a channel-specific reload seam. Only adapters that
// explicitly support reload are wired here; nil means reload is unavailable.
@@ -116,13 +114,16 @@ type Server struct {
// Memory backs the memory view. Optional: the section reports memory as
// unavailable rather than failing when it is nil.
Memory *memory.Manager
Memory MemoryStatus
// Skills is the webui-owned skill catalogue view; nil degrades
// /api/skills to an empty page.
Skills SkillCatalog
// Curators is the daemon's live curator registry (epic archie-core-yp9).
// Backs GET /api/curators: registered names, per-curator health, and
// recent activity (archie-core-1786637489932-6). Optional: nil reports
// an empty curator list rather than failing the dashboard.
Curators *curator.Registry
Curators CuratorStatus
// Chat exposes the Gateway's wire-safe conversational contract. Optional:
// the dashboard simply omits chat when it is nil.
@@ -146,7 +147,7 @@ type Server struct {
// GET /api/captures list and the mapping preview's by-ID scan
// (docs/prds/event-capture-storage.md). Optional: nil makes the list
// answer {"enabled": false} rather than the dashboard failing to start.
Captures storev1.CaptureStore
Captures storecontract.CaptureStore
// CaptureMaxEvents is the operator's configured [capture] max_events,
// used to bound captureByID's scan window (api_mapping.go).
// CaptureIntake is the write half's mount.
@@ -167,13 +168,13 @@ type Server struct {
// Mappings persists payload field mappings (docs/prds/payload-field-mapping.md).
// Optional: nil makes every /api/mappings route answer 503 rather than
// the dashboard failing to start.
Mappings storev1.MappingStore
Mappings storecontract.MappingStore
// Bindings persists playbook bindings: matcher + mapping + workflow
// triples that turn a captured webhook into an archie task
// (docs/prds/webhook-intake-security.md). Optional: nil makes every
// /api/bindings route answer 503 rather than the dashboard failing to start.
Bindings storev1.BindingStore
Bindings storecontract.BindingStore
// TelegramUpdateReportPath and TelegramUpdateChatID let a dashboard-
// initiated update use the same post-restart notification route as a
+3 -3
View File
@@ -7,7 +7,7 @@ import (
"net/http"
"strconv"
storev1 "github.com/samcharles93/archie-core/internal/contracts/store/v1"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/events"
)
@@ -89,7 +89,7 @@ func (s *Server) registerSSEConn() (chan events.Event, func()) {
// running "since" watermark that deduplicates the backlog against live
// broadcasts covering the same event.
type sseStream struct {
store storev1.TaskStore
store storecontract.TaskStore
log *slog.Logger
w http.ResponseWriter
fl http.Flusher
@@ -98,7 +98,7 @@ type sseStream struct {
// newSSEStream builds a stream over w, reporting false if w cannot be
// flushed incrementally -- SSE does not work without that.
func newSSEStream(st storev1.TaskStore, log *slog.Logger, w http.ResponseWriter, since int64) (*sseStream, bool) {
func newSSEStream(st storecontract.TaskStore, log *slog.Logger, w http.ResponseWriter, since int64) (*sseStream, bool) {
fl, ok := w.(http.Flusher)
if !ok {
return nil, false