Add cmd/archie-ui and internal/app/archieui: a second composition root that
serves the dashboard and the compiled SPA against the two contracts the daemon
already dials, so the UI stops needing the daemon's in-process objects.
The composition root lives outside internal/app/archied deliberately. That
package pulls 88 internal packages (daemon, forge, containers, NATS, secrets,
workflow); reusing its boot the way RunGateway and RunStateStore do would make
the PRD's deletion gate unreachable. archieui links 41, and cmd/archie-ui 42.
Configuration ownership follows docs/prds/ui-service-boundary.md: the process
reads the shared file, but only [services.gateway].{target,target_token},
[services.state].{target,target_token} and [web].{listen,
trust_forwarded_headers}, with flags taking precedence. Options has no field
for anything else in that file to land in, and no config.Holder.
compose() sets only the contract-backed and process-local fields. Every daemon
runtime handle stays nil on purpose and its route degrades through the
existing 501/503/empty paths. Captures, CaptureLimiter and BindingDispatcher
are withheld for the duration of the seam: the daemon's dashboard still serves
POST /webhooks/capture/{source}, and two intakes are not permitted.
Readiness is the UI's own registry over its two dependencies via a new bounded
readiness.ContractProbe. The existing GatewayProbe was unusable here: with no
channel manager to inject it reports "no gateway channels configured", i.e.
permanently degraded.
The State Store's fail-closed non-loopback rule and the two dial paths move to
staterpc.Dial/TargetIsLoopback and gatewayrpc.Dial, so the server side and
every client share one implementation instead of three copies.
The Gateway remains loopback-only with no auth interceptor, so this process is
scoped to being colocated with it; filed as archie-core-juqx.
Refs: archie-core-8cda.5.2
60 lines
2.4 KiB
Go
60 lines
2.4 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, reached
|
|
// through a narrow admin contract. The shared holder is removed from the
|
|
// daemon's own wiring by archie-core-8cda.5.4.
|
|
// - LogFeed, TaskLogs, Events, Channels, ReloadChannel, Curators, Memory,
|
|
// Issues, TaskStopper, 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 d.Chat != nil {
|
|
srv.Chat = &webui.ChatService{Contract: d.Chat}
|
|
}
|
|
return srv
|
|
}
|