The same dashboard is served by the daemon, which holds every runtime handle, and by the UI process, which holds two remote contracts. A section with nothing behind it still answers -- an empty list, a "disabled" marker, a 501 -- and the browser cannot tell that from a deployment where nothing has happened yet. GET /api/capabilities says which sections this process can back, and the nav drops the rest rather than offering a page that is permanently empty. It fails open in both directions: an unreported section stays visible, and a failed read hides nothing, because an entry that silently vanished is worse than a page that explains itself. Mappings and bindings move the other way. Both are ratified State Store contracts carried by the client the UI process already holds, so leaving them nil degraded two pages that have an owner; compose wires them. A table test now enumerates every route whose capability is daemon-local and pins what it answers without one (requirement 4 of archie-core-8cda.5.4): task logs, the log feed and its stream, version and the update flow, channels and reload, curators, memory, skills, workflows and work requests. Adding a route with no owner now fails that test rather than the operator's browser.
73 lines
2.9 KiB
Go
73 lines
2.9 KiB
Go
package archieui
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/health"
|
|
"github.com/samcharles93/archie-core/internal/gateway"
|
|
"github.com/samcharles93/archie-core/internal/store"
|
|
"github.com/samcharles93/archie-core/internal/webui"
|
|
)
|
|
|
|
// deps are the resolved inputs the dashboard is built from: two remote
|
|
// contracts, the process's own logger and options, and the readiness registry
|
|
// assembled over those same contracts.
|
|
type deps struct {
|
|
Options Options
|
|
Log *slog.Logger
|
|
Store store.TaskStore
|
|
Chat gateway.ChatContract
|
|
Health *health.Registry
|
|
}
|
|
|
|
// compose builds the dashboard server for the UI process. It sets exactly the
|
|
// fields a contract already carries plus this process's own settings, and
|
|
// leaves every remaining field at its zero value on purpose: each one is a
|
|
// daemon-local runtime handle with no contract behind it, and the handlers
|
|
// already degrade to a documented 501/503/empty response rather than panicking
|
|
// (docs/prds/ui-service-boundary.md:130-131).
|
|
//
|
|
// What is deliberately absent, and which bead fills it:
|
|
//
|
|
// - Cfg, LastReload, UpdateConfig, ConfigOverrides, ResetConfig,
|
|
// UpdateRepoField: the configuration owner stays the daemon. The read
|
|
// crosses as the snapshot ConfigSource renders; the write routes answer
|
|
// 503 and the page hides their controls (archie-core-ymut).
|
|
// - LogFeed, TaskLogs, Events, Channels, ReloadChannel, Curators, Memory,
|
|
// Workflows, WorkRequests, RunningVersions, Chat.Updates,
|
|
// UpdateReportPath: no contract exists for these yet.
|
|
// Defining one amends the owning service's contract first
|
|
// (docs/prds/ui-service-boundary.md:205-207); the route migration is
|
|
// archie-core-8cda.5.3.
|
|
// - Captures, CaptureLimiter, BindingDispatcher: withheld for the duration
|
|
// of the seam. The daemon's in-process dashboard still serves
|
|
// POST /webhooks/capture/{source}; wiring it here too would give two
|
|
// listeners the same intake authority, which the PRD forbids
|
|
// (lines 30-33). Turned on at cutover, once the daemon's listener is gone.
|
|
func compose(d deps) *webui.Server {
|
|
srv := &webui.Server{
|
|
Store: d.Store,
|
|
Log: d.Log,
|
|
Token: d.Options.Token,
|
|
TrustForwardedHeaders: d.Options.trustForwardedHeaders(),
|
|
Health: d.Health,
|
|
}
|
|
if snapshots, ok := d.Store.(store.ConfigSnapshotStore); ok {
|
|
srv.ConfigSource = webui.RemoteConfigView(snapshots)
|
|
}
|
|
// Mappings and bindings are ratified State Store contracts, and the same
|
|
// client already carries them: withholding them would degrade two pages
|
|
// that have an owner, which is a different thing from the intake surfaces
|
|
// below.
|
|
if mappings, ok := d.Store.(store.MappingStore); ok {
|
|
srv.Mappings = mappings
|
|
}
|
|
if bindings, ok := d.Store.(store.BindingStore); ok {
|
|
srv.Bindings = bindings
|
|
}
|
|
if d.Chat != nil {
|
|
srv.Chat = &webui.ChatService{Contract: d.Chat}
|
|
}
|
|
return srv
|
|
}
|