refactor(config): delete the runtime config overlay
The control plane replaces this, rather than extending it (docs/prds/runtime-control-plane.md, "First implementation"). Until now both paths existed: overlay kept dashboard edits in its own SQLite file beside archie.db and layered them over the file config at boot and on every reload, which is the duplicate configuration authority the PRD set out to remove. Gone with it: the --no-config-overlay flag and ARCHIE_SKIP_CONFIG_OVERLAY recovery hatch, which existed because a bad overlay row could brick the boot; ReloadStatus.OverlayUnavailable; and the reload controller's overlay source. The -config-overlay file overlay is a different thing and stays. The dashboard's three write seams went too. UpdateConfig, ResetConfig and UpdateRepoField were assigned only in internal/webui's own tests, so in production they answered 503 and ConfigView.Editable was permanently false (archie-core-j28m). Removing Editable would otherwise have flipped the SPA's controls on, since configEditable read a missing field as true, so the config pages become what they already were in practice: a read of what each process is running with. Configuration is written through the control plane. apply.go survives this deliberately; archie-core-xrux carries the question of whether its map merge is still guarding the file overlay path.
This commit is contained in:
1 parent
a89281cca8
commit
295f8d697f
35 files changed
+58
-1519
No files matched your search
@@ -897,11 +897,11 @@ func TestUIProcessServesTheDashboardAgainstLiveDependencies(t *testing.T) {
|
||||
if err := json.Unmarshal(rendered.body, &view); err != nil {
|
||||
t.Fatalf("decode config view: %v (%s)", err, rendered.body)
|
||||
}
|
||||
if view.Identity.BotUser != "archie-bot" || view.Editable {
|
||||
if view.Identity.BotUser != "archie-bot" {
|
||||
t.Errorf("config view = %s, want the published projection rendered read-only", rendered.body)
|
||||
}
|
||||
if got := d.do(d.request(http.MethodPatch, "/api/config", `{}`, true)); got.status != http.StatusServiceUnavailable {
|
||||
t.Errorf("PATCH /api/config = %d, want 503", got.status)
|
||||
if got := d.do(d.request(http.MethodPatch, "/api/config", `{}`, true)); got.status != http.StatusMethodNotAllowed {
|
||||
t.Errorf("PATCH /api/config = %d, want 405: configuration is read here and written through the control plane", got.status)
|
||||
}
|
||||
|
||||
// The setup checklist reads the same projection. It reported
|
||||
|
||||
@@ -45,7 +45,6 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/indexing"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration/overlay"
|
||||
infraembedding "github.com/samcharles93/archie-core/internal/infrastructure/embedding"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/eventbus/nats"
|
||||
infraMemory "github.com/samcharles93/archie-core/internal/infrastructure/memory"
|
||||
@@ -84,8 +83,6 @@ type boot struct {
|
||||
|
||||
loader *configuration.Loader
|
||||
doc *configuration.Document
|
||||
overlayStore *overlay.Store
|
||||
bootOverlayErr atomic.Pointer[string]
|
||||
currentProvenance atomic.Pointer[configuration.Provenance]
|
||||
|
||||
health *healthSurface
|
||||
@@ -244,16 +241,12 @@ func (b *boot) cleanup() {
|
||||
}
|
||||
}
|
||||
|
||||
// loadConfig resolves the file config and layers the runtime overlay
|
||||
// over it. A Resolve failure is reported on stderr because the file log
|
||||
// destination is itself configuration that has not been read yet.
|
||||
func (b *boot) loadConfig(ctx context.Context, cfgPath, overlayPath string, noConfigOverlay bool) error {
|
||||
// loadConfig resolves the file config. A Resolve failure is reported on
|
||||
// stderr because the file log destination is itself configuration that has
|
||||
// not been read yet.
|
||||
func (b *boot) loadConfig(ctx context.Context, cfgPath, overlayPath string) error {
|
||||
loader := configuration.New(b.log)
|
||||
b.loader = loader
|
||||
skipOverlay := noConfigOverlay || configuration.SkipOverlay()
|
||||
if skipOverlay {
|
||||
b.log.Info("runtime config overlay disabled (recovery hatch); booting on file config alone")
|
||||
}
|
||||
doc, err := loader.Resolve(cfgPath, overlayPath)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -268,21 +261,6 @@ func (b *boot) loadConfig(ctx context.Context, cfgPath, overlayPath string, noCo
|
||||
if len(doc.UnknownKeys) > 0 {
|
||||
b.log.Warn("config file has unrecognised keys; check for typos", "keys", doc.UnknownKeys)
|
||||
}
|
||||
// Runtime config overlay: dashboard-edited overrides layered over the
|
||||
// file config from their own SQLite file (own user_version and
|
||||
// migrator, no contention with the task store). Skipped under
|
||||
// --no-config-overlay / ARCHIE_SKIP_CONFIG_OVERLAY=1, or when the
|
||||
// store cannot be opened or its values fail validation -- a broken
|
||||
// overlay must not brick the daemon. bootOverlayErr carries the
|
||||
// degrade reason into /api/config's reload status so it is visible
|
||||
// where the operator is looking, not only in logs.
|
||||
if !skipOverlay {
|
||||
b.overlayStore, b.doc = bootConfigOverlay(ctx, loader, doc, &b.bootOverlayErr, b.log)
|
||||
if b.overlayStore != nil {
|
||||
store := b.overlayStore
|
||||
b.addCleanup(func() { _ = store.Close() })
|
||||
}
|
||||
}
|
||||
b.cfg = b.doc.Config
|
||||
b.cfgHolder = config.NewHolder(b.cfg)
|
||||
b.currentProvenance.Store(&b.doc.Provenance)
|
||||
@@ -1357,22 +1335,6 @@ func (b *boot) configOrigins() []webui.ConfigOrigin {
|
||||
return origins
|
||||
}
|
||||
|
||||
// configOverrides lists the dotted keys the runtime overlay currently sets,
|
||||
// so the dashboard can mark those rows: their file value is shadowed until
|
||||
// reset. A disabled overlay store reports no overrides.
|
||||
func (b *boot) configOverrides(ctx context.Context) []string {
|
||||
if b.overlayStore == nil {
|
||||
return nil
|
||||
}
|
||||
keys, err := b.overlayStore.Keys(ctx)
|
||||
if err != nil {
|
||||
// A failed read omits the list rather than failing the whole
|
||||
// view; the reload status carries the overlay degrade reason.
|
||||
return nil
|
||||
}
|
||||
return keys
|
||||
}
|
||||
|
||||
// configViewInput assembles the dashboard's configuration projection from
|
||||
// the daemon's own configuration state. The daemon is the configuration
|
||||
// owner, so it is the process that renders this view (archie-core-ml30).
|
||||
@@ -1380,7 +1342,6 @@ func (b *boot) configViewInput(ctx context.Context) webui.ConfigViewInput {
|
||||
in := webui.ConfigViewInput{
|
||||
Config: b.cfgHolder.Get(),
|
||||
Provenance: b.configOrigins(),
|
||||
Overridden: b.configOverrides(ctx),
|
||||
}
|
||||
if b.lastReload != nil {
|
||||
status := b.lastReload()
|
||||
@@ -1447,17 +1408,8 @@ func (b *boot) wireConfigPublishing(ctx context.Context, cfgPath, overlayPath st
|
||||
log.Info("config reloaded", "paths", doc.Provenance.Paths())
|
||||
}
|
||||
})
|
||||
if b.overlayStore != nil {
|
||||
reloadController.WithOverlay(func() (map[string]any, error) { return b.overlayStore.Snapshot(ctx) })
|
||||
}
|
||||
// lastReload merges the reload controller's outcome with the boot-time
|
||||
// overlay degrade, so /api/config carries both the last reload result
|
||||
// and whether the runtime overlay is in effect at all.
|
||||
b.lastReload = func() config.ReloadStatus {
|
||||
st := reloadController.Status()
|
||||
if p := b.bootOverlayErr.Load(); p != nil {
|
||||
st.OverlayUnavailable = *p
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration/overlay"
|
||||
"github.com/samcharles93/archie-core/internal/store"
|
||||
"github.com/samcharles93/archie-core/internal/webui"
|
||||
)
|
||||
@@ -81,68 +80,8 @@ func TestPublishConfigSnapshotRendersTheDaemonsConfiguration(t *testing.T) {
|
||||
if view.Reload == nil || view.Reload.LastError != "poll_interval must be positive" {
|
||||
t.Errorf("Reload = %+v, want the last reload outcome", view.Reload)
|
||||
}
|
||||
// Editable describes the rendering process's write path, never the
|
||||
// published document.
|
||||
if view.Editable {
|
||||
t.Error("the published document claims to be editable")
|
||||
}
|
||||
}
|
||||
|
||||
// TestPublishedSnapshotCarriesOverlayOverrides: the dashboard marks rows the
|
||||
// runtime overlay shadows, so the projection has to name those keys. The
|
||||
// daemon reads them from the overlay store it owns.
|
||||
func TestPublishedSnapshotCarriesOverlayOverrides(t *testing.T) {
|
||||
st, err := store.Open(t.Context(), filepath.Join(t.TempDir(), "state.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = st.Close() })
|
||||
|
||||
overlayStore, err := overlay.Open(t.Context(), filepath.Join(t.TempDir(), "config.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = overlayStore.Close() })
|
||||
if err := overlayStore.Set(t.Context(), "label", `"archie"`, "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := overlayStore.Set(t.Context(), "budgets.max_steps", "40", "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
b := &boot{
|
||||
log: slog.New(slog.DiscardHandler),
|
||||
stateStore: st,
|
||||
cfgHolder: config.NewHolder(config.Config{}),
|
||||
overlayStore: overlayStore,
|
||||
}
|
||||
b.publishConfigSnapshot(t.Context())
|
||||
|
||||
snapshot, found, err := st.ConfigSnapshot(context.Background())
|
||||
if err != nil || !found {
|
||||
t.Fatalf("ConfigSnapshot = (found %v, %v), want the published document", found, err)
|
||||
}
|
||||
var view webui.ConfigView
|
||||
if err := json.Unmarshal(snapshot.Document, &view); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := []string{"budgets.max_steps", "label"}
|
||||
if len(view.Overridden) != len(want) {
|
||||
t.Fatalf("Overridden = %+v, want %+v", view.Overridden, want)
|
||||
}
|
||||
for i, key := range want {
|
||||
if view.Overridden[i] != key {
|
||||
t.Errorf("Overridden[%d] = %q, want %q (sorted)", i, view.Overridden[i], key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestPublishedSnapshotCarriesPerIdentityForges: in a multi-identity
|
||||
// deployment the task board attributes each task to the forge that owns it,
|
||||
// and the only process that holds that configuration is the daemon. So the
|
||||
// published projection has to name every configured identity's forge and the
|
||||
// repositories it owns (archie-core-pv6t); with the default identity alone,
|
||||
// every row in such a deployment renders unlinked.
|
||||
func TestPublishedSnapshotCarriesPerIdentityForges(t *testing.T) {
|
||||
st, err := store.Open(t.Context(), filepath.Join(t.TempDir(), "state.db"))
|
||||
if err != nil {
|
||||
|
||||
@@ -56,7 +56,7 @@ func gatewayListenAndToken(b *boot, options GatewayOptions) (listen, token strin
|
||||
func RunGateway(ctx context.Context, options GatewayOptions) error {
|
||||
b := newBootstrap()
|
||||
defer b.cleanup()
|
||||
if err := b.loadConfig(ctx, options.Config, options.Overlay, false); err != nil {
|
||||
if err := b.loadConfig(ctx, options.Config, options.Overlay); err != nil {
|
||||
return err
|
||||
}
|
||||
b.log = b.log.With("component", "gateway")
|
||||
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
|
||||
"github.com/moby/moby/client"
|
||||
@@ -38,7 +37,6 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/forgerpc"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration/overlay"
|
||||
"github.com/samcharles93/archie-core/internal/logging"
|
||||
"github.com/samcharles93/archie-core/internal/plugin"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
@@ -292,15 +290,6 @@ func taskDBPath(configuredPath string) string {
|
||||
return configuredPath + "-tasks.sqlite"
|
||||
}
|
||||
|
||||
// configDBPath resolves the runtime config overlay file. It is a sibling
|
||||
// of the task and conversation stores (same configured path, own suffix)
|
||||
// so each file owns its user_version and its migrator with no
|
||||
// contention; recovery from a broken overlay is rm this file plus the
|
||||
// --no-config-overlay boot flag.
|
||||
func configDBPath(configuredPath string) string {
|
||||
return configuredPath + "-config.sqlite"
|
||||
}
|
||||
|
||||
func manualRequeueTask(ctx context.Context, st storecontract.TaskStore, taskID int64) error {
|
||||
task, err := st.TaskByID(ctx, taskID)
|
||||
if err != nil {
|
||||
@@ -318,11 +307,10 @@ func manualRequeueTask(ctx context.Context, st storecontract.TaskStore, taskID i
|
||||
}
|
||||
|
||||
type runArgs struct {
|
||||
cfgPath string
|
||||
overlayPath string
|
||||
noConfigOverlay bool
|
||||
once bool
|
||||
requeue int64
|
||||
cfgPath string
|
||||
overlayPath string
|
||||
once bool
|
||||
requeue int64
|
||||
}
|
||||
|
||||
func parseArgs() (runArgs, bool) {
|
||||
@@ -330,7 +318,6 @@ func parseArgs() (runArgs, bool) {
|
||||
var args runArgs
|
||||
flag.StringVar(&args.cfgPath, "config", defaultCfg, "path to a TOML/YAML config file or configuration directory")
|
||||
flag.StringVar(&args.overlayPath, "config-overlay", "", "path to a TOML/YAML overlay file or configuration directory applied on top of -config")
|
||||
flag.BoolVar(&args.noConfigOverlay, "no-config-overlay", false, "skip the runtime config overlay (recovery hatch for the DB overlay; the -config-overlay file overlay still applies)")
|
||||
flag.BoolVar(&args.once, "once", false, "run a single poll+process cycle and exit (systemd timer / testing)")
|
||||
flag.Int64Var(&args.requeue, "requeue", 0, "requeue a parked/waiting task by id (keeps its workflow), then exit unless -once is also set")
|
||||
showVersion := flag.Bool("version", false, "print the gateway and runtime versions and exit")
|
||||
@@ -366,7 +353,7 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
// The drain monitor cancels this root to trigger a graceful shutdown, which
|
||||
// propagates through ctx exactly as an operator SIGTERM does.
|
||||
b.shutdown = cancelRoot
|
||||
if err := b.loadConfig(ctx, args.cfgPath, args.overlayPath, args.noConfigOverlay); err != nil {
|
||||
if err := b.loadConfig(ctx, args.cfgPath, args.overlayPath); err != nil {
|
||||
return 1
|
||||
}
|
||||
defer b.cleanup()
|
||||
@@ -468,54 +455,6 @@ func (b *boot) wireConfigSurfaces(ctx context.Context, cfgPath, overlayPath stri
|
||||
b.publishConfigSnapshot(ctx)
|
||||
}
|
||||
|
||||
// bootConfigOverlay layers the runtime config overlay over the resolved
|
||||
// file config. Every failure degrades rather than aborts -- the daemon
|
||||
// boots on file config alone and the reason is recorded in bootOverlayErr,
|
||||
// which /api/config surfaces as the reload status. The returned store is
|
||||
// nil only when Open failed; a store that opened but could not be read
|
||||
// stays open and non-nil so the dashboard PATCH path and reload wiring
|
||||
// keep exactly the behaviour of the original inline block.
|
||||
func bootConfigOverlay(
|
||||
ctx context.Context,
|
||||
loader *configuration.Loader,
|
||||
doc *configuration.Document,
|
||||
bootOverlayErr *atomic.Pointer[string],
|
||||
log *slog.Logger,
|
||||
) (*overlay.Store, *configuration.Document) {
|
||||
store, err := overlay.Open(ctx, configDBPath(doc.Config.DBPath))
|
||||
if err != nil {
|
||||
recordBootOverlayError(bootOverlayErr, log, err,
|
||||
"config overlay unavailable; booting on file config alone",
|
||||
"path", configDBPath(doc.Config.DBPath))
|
||||
return nil, doc
|
||||
}
|
||||
overrides, err := store.Snapshot(ctx)
|
||||
if err != nil {
|
||||
recordBootOverlayError(bootOverlayErr, log, err,
|
||||
"config overlay unreadable; booting on file config alone")
|
||||
return store, doc
|
||||
}
|
||||
if len(overrides) == 0 {
|
||||
return store, doc
|
||||
}
|
||||
applied, err := loader.ApplyOverlay(doc, overrides)
|
||||
if err != nil {
|
||||
recordBootOverlayError(bootOverlayErr, log, err,
|
||||
"config overlay rejected by validation; booting on file config alone")
|
||||
return store, doc
|
||||
}
|
||||
return store, applied
|
||||
}
|
||||
|
||||
// recordBootOverlayError stores the degrade reason for /api/config and
|
||||
// logs it, so the operator sees both where they are looking.
|
||||
func recordBootOverlayError(p *atomic.Pointer[string], log *slog.Logger, err error, msg string, args ...any) {
|
||||
reason := err.Error()
|
||||
p.Store(&reason)
|
||||
args = append(args, "err", err)
|
||||
log.Error(msg, args...)
|
||||
}
|
||||
|
||||
// persistEvents drains the bus until it closes, giving each event an ID
|
||||
// from the store. The store is the only fan-out point (docs/architecture/
|
||||
// migration-decisions.md, "Dashboard live event delivery"): the UI process
|
||||
|
||||
@@ -33,7 +33,6 @@ type ReloadController struct {
|
||||
// (dotted keys -> typed values) to layer over the file config before
|
||||
// publishing. A failed overlay read or validation aborts the reload
|
||||
// exactly like a bad file.
|
||||
overlayValues func() (map[string]any, error)
|
||||
|
||||
status atomic.Pointer[config.ReloadStatus]
|
||||
}
|
||||
@@ -57,27 +56,6 @@ func (c *ReloadController) Reload() error {
|
||||
})
|
||||
return err
|
||||
}
|
||||
if c.overlayValues != nil {
|
||||
values, err := c.overlayValues()
|
||||
if err != nil {
|
||||
c.status.Store(&config.ReloadStatus{
|
||||
LastError: err.Error(),
|
||||
LastErrorAt: time.Now().UTC().Format(time.RFC3339),
|
||||
})
|
||||
return err
|
||||
}
|
||||
if len(values) > 0 {
|
||||
// ApplyOverlay never mutates its input: on failure the
|
||||
// resolved document (and the running config) is untouched.
|
||||
if doc, err = c.loader.ApplyOverlay(doc, values); err != nil {
|
||||
c.status.Store(&config.ReloadStatus{
|
||||
LastError: err.Error(),
|
||||
LastErrorAt: time.Now().UTC().Format(time.RFC3339),
|
||||
})
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
c.apply(doc)
|
||||
c.status.Store(&config.ReloadStatus{
|
||||
LastReloadAt: time.Now().UTC().Format(time.RFC3339),
|
||||
@@ -85,13 +63,6 @@ func (c *ReloadController) Reload() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// WithOverlay attaches the runtime config overlay source. Optional: a
|
||||
// controller without it publishes the file config alone.
|
||||
func (c *ReloadController) WithOverlay(fn func() (map[string]any, error)) *ReloadController {
|
||||
c.overlayValues = fn
|
||||
return c
|
||||
}
|
||||
|
||||
// Status returns the most recent reload outcome.
|
||||
func (c *ReloadController) Status() config.ReloadStatus {
|
||||
if p := c.status.Load(); p != nil {
|
||||
|
||||
@@ -2,7 +2,6 @@ package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -106,53 +105,6 @@ func TestReloadValidationFailureDoesNotApply(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReloadAppliesOverlayBeforePublish(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "config.toml")
|
||||
writeConfig(t, path, minimalConfigTOML("widget"))
|
||||
|
||||
loader := configuration.New(slog.New(slog.DiscardHandler))
|
||||
var published config.Config
|
||||
controller := newReloadController(loader, path, "", func(doc *configuration.Document) {
|
||||
published = doc.Config
|
||||
}).WithOverlay(func() (map[string]any, error) {
|
||||
return map[string]any{"poll_interval": "90s"}, nil
|
||||
})
|
||||
|
||||
if err := controller.Reload(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if published.PollInterval != config.Duration(90*time.Second) {
|
||||
t.Errorf("PollInterval = %v, want 90s (overlay applied before publish)", published.PollInterval)
|
||||
}
|
||||
}
|
||||
|
||||
// TestReloadOverlayFailureAborts pins that a failed overlay read or
|
||||
// validation aborts the reload exactly like a bad file: apply is not
|
||||
// called and the error is recorded.
|
||||
func TestReloadOverlayFailureAborts(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "config.toml")
|
||||
writeConfig(t, path, minimalConfigTOML("widget"))
|
||||
|
||||
loader := configuration.New(slog.New(slog.DiscardHandler))
|
||||
applied := 0
|
||||
controller := newReloadController(loader, path, "", func(*configuration.Document) { applied++ }).
|
||||
WithOverlay(func() (map[string]any, error) {
|
||||
return nil, errors.New("overlay unreadable")
|
||||
})
|
||||
|
||||
if err := controller.Reload(); err == nil {
|
||||
t.Fatal("expected an error from the failed overlay")
|
||||
}
|
||||
if applied != 0 {
|
||||
t.Fatalf("apply called %d times after overlay failure, want 0", applied)
|
||||
}
|
||||
if st := controller.Status(); st.LastError == "" {
|
||||
t.Fatal("expected LastError recorded")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReloadLoopAppliesOnSignalAndStopsOnCancel(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "config.toml")
|
||||
|
||||
@@ -75,7 +75,7 @@ type StateStoreOptions struct {
|
||||
func RunStateStore(ctx context.Context, options StateStoreOptions) error {
|
||||
b := newBootstrap()
|
||||
defer b.cleanup()
|
||||
if err := b.loadConfig(ctx, options.Config, options.Overlay, false); err != nil {
|
||||
if err := b.loadConfig(ctx, options.Config, options.Overlay); err != nil {
|
||||
return err
|
||||
}
|
||||
listen, err := resolveServiceListen("state", options.Listen, b.cfg.Services.Get(config.ServiceNameState).Listen)
|
||||
|
||||
@@ -9,10 +9,7 @@ import (
|
||||
|
||||
// TestLoadConfigWarnsOnUnknownKeys pins plan-config-drift.md step 3: a
|
||||
// stray/misspelled config key must be visible to the operator, not just
|
||||
// silently parsed, validated and dropped. noConfigOverlay:true keeps the
|
||||
// test to the file-load path alone, matching the recovery-hatch boot the
|
||||
// daemon uses when it cannot or should not touch the runtime overlay
|
||||
// store.
|
||||
// silently parsed, validated and dropped.
|
||||
func TestLoadConfigWarnsOnUnknownKeys(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.toml")
|
||||
writeConfig(t, path, minimalConfigTOML("widget")+"[containers]\nmax_concurrancy = 4\n")
|
||||
@@ -21,7 +18,7 @@ func TestLoadConfigWarnsOnUnknownKeys(t *testing.T) {
|
||||
log := slog.New(slog.NewTextHandler(&sb, &slog.HandlerOptions{Level: slog.LevelWarn}))
|
||||
b := &boot{log: log}
|
||||
|
||||
if err := b.loadConfig(t.Context(), path, "", true); err != nil {
|
||||
if err := b.loadConfig(t.Context(), path, ""); err != nil {
|
||||
t.Fatalf("loadConfig: %v (an unknown key must not fail the boot)", err)
|
||||
}
|
||||
|
||||
@@ -42,7 +39,7 @@ func TestLoadConfigDoesNotWarnOnAKnownConfig(t *testing.T) {
|
||||
log := slog.New(slog.NewTextHandler(&sb, &slog.HandlerOptions{Level: slog.LevelWarn}))
|
||||
b := &boot{log: log}
|
||||
|
||||
if err := b.loadConfig(t.Context(), path, "", true); err != nil {
|
||||
if err := b.loadConfig(t.Context(), path, ""); err != nil {
|
||||
t.Fatalf("loadConfig: %v", err)
|
||||
}
|
||||
|
||||
@@ -56,7 +53,7 @@ func TestLoadConfigMakesRuntimeSettingsAvailableBeforeSubsystemSetup(t *testing.
|
||||
writeConfig(t, path, minimalConfigTOML("widget"))
|
||||
b := &boot{log: slog.Default()}
|
||||
|
||||
if err := b.loadConfig(t.Context(), path, "", true); err != nil {
|
||||
if err := b.loadConfig(t.Context(), path, ""); err != nil {
|
||||
t.Fatalf("loadConfig: %v", err)
|
||||
}
|
||||
if b.cfgHolder == nil {
|
||||
|
||||
@@ -78,9 +78,6 @@ func TestComposeUIServerHoldsNoDaemonState(t *testing.T) {
|
||||
}
|
||||
|
||||
unwired := map[string]any{
|
||||
"UpdateConfig": srv.UpdateConfig,
|
||||
"ResetConfig": srv.ResetConfig,
|
||||
"UpdateRepoField": srv.UpdateRepoField,
|
||||
"ReloadChannel": srv.ReloadChannel,
|
||||
"RunningVersions": srv.RunningVersions,
|
||||
"Events": srv.Events,
|
||||
|
||||
@@ -113,7 +113,6 @@ func TestUIServesDashboardAgainstRemoteContracts(t *testing.T) {
|
||||
// links from, the same projection the task list uses.
|
||||
published, err := json.Marshal(webui.ConfigView{
|
||||
Identity: webui.IdentityView{BotUser: "archie", ForgeType: "github", ForgeHost: "https://forge.example"},
|
||||
Editable: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -256,9 +255,6 @@ func TestUIServesDashboardAgainstRemoteContracts(t *testing.T) {
|
||||
if rendered.Identity.BotUser != "archie" {
|
||||
t.Fatalf("config view = %s, want the published projection", body)
|
||||
}
|
||||
if rendered.Editable {
|
||||
t.Error("the UI process rendered configuration as editable; it has no write path")
|
||||
}
|
||||
req, err := http.NewRequestWithContext(t.Context(), http.MethodPatch, ts.URL+"/api/config", http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatalf("patch request: %v", err)
|
||||
@@ -268,8 +264,8 @@ func TestUIServesDashboardAgainstRemoteContracts(t *testing.T) {
|
||||
t.Fatalf("PATCH /api/config: %v", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusServiceUnavailable {
|
||||
t.Errorf("PATCH /api/config = %d, want 503: the daemon stays the configuration writer (PRD lines 95-96)", resp.StatusCode)
|
||||
if resp.StatusCode != http.StatusMethodNotAllowed {
|
||||
t.Errorf("PATCH /api/config = %d, want 405: configuration is read here and written through the control plane", resp.StatusCode)
|
||||
}
|
||||
|
||||
// The run-detail reads. These three routes have no fake behind them: the
|
||||
|
||||
@@ -14,11 +14,4 @@ type ReloadStatus struct {
|
||||
// LastReloadAt is the RFC3339 UTC timestamp of the most recent
|
||||
// successful reload. Empty until the first reload.
|
||||
LastReloadAt string `json:"last_reload_at,omitempty"`
|
||||
// OverlayUnavailable is the reason the runtime config overlay is not
|
||||
// in effect, so the running config is file-only. Set at boot when
|
||||
// the overlay store cannot be opened or its values fail validation,
|
||||
// and cleared by a successful dashboard write or reset. The
|
||||
// dashboard shows it so a boot-time degrade is visible where the
|
||||
// operator is looking, not only in logs.
|
||||
OverlayUnavailable string `json:"overlay_unavailable,omitempty"`
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package configuration
|
||||
|
||||
import "os"
|
||||
|
||||
// envSkipOverlay names the environment variable that disables runtime
|
||||
// config overlays. It is the recovery hatch for an overlay write that
|
||||
// leaves the daemon unable to boot: set ARCHIE_SKIP_CONFIG_OVERLAY=1
|
||||
// and the daemon boots from file config alone. The same switch exists
|
||||
// as the --no-config-overlay flag on archied.
|
||||
const envSkipOverlay = "ARCHIE_SKIP_CONFIG_OVERLAY"
|
||||
|
||||
// SkipOverlay reports whether runtime config overlays are disabled via
|
||||
// ARCHIE_SKIP_CONFIG_OVERLAY=1. The overlay source (a later step of the
|
||||
// config-editing work) consults this before loading; cmd/archied
|
||||
// OR-s its --no-config-overlay flag with this at startup.
|
||||
func SkipOverlay() bool {
|
||||
return os.Getenv(envSkipOverlay) == "1"
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package configuration
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSkipOverlayEnvSet(t *testing.T) {
|
||||
t.Setenv(envSkipOverlay, "1")
|
||||
if !SkipOverlay() {
|
||||
t.Fatal("SkipOverlay() = false with env set to 1")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSkipOverlayEnvUnset(t *testing.T) {
|
||||
t.Setenv(envSkipOverlay, "")
|
||||
if SkipOverlay() {
|
||||
t.Fatal("SkipOverlay() = true with env empty")
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
// Package overlay persists runtime-tunable configuration overrides in
|
||||
// their own SQLite file (cfg.DBPath + "-config.sqlite"), separate from
|
||||
// the task, conversation and search stores so each file owns its
|
||||
// user_version and its migrator with no contention.
|
||||
//
|
||||
// It backs the dashboard's config editing: a PATCH writes here, the
|
||||
// daemon layers these values over the file config at boot and on every
|
||||
// reload, and removing the file (or passing --no-config-overlay /
|
||||
// ARCHIE_SKIP_CONFIG_OVERLAY=1) is the documented recovery from a write
|
||||
// that would otherwise break boot.
|
||||
package overlay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
)
|
||||
|
||||
// DeniedKeys moved to internal/infrastructure/configuration ( DeniedKeys):
|
||||
// webui references the constant and must not link this package's SQLite
|
||||
// store (archie-core-8cda.5.6).
|
||||
var DeniedKeys = configuration.DeniedKeys
|
||||
|
||||
// Store is the config overlay database.
|
||||
type Store struct{ db *sql.DB }
|
||||
|
||||
const schemaVersion = 1
|
||||
|
||||
const schema = `
|
||||
CREATE TABLE IF NOT EXISTS config_overlay (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
updated_by TEXT NOT NULL
|
||||
);
|
||||
`
|
||||
|
||||
// Open opens (creating if needed) the overlay database and migrates it.
|
||||
func Open(ctx context.Context, path string) (*Store, error) {
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db, err := sql.Open("sqlite", sqliteDSN(path))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db.SetMaxOpenConns(1)
|
||||
if _, err := db.ExecContext(ctx, schema); err != nil {
|
||||
return nil, errors.Join(fmt.Errorf("overlay: init schema: %w", err), db.Close())
|
||||
}
|
||||
if err := migrate(ctx, db); err != nil {
|
||||
return nil, errors.Join(fmt.Errorf("overlay: migrate: %w", err), db.Close())
|
||||
}
|
||||
return &Store{db: db}, nil
|
||||
}
|
||||
|
||||
// Close closes the database.
|
||||
func (s *Store) Close() error { return s.db.Close() }
|
||||
|
||||
// sqliteDSN enables WAL and a busy timeout. Kept local to match the
|
||||
// task and gateway stores; deduplicating the three copies is a
|
||||
// follow-up, not part of this change.
|
||||
func sqliteDSN(path string) string {
|
||||
separator := "?"
|
||||
if strings.HasSuffix(path, "?") || strings.HasSuffix(path, "&") {
|
||||
separator = ""
|
||||
} else if strings.Contains(path, "?") {
|
||||
separator = "&"
|
||||
}
|
||||
return path + separator + "_pragma=journal_mode(WAL)&_pragma=busy_timeout(5000)"
|
||||
}
|
||||
|
||||
func migrate(ctx context.Context, db *sql.DB) error {
|
||||
tx, err := db.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
var version int
|
||||
if err := tx.QueryRowContext(ctx, `PRAGMA user_version`).Scan(&version); err != nil {
|
||||
return err
|
||||
}
|
||||
if version > schemaVersion {
|
||||
return fmt.Errorf("config overlay schema version %d is newer than supported version %d", version, schemaVersion)
|
||||
}
|
||||
if version == schemaVersion {
|
||||
return tx.Commit()
|
||||
}
|
||||
if _, err := tx.ExecContext(ctx, `PRAGMA user_version = 1`); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
// Set persists one override. key is a dotted config path
|
||||
// ("budgets.max_steps"); value is the JSON encoding of the field value
|
||||
// ("12", "\"60s\"", "true"). updatedBy names the writer for audit.
|
||||
// Keys in DeniedKeys are refused here as well as at the API layer.
|
||||
func (s *Store) Set(ctx context.Context, key, value, updatedBy string) error {
|
||||
if reason, denied := DeniedKeys[key]; denied {
|
||||
return fmt.Errorf("config key %s is not runtime-tunable: %s", key, reason)
|
||||
}
|
||||
_, err := s.db.ExecContext(ctx,
|
||||
`INSERT INTO config_overlay (key, value, updated_at, updated_by) VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT(key) DO UPDATE SET
|
||||
value = excluded.value, updated_at = excluded.updated_at, updated_by = excluded.updated_by`,
|
||||
key, value, time.Now().UTC().Format(time.RFC3339), updatedBy)
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete removes one override, restoring the file's value for that key.
|
||||
func (s *Store) Delete(ctx context.Context, key string) error {
|
||||
_, err := s.db.ExecContext(ctx, `DELETE FROM config_overlay WHERE key = ?`, key)
|
||||
return err
|
||||
}
|
||||
|
||||
// Keys lists the dotted keys the overlay sets, in sorted order. Snapshot
|
||||
// nests them into a config-shaped map for decoding, which loses the paths --
|
||||
// "budgets.max_steps" becomes out["budgets"]["max_steps"] and ranging over
|
||||
// that map yields "budgets". The dashboard marks overridden rows and offers a
|
||||
// per-row reset by dotted key, so it needs the keys as stored.
|
||||
func (s *Store) Keys(ctx context.Context) ([]string, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT key FROM config_overlay ORDER BY key`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() { _ = rows.Close() }()
|
||||
|
||||
var keys []string
|
||||
for rows.Next() {
|
||||
var key string
|
||||
if err := rows.Scan(&key); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
keys = append(keys, key)
|
||||
}
|
||||
return keys, rows.Err()
|
||||
}
|
||||
|
||||
// Snapshot returns every stored override as a nested map of typed
|
||||
// values ready to decode into config.Config. Dotted keys are nested:
|
||||
// "budgets.max_steps" becomes map["budgets"]["max_steps"]. Values are
|
||||
// JSON-decoded so the caller never has to know the field's type.
|
||||
func (s *Store) Snapshot(ctx context.Context) (map[string]any, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT key, value FROM config_overlay`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() { _ = rows.Close() }()
|
||||
|
||||
out := make(map[string]any)
|
||||
for rows.Next() {
|
||||
var key, raw string
|
||||
if err := rows.Scan(&key, &raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var value any
|
||||
if err := json.Unmarshal([]byte(raw), &value); err != nil {
|
||||
return nil, fmt.Errorf("overlay: key %s holds invalid JSON %q: %w", key, raw, err)
|
||||
}
|
||||
if err := Nest(out, key, value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// Nest inserts value into root at the dotted key path ("a.b.c" ->
|
||||
// root["a"]["b"]["c"]), creating intermediate maps as needed.
|
||||
func Nest(root map[string]any, key string, value any) error {
|
||||
parts := strings.Split(key, ".")
|
||||
if len(parts) == 0 || parts[0] == "" {
|
||||
return fmt.Errorf("overlay: empty key %q", key)
|
||||
}
|
||||
cur := root
|
||||
for _, part := range parts[:len(parts)-1] {
|
||||
next, ok := cur[part].(map[string]any)
|
||||
if !ok {
|
||||
next = make(map[string]any)
|
||||
cur[part] = next
|
||||
}
|
||||
cur = next
|
||||
}
|
||||
cur[parts[len(parts)-1]] = value
|
||||
return nil
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package overlay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func openTest(t *testing.T) (*Store, context.Context) {
|
||||
t.Helper()
|
||||
s, err := Open(context.Background(), filepath.Join(t.TempDir(), "config.sqlite"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = s.Close() })
|
||||
return s, context.Background()
|
||||
}
|
||||
|
||||
func TestSetGetSnapshotRoundTrip(t *testing.T) {
|
||||
s, ctx := openTest(t)
|
||||
|
||||
for _, tc := range []struct {
|
||||
key, value string
|
||||
}{
|
||||
{"budgets.max_steps", "12"},
|
||||
{"label", `"archie"`},
|
||||
{"containers.image", `"archie-agent:test"`},
|
||||
{"web.listen", `":8643"`},
|
||||
} {
|
||||
if err := s.Set(ctx, tc.key, tc.value, "test"); err != nil {
|
||||
t.Fatalf("Set(%s): %v", tc.key, err)
|
||||
}
|
||||
}
|
||||
|
||||
snap, err := s.Snapshot(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
budgets, ok := snap["budgets"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("budgets = %#v, want map", snap["budgets"])
|
||||
}
|
||||
if got := budgets["max_steps"]; !reflect.DeepEqual(got, float64(12)) {
|
||||
t.Errorf("budgets.max_steps = %#v, want float64(12)", got)
|
||||
}
|
||||
if got := snap["label"]; got != "archie" {
|
||||
t.Errorf("label = %#v, want archie", got)
|
||||
}
|
||||
containers, ok := snap["containers"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("containers = %#v, want map", snap["containers"])
|
||||
}
|
||||
if got := containers["image"]; got != "archie-agent:test" {
|
||||
t.Errorf("containers.image = %#v, want archie-agent:test", got)
|
||||
}
|
||||
web, ok := snap["web"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("web = %#v, want map", snap["web"])
|
||||
}
|
||||
if got := web["listen"]; got != ":8643" {
|
||||
t.Errorf("web.listen = %#v, want :8643", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetUpsertsAndDeleteRestores(t *testing.T) {
|
||||
s, ctx := openTest(t)
|
||||
|
||||
if err := s.Set(ctx, "label", `"first"`, "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.Set(ctx, "label", `"second"`, "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
snap, err := s.Snapshot(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if snap["label"] != "second" {
|
||||
t.Fatalf("after upsert, label = %#v, want second", snap["label"])
|
||||
}
|
||||
|
||||
if err := s.Delete(ctx, "label"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
snap, err = s.Snapshot(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(snap) != 0 {
|
||||
t.Fatalf("after delete, snapshot = %#v, want empty", snap)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetRefusesDeniedKeys(t *testing.T) {
|
||||
s, ctx := openTest(t)
|
||||
for key := range DeniedKeys {
|
||||
if err := s.Set(ctx, key, `"x"`, "test"); err == nil {
|
||||
t.Errorf("Set(%s) succeeded, want denial", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNestBuildsNestedMaps(t *testing.T) {
|
||||
root := map[string]any{}
|
||||
if err := Nest(root, "a.b.c", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := Nest(root, "a.b.d", "x"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a, ok := root["a"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("root[a] = %#v, want map", root["a"])
|
||||
}
|
||||
ab, ok := a["b"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("root[a][b] = %#v, want map", a["b"])
|
||||
}
|
||||
if ab["c"] != 1 || ab["d"] != "x" {
|
||||
t.Fatalf("nested map = %#v", root)
|
||||
}
|
||||
if err := Nest(root, "", 1); err == nil {
|
||||
t.Fatal("empty key accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenIdempotentAndVersioned(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.sqlite")
|
||||
s1, err := Open(context.Background(), path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = s1.Close()
|
||||
s2, err := Open(context.Background(), path)
|
||||
if err != nil {
|
||||
t.Fatalf("reopen: %v", err)
|
||||
}
|
||||
_ = s2.Close()
|
||||
}
|
||||
|
||||
// TestKeysReportsDottedPaths: Snapshot nests keys for decoding, so it cannot
|
||||
// answer "which keys are overridden" -- ranging over its result yields the
|
||||
// top-level section ("budgets"), not the stored key ("budgets.max_steps").
|
||||
// The dashboard marks rows and resets them by stored key, so Keys reports
|
||||
// those.
|
||||
func TestKeysReportsDottedPaths(t *testing.T) {
|
||||
store, ctx := openTest(t)
|
||||
for key, value := range map[string]string{
|
||||
"budgets.max_steps": "40",
|
||||
"budgets.wall_clock": `"30m"`,
|
||||
"label": `"archie"`,
|
||||
} {
|
||||
if err := store.Set(ctx, key, value, "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
keys, err := store.Keys(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := []string{"budgets.max_steps", "budgets.wall_clock", "label"}
|
||||
if len(keys) != len(want) {
|
||||
t.Fatalf("Keys = %v, want %v", keys, want)
|
||||
}
|
||||
for i, key := range want {
|
||||
if keys[i] != key {
|
||||
t.Errorf("Keys[%d] = %q, want %q (sorted, dotted)", i, keys[i], key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestKeysOnAnEmptyOverlay: nothing overridden is an empty list, not an error.
|
||||
func TestKeysOnAnEmptyOverlay(t *testing.T) {
|
||||
store, ctx := openTest(t)
|
||||
keys, err := store.Keys(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(keys) != 0 {
|
||||
t.Fatalf("Keys = %v, want none", keys)
|
||||
}
|
||||
}
|
||||
@@ -150,10 +150,6 @@ type ConfigView struct {
|
||||
// dashboard to the reason. The UI renders these rows disabled rather
|
||||
// than silently omitting the edit affordance.
|
||||
Locked map[string]string `json:"locked,omitempty"`
|
||||
// Overridden lists the dotted config keys currently set by the
|
||||
// runtime overlay, so the UI can mark those rows (their file value
|
||||
// is shadowed until reset) and offer a per-row reset.
|
||||
Overridden []string `json:"overridden,omitempty"`
|
||||
// MultiIdentity reports that the deployment configures [[identities]],
|
||||
// so Identity and Repositories describe the default identity alone.
|
||||
// Identities below carries the rest; a consumer attributing a task to
|
||||
@@ -167,11 +163,6 @@ type ConfigView struct {
|
||||
// Server.resolveForge (api_tasks.go). Empty for a single-identity
|
||||
// deployment, whose forge is Identity above.
|
||||
Identities []ForgeIdentityView `json:"identities,omitempty"`
|
||||
// Editable reports whether this process can apply configuration
|
||||
// changes. False makes the page render values without edit controls,
|
||||
// which is what a process that only displays a published snapshot can
|
||||
// honestly offer -- its write routes answer 503.
|
||||
Editable bool `json:"editable"`
|
||||
// Schema is the field-descriptor catalog (archie-core-b6ew) attached to
|
||||
// this view's own values, locked reasons, and overridden markers -- see
|
||||
// config_schema.go. The dashboard's generic renderer (archie-core-b6ew.3)
|
||||
@@ -330,9 +321,6 @@ func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, map[string]any{})
|
||||
return
|
||||
}
|
||||
// Editable belongs to the process that would perform the write, not to
|
||||
// the document: whoever holds the update path is the writer.
|
||||
view.Editable = s.UpdateConfig != nil
|
||||
writeJSON(w, view)
|
||||
}
|
||||
|
||||
@@ -346,8 +334,6 @@ type ConfigViewInput struct {
|
||||
// Provenance is the file chain that produced Config, in precedence
|
||||
// order.
|
||||
Provenance []ConfigOrigin
|
||||
// Overridden lists the dotted keys the runtime overlay currently sets.
|
||||
Overridden []string
|
||||
// Reload is the most recent reload outcome, or nil when unavailable.
|
||||
Reload *config.ReloadStatus
|
||||
}
|
||||
@@ -411,7 +397,6 @@ func BuildConfigView(in ConfigViewInput) ConfigView {
|
||||
ChannelConfigured: chatChannelConfigured(cfg.Chat),
|
||||
},
|
||||
Provenance: provenance,
|
||||
Overridden: in.Overridden,
|
||||
Reload: in.Reload,
|
||||
Locked: lockedConfigKeys(),
|
||||
}
|
||||
@@ -450,83 +435,15 @@ func RemoteConfigView(snapshots storecontract.ConfigSnapshotStore) ConfigViewSou
|
||||
}
|
||||
}
|
||||
|
||||
// handleConfigReset deletes one runtime-overlay row via ResetConfig,
|
||||
// restoring the file value for that key. The dashboard offers this on
|
||||
// overridden rows so it can remove an override it created.
|
||||
func (s *Server) handleConfigReset(w http.ResponseWriter, r *http.Request) {
|
||||
if s.ResetConfig == nil {
|
||||
http.Error(w, ErrConfigUpdateUnavailable.Error(), http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
var body struct {
|
||||
Key string `json:"key"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
http.Error(w, "invalid request body: "+err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if body.Key == "" {
|
||||
http.Error(w, "key required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if err := s.ResetConfig(r.Context(), body.Key); err != nil {
|
||||
switch {
|
||||
case errors.Is(err, ErrConfigUpdateUnavailable):
|
||||
http.Error(w, err.Error(), http.StatusServiceUnavailable)
|
||||
case errors.Is(err, ErrConfigUpdateInvalid):
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
http.Error(w, "config reset failed: "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
writeJSON(w, map[string]any{"ok": true})
|
||||
}
|
||||
|
||||
// lockedConfigKeys returns the dotted config keys the overlay refuses
|
||||
// to set, with the reason shown in the UI. These are the daemon's own
|
||||
// bootstrap inputs; changing them from the dashboard could break the
|
||||
// next boot.
|
||||
// lockedConfigKeys returns the dotted config keys that stay bootstrap-owned,
|
||||
// with the reason shown in the UI. These are the daemon's own startup inputs,
|
||||
// which the control plane deliberately does not manage.
|
||||
func lockedConfigKeys() map[string]string {
|
||||
out := make(map[string]string, len(configuration.DeniedKeys))
|
||||
maps.Copy(out, configuration.DeniedKeys)
|
||||
return out
|
||||
}
|
||||
|
||||
// handleConfigUpdate applies a set of dotted-path config updates via
|
||||
// UpdateConfig, which the composition root wires to the same
|
||||
// validate-persist-publish path as reload. The dashboard can then
|
||||
// change runtime-tunable settings without hand-editing TOML.
|
||||
func (s *Server) handleConfigUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
if s.UpdateConfig == nil {
|
||||
http.Error(w, ErrConfigUpdateUnavailable.Error(), http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
var body struct {
|
||||
Updates map[string]any `json:"updates"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
http.Error(w, "invalid request body: "+err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if len(body.Updates) == 0 {
|
||||
http.Error(w, "no updates provided", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if err := s.UpdateConfig(r.Context(), body.Updates); err != nil {
|
||||
switch {
|
||||
case errors.Is(err, ErrConfigUpdateUnavailable):
|
||||
http.Error(w, err.Error(), http.StatusServiceUnavailable)
|
||||
case errors.Is(err, ErrConfigUpdateInvalid):
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
http.Error(w, "config update failed: "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
writeJSON(w, map[string]any{"ok": true})
|
||||
}
|
||||
|
||||
func reposView(repos []config.Repo) []RepoView {
|
||||
out := make([]RepoView, 0, len(repos))
|
||||
for _, r := range repos {
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
package webui
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// RepoEditableFields are the per-repository fields the dashboard may change
|
||||
// through handleConfigRepoUpdate. Deliberately narrow: these three are
|
||||
// booleans/small ints with no cross-field validation, unlike Gate or
|
||||
// Protect, which stay file-edited (archie-core-b6ew.4/.6).
|
||||
var RepoEditableFields = map[string]bool{
|
||||
"allow_concurrent": true,
|
||||
"max_retries": true,
|
||||
"review_enabled": true,
|
||||
}
|
||||
|
||||
// handleConfigRepoUpdate applies one field change to one repository,
|
||||
// identified by owner/name in the path. It exists because the repository
|
||||
// list is a []config.Repo, not a flat dotted key -- PATCH /api/config's
|
||||
// generic path (overlay.Nest + configuration.ApplyOverlayValues) has no way
|
||||
// to address "element N of this slice." UpdateRepoField's implementation
|
||||
// (wired by the composition root) reads the daemon's own live config.Repo
|
||||
// values (never the trimmed, wire-safe RepoView), changes just the one
|
||||
// field, and republishes the full repository list through the same
|
||||
// validate-persist-publish path PATCH /api/config already uses -- see
|
||||
// bootstrap.go's installUpdateConfigHandler for why that matters: the wire
|
||||
// view omits fields (Preflight, TestGlob) that a naive round-trip through
|
||||
// ConfigView would silently drop.
|
||||
func (s *Server) handleConfigRepoUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
if s.UpdateRepoField == nil {
|
||||
http.Error(w, ErrConfigUpdateUnavailable.Error(), http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
owner := r.PathValue("owner")
|
||||
name := r.PathValue("name")
|
||||
var body struct {
|
||||
Field string `json:"field"`
|
||||
Value any `json:"value"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
http.Error(w, "invalid request body: "+err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if !RepoEditableFields[body.Field] {
|
||||
http.Error(w, "field "+body.Field+" is not editable from the dashboard", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if err := s.UpdateRepoField(r.Context(), owner, name, body.Field, body.Value); err != nil {
|
||||
switch {
|
||||
case errors.Is(err, ErrConfigUpdateUnavailable):
|
||||
http.Error(w, err.Error(), http.StatusServiceUnavailable)
|
||||
case errors.Is(err, ErrConfigUpdateInvalid):
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
http.Error(w, "repo update failed: "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
writeJSON(w, map[string]any{"ok": true})
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package webui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHandleConfigRepoUpdateAppliesViaSeam(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
type call struct {
|
||||
owner, name, field string
|
||||
value any
|
||||
}
|
||||
var got call
|
||||
srv.UpdateRepoField = func(_ context.Context, owner, name, field string, value any) error {
|
||||
got = call{owner, name, field, value}
|
||||
return nil
|
||||
}
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPatch, "/api/config/repos/acme/widget",
|
||||
strings.NewReader(`{"field": "allow_concurrent", "value": true}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, body = %s", w.Code, w.Body)
|
||||
}
|
||||
if got != (call{"acme", "widget", "allow_concurrent", true}) {
|
||||
t.Errorf("seam called with %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleConfigRepoUpdateRejectsUneditableFields proves the handler
|
||||
// itself refuses a field outside RepoEditableFields before ever calling the
|
||||
// seam -- Gate, Protect, and every other repo field stay file-edited.
|
||||
func TestHandleConfigRepoUpdateRejectsUneditableFields(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
called := false
|
||||
srv.UpdateRepoField = func(context.Context, string, string, string, any) error {
|
||||
called = true
|
||||
return nil
|
||||
}
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPatch, "/api/config/repos/acme/widget",
|
||||
strings.NewReader(`{"field": "gate", "value": [["rm", "-rf", "/"]]}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("status = %d, want 400", w.Code)
|
||||
}
|
||||
if called {
|
||||
t.Error("UpdateRepoField was called for a field outside RepoEditableFields")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleConfigRepoUpdateUnavailableMapsTo503(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
srv.UpdateRepoField = nil
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPatch, "/api/config/repos/acme/widget",
|
||||
strings.NewReader(`{"field": "allow_concurrent", "value": true}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusServiceUnavailable {
|
||||
t.Fatalf("status = %d, want 503", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleConfigRepoUpdateSeamErrorMapsTo400(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
srv.UpdateRepoField = func(context.Context, string, string, string, any) error {
|
||||
return ErrConfigUpdateInvalid
|
||||
}
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPatch, "/api/config/repos/acme/widget",
|
||||
strings.NewReader(`{"field": "max_retries", "value": 5}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("status = %d, want 400", w.Code)
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package webui
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
@@ -480,149 +479,6 @@ func TestHandleConfigSchemaNeverLeaksSecrets(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleConfigUpdateAppliesViaSeam proves the PATCH handler passes
|
||||
// the decoded updates to the wired UpdateConfig seam and answers ok.
|
||||
func TestHandleConfigUpdateAppliesViaSeam(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
var got map[string]any
|
||||
srv.UpdateConfig = func(_ context.Context, updates map[string]any) error {
|
||||
got = updates
|
||||
return nil
|
||||
}
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPatch, "/api/config",
|
||||
strings.NewReader(`{"updates": {"budgets.max_steps": 12}}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, body = %s", w.Code, w.Body)
|
||||
}
|
||||
if got["budgets.max_steps"] != float64(12) {
|
||||
t.Errorf("updates = %#v, want budgets.max_steps=12", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleConfigUpdateInvalidMapsTo400 proves a rejected update (the
|
||||
// seam wraps its error with ErrConfigUpdateInvalid) answers 400.
|
||||
func TestHandleConfigUpdateInvalidMapsTo400(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
srv.UpdateConfig = func(context.Context, map[string]any) error {
|
||||
return fmt.Errorf("%w: label is not runtime-tunable", ErrConfigUpdateInvalid)
|
||||
}
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPatch, "/api/config",
|
||||
strings.NewReader(`{"updates": {"label": "x"}}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("status = %d, want 400, body = %s", w.Code, w.Body)
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleConfigUpdateUnavailableMapsTo503 proves a disabled overlay
|
||||
// (ErrConfigUpdateUnavailable) answers 503, as does a server with no
|
||||
// UpdateConfig seam at all.
|
||||
func TestHandleConfigUpdateUnavailableMapsTo503(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
srv.UpdateConfig = func(context.Context, map[string]any) error {
|
||||
return fmt.Errorf("%w: overlay disabled by recovery flag", ErrConfigUpdateUnavailable)
|
||||
}
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPatch, "/api/config",
|
||||
strings.NewReader(`{"updates": {"label": "x"}}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusServiceUnavailable {
|
||||
t.Fatalf("status = %d, want 503, body = %s", w.Code, w.Body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleConfigUpdateWithoutSeamMapsTo503(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPatch, "/api/config",
|
||||
strings.NewReader(`{"updates": {"label": "x"}}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusServiceUnavailable {
|
||||
t.Fatalf("status = %d, want 503, body = %s", w.Code, w.Body)
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleConfigIncludesOverridden proves the overridden dotted keys
|
||||
// reach the view so the UI can mark rows shadowed by the runtime overlay.
|
||||
func TestHandleConfigIncludesOverridden(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
localView(srv, ConfigViewInput{
|
||||
Config: configWithFakeSecrets().Get(),
|
||||
Overridden: []string{"budgets.max_steps", "label"},
|
||||
})
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/config", nil)
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
var got ConfigView
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
if len(got.Overridden) != 2 || got.Overridden[0] != "budgets.max_steps" || got.Overridden[1] != "label" {
|
||||
t.Errorf("Overridden = %v, want [budgets.max_steps label]", got.Overridden)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleConfigResetCallsSeamAndAnswersOk(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
var got string
|
||||
srv.ResetConfig = func(_ context.Context, key string) error {
|
||||
got = key
|
||||
return nil
|
||||
}
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/config/reset",
|
||||
strings.NewReader(`{"key": "budgets.max_steps"}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, body = %s", w.Code, w.Body)
|
||||
}
|
||||
if got != "budgets.max_steps" {
|
||||
t.Errorf("ResetConfig called with %q, want budgets.max_steps", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleConfigResetWithoutSeamMapsTo503(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/config/reset",
|
||||
strings.NewReader(`{"key": "label"}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusServiceUnavailable {
|
||||
t.Fatalf("status = %d, want 503, body = %s", w.Code, w.Body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleConfigResetRejectsEmptyKey(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
srv.ResetConfig = func(context.Context, string) error { return nil }
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/config/reset",
|
||||
strings.NewReader(`{"key": ""}`))
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("status = %d, want 400, body = %s", w.Code, w.Body)
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleChannelsWithoutManagerIsEmpty: channel lifecycle is the status
|
||||
// manager's to report. A process without one answers an empty list rather
|
||||
// than deriving channels from configuration, which could only ever describe
|
||||
@@ -710,42 +566,6 @@ func TestRemoteConfigViewRendersThePublishedSnapshot(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestConfigViewEditableFollowsThisProcessWritePath: Editable describes the
|
||||
// rendering process, not the document. A published snapshot cannot make a
|
||||
// reader editable, and a process that holds the update path says so even
|
||||
// when the document it renders says otherwise.
|
||||
func TestConfigViewEditableFollowsThisProcessWritePath(t *testing.T) {
|
||||
render := func(t *testing.T, wireUpdate bool) ConfigView {
|
||||
t.Helper()
|
||||
srv := newTestServer(t)
|
||||
srv.ConfigSource = func(context.Context) (ConfigView, bool, error) {
|
||||
// The document claims editable; only the process decides.
|
||||
return ConfigView{Editable: true}, true, nil
|
||||
}
|
||||
if wireUpdate {
|
||||
srv.UpdateConfig = func(context.Context, map[string]any) error { return nil }
|
||||
}
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/config", nil)
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("GET /api/config = %d, want 200", w.Code)
|
||||
}
|
||||
var got ConfigView
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
return got
|
||||
}
|
||||
|
||||
if render(t, false).Editable {
|
||||
t.Error("Editable = true without an update path; the write routes answer 503")
|
||||
}
|
||||
if !render(t, true).Editable {
|
||||
t.Error("Editable = false with UpdateConfig wired; the page would hide controls that work")
|
||||
}
|
||||
}
|
||||
|
||||
// TestRemoteConfigViewRefusesAnUnknownSchema: a document whose shape this
|
||||
// build does not know is not something to render half of.
|
||||
func TestRemoteConfigViewRefusesAnUnknownSchema(t *testing.T) {
|
||||
|
||||
@@ -51,9 +51,6 @@ type ConfigField struct {
|
||||
// LockedReason is set per instance from the running config's denied
|
||||
// keys (configuration.DeniedKeys), not hand-authored here.
|
||||
LockedReason string `json:"locked_reason,omitempty"`
|
||||
// Overridden is set per instance from the running config's overlay
|
||||
// state, not hand-authored here.
|
||||
Overridden bool `json:"overridden"`
|
||||
// Options lists the valid values for a FieldEnum field.
|
||||
Options []string `json:"options,omitempty"`
|
||||
// RestartRequired reports that changing this field through the
|
||||
@@ -77,7 +74,7 @@ type ConfigSection struct {
|
||||
|
||||
// configFieldDescriptors is the hand-authored catalog: one entry per field
|
||||
// ConfigView exposes today, in the section grouping settings.js already
|
||||
// renders. Values, LockedReason and Overridden are attached separately
|
||||
// renders. Values and LockedReason are attached separately
|
||||
// against a live ConfigView (archie-core-b6ew.2); this list is the
|
||||
// data-independent half of the contract -- key, label, type, and the two
|
||||
// safety-relevant properties (editable, restart_required) that must be
|
||||
@@ -212,23 +209,17 @@ func configFieldValues(view ConfigView) map[string]any {
|
||||
// overridden markers to the static descriptor catalog, producing the
|
||||
// sections handleConfig returns to the dashboard. The catalog
|
||||
// (configFieldDescriptors) and the per-request state (configFieldValues,
|
||||
// view.Locked, view.Overridden) are kept as two separate functions
|
||||
// deliberately: one is data-independent and safe to unit-test as a fixed
|
||||
// catalog, the other is "what does this specific running config say."
|
||||
// view.Locked) are kept as two separate functions deliberately: one is
|
||||
// data-independent and safe to unit-test as a fixed catalog, the other is
|
||||
// "what does this specific running config say."
|
||||
func buildConfigSchema(view ConfigView) []ConfigSection {
|
||||
values := configFieldValues(view)
|
||||
overridden := make(map[string]bool, len(view.Overridden))
|
||||
for _, key := range view.Overridden {
|
||||
overridden[key] = true
|
||||
}
|
||||
|
||||
sections := configFieldDescriptors()
|
||||
for i := range sections {
|
||||
for j := range sections[i].Fields {
|
||||
f := §ions[i].Fields[j]
|
||||
f.Value = values[f.Key]
|
||||
f.LockedReason = view.Locked[f.Key]
|
||||
f.Overridden = overridden[f.Key]
|
||||
}
|
||||
}
|
||||
return sections
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestConfigFieldDescriptorsAreComplete(t *testing.T) {
|
||||
if f.Type != FieldEnum && len(f.Options) != 0 {
|
||||
t.Errorf("field %q has options but is not type enum", f.Key)
|
||||
}
|
||||
// Value/LockedReason/Overridden are attached per-instance
|
||||
// Value/LockedReason are attached per-instance
|
||||
// against a live ConfigView (archie-core-b6ew.2), not part of
|
||||
// the static catalog -- the catalog must not pre-populate them.
|
||||
if f.Value != nil {
|
||||
@@ -54,9 +54,6 @@ func TestConfigFieldDescriptorsAreComplete(t *testing.T) {
|
||||
if f.LockedReason != "" {
|
||||
t.Errorf("field %q has a static LockedReason; that is attached per-request", f.Key)
|
||||
}
|
||||
if f.Overridden {
|
||||
t.Errorf("field %q has a static Overridden; that is attached per-request", f.Key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,27 +53,6 @@ type Server struct {
|
||||
// of them is about configuration.
|
||||
TaskLogs TaskLogSource
|
||||
|
||||
// UpdateConfig applies a set of dotted-path config updates through
|
||||
// the same validate-persist-publish path as reload (wired by the
|
||||
// composition root). Optional: when nil, PATCH /api/config answers
|
||||
// 503. The handler never touches the Cfg Holder directly -- see the
|
||||
// Cfg field doc.
|
||||
UpdateConfig func(context.Context, map[string]any) error
|
||||
|
||||
// ResetConfig deletes one runtime-overlay row and republishes file +
|
||||
// remaining overlay. Optional: when nil, POST /api/config/reset
|
||||
// answers 503. Like UpdateConfig, it never touches the Cfg Holder
|
||||
// directly.
|
||||
ResetConfig func(context.Context, string) error
|
||||
|
||||
// UpdateRepoField changes one editable field (RepoEditableFields) on
|
||||
// the repository identified by owner/name, republishing the full
|
||||
// repository list through the same path as UpdateConfig. Optional:
|
||||
// when nil, PATCH /api/config/repos/{owner}/{name} answers 503. See
|
||||
// handleConfigRepoUpdate for why this needs its own seam rather than
|
||||
// going through UpdateConfig's dotted-key path directly.
|
||||
UpdateRepoField func(ctx context.Context, owner, name, field string, value any) error
|
||||
|
||||
// Channels reports actual adapter lifecycle, independently of configuration
|
||||
// presence. Nil preserves the configuration-only fallback for tests and
|
||||
// minimal embedding.
|
||||
@@ -276,9 +255,6 @@ func (s *Server) registerConfigAndLogRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("POST /api/identities", s.handleIdentityCreate)
|
||||
mux.HandleFunc("POST /api/identities/{id}/{command}", s.handleIdentityCommand)
|
||||
mux.HandleFunc("GET /api/config", s.handleConfig)
|
||||
mux.HandleFunc("PATCH /api/config", s.handleConfigUpdate)
|
||||
mux.HandleFunc("POST /api/config/reset", s.handleConfigReset)
|
||||
mux.HandleFunc("PATCH /api/config/repos/{owner}/{name}", s.handleConfigRepoUpdate)
|
||||
mux.HandleFunc("GET /api/logs", s.handleLogs)
|
||||
mux.HandleFunc("GET /api/logs/stream", s.handleLogStream)
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
.identities-page[data-v-8ab739de]{max-width:960px}.identity-create[data-v-8ab739de]{gap:.75rem;margin:1.5rem 0;display:flex}.identity-create input[data-v-8ab739de]{flex:1}.identity-create input[data-v-8ab739de],.identity-create select[data-v-8ab739de],.identity-create button[data-v-8ab739de],.actions button[data-v-8ab739de]{border:1px solid var(--border);background:var(--surface);color:inherit;border-radius:.5rem;padding:.6rem .8rem}.identity-list[data-v-8ab739de]{border-top:1px solid var(--border)}.identity-row[data-v-8ab739de]{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:1rem;padding:1rem 0;display:flex}.identity-row span[data-v-8ab739de]{color:var(--muted-foreground);text-transform:capitalize;margin-top:.2rem;font-size:.85rem;display:block}.actions[data-v-8ab739de]{gap:.5rem;display:flex}.actions .danger[data-v-8ab739de],.error[data-v-8ab739de]{color:var(--destructive)}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-scrollbar-thumb:#0000;--tw-scrollbar-track:#0000;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@layer theme{:root,:host{--font-sans:"Geist Variable", sans-serif;--color-black:#000;--spacing:.25rem;--container-xs:20rem;--container-sm:24remLine truncated
|
||||
.identities-page[data-v-8ab739de]{max-width:960px}.identity-create[data-v-8ab739de]{gap:.75rem;margin:1.5rem 0;display:flex}.identity-create input[data-v-8ab739de]{flex:1}.identity-create input[data-v-8ab739de],.identity-create select[data-v-8ab739de],.identity-create button[data-v-8ab739de],.actions button[data-v-8ab739de]{border:1px solid var(--border);background:var(--surface);color:inherit;border-radius:.5rem;padding:.6rem .8rem}.identity-list[data-v-8ab739de]{border-top:1px solid var(--border)}.identity-row[data-v-8ab739de]{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:1rem;padding:1rem 0;display:flex}.identity-row span[data-v-8ab739de]{color:var(--muted-foreground);text-transform:capitalize;margin-top:.2rem;font-size:.85rem;display:block}.actions[data-v-8ab739de]{gap:.5rem;display:flex}.actions .danger[data-v-8ab739de],.error[data-v-8ab739de]{color:var(--destructive)}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-scrollbar-thumb:#0000;--tw-scrollbar-track:#0000;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@layer theme{:root,:host{--font-sans:"Geist Variable", sans-serif;--color-black:#000;--spacing:.25rem;--container-xs:20rem;--container-sm:24remLine truncated
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
|
||||
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
|
||||
`)&&(ki(e,0)||yi(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||c(a)&&!re(a)||a[0]===`.`||t&&!re(a)||u&&u.includes(a)){if(Ei(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&cn(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&Ns(x,n,t),h&&wr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&ls(()=>{x&&Ns(x,n,t),l&&g.enter(e),h&&wr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=As(d[t]),g=h.type===fs;e?(g&&!u&&t+1<p&&As(d[t+1]).type===fs&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,ki(r,1)||yi()),n(null,h,r,null,o,s,Si(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&Ci(f)&&f.data===`]`?a(t.anchor=f):(yi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,c,l)=>{if(ji(e,t)||yi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)s(n);else break}}let u=a(e),d=o(e);return s(e),n(null,t,d,u,r,i,Si(d),c),r&&(r.vnode.el=t.el,So(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&Ci(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var Ti=new Set([`src`,`srcset`,`href`,`poster`]);function Ei(e,t,n){return Ti.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var Di=`data-allow-mismatch`,Oi={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function ki(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(Di);)e=e.parentElement;return Ai(e&&e.getAttribute(Di),t)}function Ai(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(Oi[t])}}function ji(e,t){return ki(e.parentElement,1)||Mi(e)||Ni(t)}function Mi(e){return e.nodeType===1&&Ai(e.getAttribute(Di),1)}function Ni({props:e}){let t=e&&e[Di];return typeof t==`string`&&Ai(t,1)}var Pi=ge().requestIdleCallback||(e=>setTimeout(e,1)),Fi=ge().cancelIdleCallback||(e=>clearTimeout(e)),Ii=(e=1e4)=>t=>{let n=Pi(t,{timeout:e});return()=>Fi(n)};function Li(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var Ri=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(Li(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},zi=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},Bi=(e=[])=>(t,n)=>{b(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Vi(e,t){if(Ci(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(Ci(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Hi=e=>!!e.type.__asyncLoader;function Ui(e){y(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return N({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Vi(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=Ls;if(fi(e),u)return()=>Wi(u,e);let t=t=>{l=null,Xn(t,e,13,!r)};if(s&&e.suspense||Ws)return p().then(t=>()=>Wi(t,e)).catch(e=>(t(e),()=>r?V(r,{error:e}):null));let a=k(!1),c=k(),d=k(!!i),f,m;return sa(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&Gi(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Wi(u,e);if(c.value&&r)return V(r,{error:c.value});if(n&&
Line truncated
|
||||
`))),e[Gl]=Hl(i);let a=r||i.props&&i.props.type===`number`;ll(e,t?`change`:`input`,t=>{t.target.composing||e[Gl](ql(e.value,n,a))}),(n||a)&&ll(e,`change`,()=>{e.value=ql(e.value,n,a)}),t||(ll(e,`compositionstart`,Ul),ll(e,`compositionend`,Wl),ll(e,`change`,Wl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[Kl];delete e[Kl],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Gl](ql(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Gl]=Hl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?pe(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Yl={deep:!0,created(e,t,n){e[Gl]=Hl(n),ll(e,`change`,()=>{let t=e._modelValue,n=tu(e),r=e.checked,i=e[Gl];if(m(t)){let e=Me(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(g(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(nu(e,r))})},mounted:Xl,beforeUpdate(e,t,n){e[Gl]=Hl(n),Xl(e,t,n)}};function Xl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(m(t))i=Me(t,r.props.value)>-1;else if(g(t))i=t.has(r.props.value);else{if(t===n)return;i=je(t,nu(e,!0))}e.checked!==i&&(e.checked=i)}var Zl={created(e,{value:t},n){e.checked=je(t,n.props.value),e[Gl]=Hl(n),ll(e,`change`,()=>{e[Gl](tu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Gl]=Hl(r),t!==n&&(e.checked=je(t,r.props.value))}},Ql={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,ll(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?pe(tu(e)):tu(e)),r=e.multiple,i=r?g(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?m(i)?t.slice():t:i];try{e[Gl](i)}finally{ar(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Gl]=Hl(r)},mounted(e,{value:t}){eu(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Gl]=Hl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!$l(t,n[1],n[0]))&&eu(e,t)}};function $l(e,t,n){if(!n||m(e))return je(e,t);if(g(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function eu(e,t){let n=e.multiple,r=m(t);if(!n||r||g(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=tu(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Me(t,o)>-1}else a.selected=t.has(o)}else if(je(tu(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function tu(e){return`_value`in e?e._value:e.value}function nu(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var ru={created(e,t,n){au(e,t,n,null,`created`)},mounted(e,t,n){au(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){au(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){au(e,t,n,r,`updated`)}};function iu(e,t){switch(e){case`SELECT`:return Ql;case`TEXTAREA`:return Jl;default:switch(t){case`checkbox`:return Yl;case`radio`:return Zl;default:return Jl}}}function au(e,t,n,r,i){let a=iu(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function ou(){Jl.getSSRProps=({value:e})=>({value:e}),Zl.getSSRProps=({value:e},t)=>{if(t.props&&je(t.props.value,e))return{checked:!0}},Yl.getSSRProps=({value:e},t)=>{if(m(e)){if(t.props&&Me(e,t.props.value)>-1)return{checked:!0}}else if(g(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},ru.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=iu(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var su=[`ctrl`,`shift`,`alt`,`meta`],cu={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>su.some(n=>e[`${n}Key`]&&!t.includes(n))},lu=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=cu[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},uu={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},du=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=ce(n.key);if(t.some(e=>e===r||uu[e]===r))return e(n)}))},fu=u({patchProp:xl},xc),pu,mu=!1;function hu(){return pu||=Ho(fu)}function gu(){return pu=mu?pu:Uo(fu),mu=!0,pu}var _u=((...e)=>{hu().render(...e)}),vu=((...e)=>{gu().hydrate(...e)}),yu=((...e)=>{let t=hu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Su(e);if(!r)return;let i=t._component;!y(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,xu(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),bu=((
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Op;function kp(e){Op=e}var Ap=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function jp(e){let t=e instanceof Ap?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Mp(e,t){let n=await fetch(e,t);if(Op?.(n.status===401),!n.ok)throw new Ap(await Dp(n),n.status);return n}async function Np(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Tp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Mp(e,s);return a?await c.json():void 0}var Y={health:()=>Np(`/health/detailed`),summary:()=>Np(`/api/summary`),tasks:()=>Np(`/api/tasks`),taskMeta:()=>Np(`/api/task-meta`),task:e=>Np(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Np(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Np(`/api/tasks/${encodeURIComponent(e)}/changes`+Ep(t)),taskDebug:(e,t)=>Np(`/api/tasks/${encodeURIComponent(e)}/debug`+Ep(t)),taskAction:(e,t)=>Np(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t}}),setup:()=>Np(`/api/setup`),capabilities:()=>Np(`/api/capabilities`),workflows:()=>Np(`/api/workflows`),workRequest:e=>Np(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Np(`/api/skills`),channels:()=>Np(`/api/channels`),curators:()=>Np(`/api/curators`),channelReload:e=>Np(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Np(`/api/config`),configUpdate:e=>Np(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>Np(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>Np(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>Np(`/api/logs`+Ep(e)),taskLogs:(e,t)=>Np(`/api/tasks/${encodeURIComponent(e)}/logs`+Ep(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>Np(`/api/captures`+Ep({limit:e})),mappings:()=>Np(`/api/mappings`),mappingCreate:e=>Np(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Np(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Np(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Np(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Np(`/api/bindings`),bindingCreate:e=>Np(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Np(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Np(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Np(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),chatSessions:()=>Np(`/api/chat/sessions`),chatMessages:e=>Np(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Np(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Np(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Np(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:wp(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Np(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Np(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Np(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Np(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Mp(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Pp(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Fp(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(Cp(n.readyState)),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}var Ip=`archie.web.chat.channel`;function Lp(){let e=localStorage.getItem(Ip);return e||(e=wp(),localStorage.setItem(Ip,e)),e}var Rp=/(?:^|\s)\/([^\s]*)$/,zp=/(?:^|\s)\/[^\s]*$/,Bp=8;function Vp(e,t,n){let r=t.slice(0,n).match(Rp);if(!r)return[];let i=r[1].toLowerCase();return e.filter(e=>`${e.command} ${e.description??``}`.toLowerCase().includes(i)).slice(0,Bp)}function Hp(e,t,n){let r=e.slice(0,t),i=e.slice(t),a=r.search(zp),o=a<0?r.length:a+ +(r[a]===` `);return{text:`${r.slice(0,o)}${n} ${i}`,cursor:o+n.length+1}}function Up(e,t){let n=t.trim();return e.some(e=>e.command===n)}function Wp(e){return{text:e,sourceID:wp()}}function Gp(e){return{...e}}fun
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Op;function kp(e){Op=e}var Ap=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function jp(e){let t=e instanceof Ap?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Mp(e,t){let n=await fetch(e,t);if(Op?.(n.status===401),!n.ok)throw new Ap(await Dp(n),n.status);return n}async function Np(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Tp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Mp(e,s);return a?await c.json():void 0}var Y={health:()=>Np(`/health/detailed`),summary:()=>Np(`/api/summary`),tasks:()=>Np(`/api/tasks`),taskMeta:()=>Np(`/api/task-meta`),task:e=>Np(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Np(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Np(`/api/tasks/${encodeURIComponent(e)}/changes`+Ep(t)),taskDebug:(e,t)=>Np(`/api/tasks/${encodeURIComponent(e)}/debug`+Ep(t)),taskAction:(e,t)=>Np(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t}}),setup:()=>Np(`/api/setup`),capabilities:()=>Np(`/api/capabilities`),workflows:()=>Np(`/api/workflows`),workRequest:e=>Np(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Np(`/api/skills`),channels:()=>Np(`/api/channels`),curators:()=>Np(`/api/curators`),channelReload:e=>Np(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Np(`/api/config`),logs:e=>Np(`/api/logs`+Ep(e)),taskLogs:(e,t)=>Np(`/api/tasks/${encodeURIComponent(e)}/logs`+Ep(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>Np(`/api/captures`+Ep({limit:e})),mappings:()=>Np(`/api/mappings`),mappingCreate:e=>Np(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Np(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Np(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Np(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Np(`/api/bindings`),bindingCreate:e=>Np(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Np(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Np(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Np(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),chatSessions:()=>Np(`/api/chat/sessions`),chatMessages:e=>Np(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Np(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Np(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Np(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:wp(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Np(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Np(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Np(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Np(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Mp(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Pp(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Fp(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(Cp(n.readyState)),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}var Ip=`archie.web.chat.channel`;function Lp(){let e=localStorage.getItem(Ip);return e||(e=wp(),localStorage.setItem(Ip,e)),e}var Rp=/(?:^|\s)\/([^\s]*)$/,zp=/(?:^|\s)\/[^\s]*$/,Bp=8;function Vp(e,t,n){let r=t.slice(0,n).match(Rp);if(!r)return[];let i=r[1].toLowerCase();return e.filter(e=>`${e.command} ${e.description??``}`.toLowerCase().includes(i)).slice(0,Bp)}function Hp(e,t,n){let r=e.slice(0,t),i=e.slice(t),a=r.search(zp),o=a<0?r.length:a+ +(r[a]===` `);return{text:`${r.slice(0,o)}${n} ${i}`,cursor:o+n.length+1}}function Up(e,t){let n=t.trim();return e.some(e=>e.command===n)}function Wp(e){return{text:e,sourceID:wp()}}function Gp(e){return{...e}}function Kp(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?Gp(e.turn):Wp(r),isRetry:n}}var qp=`chat-panel`,Jp=12e4,Yp=k([]),Xp=k(``),Zp=k([]),Qp=k(``),$p=k(`Ready`),em=k(!1),tm=k(null),nm=k({}),rm=k(``),im=k
Line truncated
|
||||
|
||||
`);u=r.pop()||``;for(let e of r){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(Xp.value=n.session_id),n.type===`delta`&&(o+=n.text,tm.value=tm.value?{...tm.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],tm.value=tm.value?{...tm.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);Zp.value=[...Zp.value,{from:`assistant`,text:o,tool_calls:a}],tm.value=null,$p.value=`Ready`,await gm()}catch(e){let t=e;t.name===`AbortError`&&!c?(tm.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},$p.value=`Stopped`):(tm.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?Gp(r):void 0,isRetry:i},$p.value=`Error — retry available`)}finally{clearTimeout(l),mm=null,em.value=!1}}function km(){$p.value=`Stopping…`,Xp.value&&Y.chatCancel(Xp.value).catch(()=>{}),hm()}function Am(){ra(()=>{gm().catch(e=>{$p.value=e.message||`Chat unavailable`})}),sa(()=>{hm()})}var jm=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Mm=N({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return J(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(L(),R(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full bg-linear-to-br from-primary to-[var(--brand-alt)] text-primary-foreground shadow-[var(--shadow-md)] transition-[transform,box-shadow] duration-[140ms] hover:-translate-y-px hover:shadow-[0_12px_34px_var(--primary-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":A(qp),onClick:i[0]||=e=>n(`toggle`)},[B(`span`,{"aria-hidden":`true`,class:D(r(!e.open))},[V(A(jd),{size:22})],2),B(`span`,{"aria-hidden":`true`,class:D(r(e.open))},[V(A(qd),{size:22})],2)],8,jm))}});function Nm(e){return typeof e==`string`?`'${e}'`:new Lm().serialize(e)}var Pm=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Fm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Pm.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Im(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Fm[n]?Fm[n]:n+128,s=a<128&&Fm[a]?Fm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var Lm=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Im(e,t):n===`number`&&r===`number`?e-t:Im(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Im),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`InLine truncated
|
||||
|
||||
@@ -140,13 +140,6 @@ export const api = {
|
||||
channelReload: <T = unknown>(id: string) =>
|
||||
request<T>(`/api/channels/${encodeURIComponent(id)}/reload`, { method: "POST", body: {} }),
|
||||
config: <T = unknown>() => request<T>("/api/config"),
|
||||
configUpdate: <T = unknown>(updates: Payload) => request<T>("/api/config", { method: "PATCH", body: { updates } }),
|
||||
configRepoUpdate: <T = unknown>(owner: string, name: string, field: string, value: unknown) =>
|
||||
request<T>(`/api/config/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`, {
|
||||
method: "PATCH",
|
||||
body: { field, value },
|
||||
}),
|
||||
configReset: <T = unknown>(key: string) => request<T>("/api/config/reset", { method: "POST", body: { key } }),
|
||||
logs: <T = unknown>(params?: QueryParams) => request<T>("/api/logs" + qs(params)),
|
||||
taskLogs: <T = unknown>(id: string, params?: QueryParams) =>
|
||||
request<T>(`/api/tasks/${encodeURIComponent(id)}/logs` + qs(params)),
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import type { ConfigFieldType } from "./types";
|
||||
|
||||
/**
|
||||
* The editor for one config field: a text input, or a select for the two types
|
||||
* whose value is a closed set.
|
||||
*
|
||||
* It owns focus -- the row mounts it the moment the row enters edit mode, so
|
||||
* the first keystroke lands in the control -- and reports Enter and Escape.
|
||||
* Saving and cancelling belong to the row, which is what knows whether what
|
||||
* was typed can be sent.
|
||||
*
|
||||
* Enter commits for the text input only. reka's select opens its listbox on
|
||||
* Enter, so a select commits through its own listbox and the row's Save.
|
||||
*/
|
||||
const props = defineProps<{
|
||||
modelValue: string;
|
||||
type: ConfigFieldType;
|
||||
options?: string[];
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": [string];
|
||||
save: [];
|
||||
cancel: [];
|
||||
}>();
|
||||
|
||||
const BOOL_OPTIONS = ["true", "false"];
|
||||
|
||||
function update(value: unknown): void {
|
||||
emit("update:modelValue", String(value ?? ""));
|
||||
}
|
||||
|
||||
const vFocus = {
|
||||
mounted: (el: HTMLElement) => {
|
||||
el.focus();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Select
|
||||
v-if="props.type === 'bool' || props.type === 'enum'"
|
||||
:model-value="props.modelValue"
|
||||
:disabled="props.disabled"
|
||||
@update:model-value="update"
|
||||
>
|
||||
<SelectTrigger v-focus class="w-full" :aria-label="props.type === 'bool' ? 'Value' : 'Option'">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem v-for="option in props.type === 'bool' ? BOOL_OPTIONS : props.options || []" :key="option" :value="option">
|
||||
{{ option }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input
|
||||
v-else
|
||||
v-focus
|
||||
:model-value="props.modelValue"
|
||||
:disabled="props.disabled"
|
||||
autocomplete="off"
|
||||
@update:model-value="update"
|
||||
@keydown.enter.prevent="emit('save')"
|
||||
@keydown.esc="emit('cancel')"
|
||||
/>
|
||||
</template>
|
||||
+19
-110
@@ -1,26 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { api } from "@/lib/api";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { parseEdit, valueText } from "./config-field";
|
||||
import ConfigControl from "./ConfigControl.vue";
|
||||
import { errorText, loadConfig } from "./state";
|
||||
import { valueText } from "./config-field";
|
||||
import type { ConfigField } from "./types";
|
||||
|
||||
/**
|
||||
* One row of a key/value list: the label, the value the process is running
|
||||
* with, and -- when the field is editable and this process holds the write
|
||||
* path -- the edit and reset controls.
|
||||
* One row of a key/value list: the label and the value the process is running
|
||||
* with. Configuration is written through the control plane, so this list
|
||||
* reports what is in effect and never offers a control of its own.
|
||||
*
|
||||
* A locked field shows its value and the reason instead of a control: those
|
||||
* keys are the daemon's own bootstrap inputs, and changing one from here could
|
||||
* break the next boot. A process serving a published snapshot has no write
|
||||
* path at all, so it renders every editable field as a value rather than a
|
||||
* control that would answer 503 (archie-core-ymut).
|
||||
* A locked field shows the reason it stays bootstrap-owned: those keys are the
|
||||
* daemon's own startup inputs and the control plane deliberately does not
|
||||
* manage them.
|
||||
*
|
||||
* Every row is a subgrid of the list's three tracks, so the columns line up
|
||||
* across rows; see ConfigList.
|
||||
@@ -28,67 +21,12 @@ import type { ConfigField } from "./types";
|
||||
const props = defineProps<{
|
||||
label: string;
|
||||
value?: unknown;
|
||||
/** The descriptor that makes the row editable. Absent for a value-only row,
|
||||
* which is what the provenance list uses. */
|
||||
/** The descriptor carrying the row's description and locked reason. */
|
||||
field?: ConfigField;
|
||||
/** Whether the serving process can apply changes at all. */
|
||||
editable?: boolean;
|
||||
}>();
|
||||
|
||||
const text = computed(() => valueText(props.value));
|
||||
|
||||
const editing = ref(false);
|
||||
const draft = ref("");
|
||||
const error = ref<string | null>(null);
|
||||
const saving = ref(false);
|
||||
const resetting = ref(false);
|
||||
|
||||
const lockedReason = computed(() => props.field?.locked_reason ?? "");
|
||||
const overridden = computed(() => Boolean(props.field?.overridden));
|
||||
const canEdit = computed(() => Boolean(props.field?.editable) && props.editable !== false && !lockedReason.value);
|
||||
|
||||
function startEdit(): void {
|
||||
if (!props.field) return;
|
||||
draft.value = String(props.field.value ?? "");
|
||||
error.value = null;
|
||||
editing.value = true;
|
||||
}
|
||||
|
||||
async function save(): Promise<void> {
|
||||
const target = props.field;
|
||||
if (!target) return;
|
||||
const parsed = parseEdit(target.type, draft.value);
|
||||
if (parsed.error) {
|
||||
error.value = parsed.error;
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
await api.configUpdate({ [target.key]: parsed.value });
|
||||
editing.value = false;
|
||||
await loadConfig();
|
||||
} catch (err) {
|
||||
error.value = errorText(err);
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function reset(): Promise<void> {
|
||||
const target = props.field;
|
||||
if (!target) return;
|
||||
resetting.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
await api.configReset(target.key);
|
||||
await loadConfig();
|
||||
} catch (err) {
|
||||
error.value = errorText(err);
|
||||
} finally {
|
||||
resetting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -106,9 +44,7 @@ async function reset(): Promise<void> {
|
||||
label and holding focus keeps the description on screen. The
|
||||
aria-label carries the label and the description together, because
|
||||
the tooltip content itself is out of the accessibility tree when the
|
||||
trigger is not hovered or focused. No visual change -- the focus
|
||||
floor in style.css draws the only new affordance, and only on
|
||||
keyboard focus.
|
||||
trigger is not hovered or focused.
|
||||
-->
|
||||
<span tabindex="0" :aria-label="`${label}: ${field.description}`" class="text-sm text-fg-muted">{{ label }}</span>
|
||||
</TooltipTrigger>
|
||||
@@ -116,43 +52,16 @@ async function reset(): Promise<void> {
|
||||
</Tooltip>
|
||||
<span v-else class="text-sm text-fg-muted">{{ label }}</span>
|
||||
|
||||
<template v-if="editing && field">
|
||||
<ConfigControl v-model="draft" :type="field.type" :options="field.options" :disabled="saving" @save="save" @cancel="editing = false" />
|
||||
<div class="flex items-center gap-2 justify-self-end">
|
||||
<Button size="sm" :disabled="saving" @click="save">Save</Button>
|
||||
<Button variant="outline" size="sm" :disabled="saving" @click="editing = false">Cancel</Button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<!-- min-w-0 is load-bearing: a grid item refuses to shrink below its
|
||||
content by default, which is what pushed long paths into the action
|
||||
column and truncated them against the buttons. -->
|
||||
<slot name="value">
|
||||
<span
|
||||
:class="cn('min-w-0 break-words font-mono text-sm min-[701px]:truncate', text === '—' ? 'text-fg-subtle' : 'text-foreground', lockedReason && 'text-fg-muted')"
|
||||
:title="text"
|
||||
>{{ text }}</span>
|
||||
</slot>
|
||||
<!-- The controls sit in the row rather than appearing on hover: one that
|
||||
only exists on hover is invisible to touch and to anyone scanning
|
||||
for what is editable. -->
|
||||
<div v-if="canEdit" class="flex items-center gap-2 justify-self-end">
|
||||
<Badge v-if="overridden" variant="warn" title="Set from the dashboard; this shadows the value in the config file">overridden</Badge>
|
||||
<Button variant="ghost" size="sm" :title="`Edit ${label}`" @click="startEdit">Edit</Button>
|
||||
<Button
|
||||
v-if="overridden"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
title="Discard the dashboard value and fall back to the config file"
|
||||
:disabled="resetting"
|
||||
@click="reset"
|
||||
>
|
||||
Reset
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- min-w-0 is load-bearing: a grid item refuses to shrink below its
|
||||
content by default, which is what pushed long paths into the action
|
||||
column and truncated them against the buttons. -->
|
||||
<slot name="value">
|
||||
<span
|
||||
:class="cn('min-w-0 break-words font-mono text-sm min-[701px]:truncate', text === '—' ? 'text-fg-subtle' : 'text-foreground', lockedReason && 'text-fg-muted')"
|
||||
:title="text"
|
||||
>{{ text }}</span>
|
||||
</slot>
|
||||
|
||||
<span v-if="lockedReason" class="col-span-full text-xs text-fg-subtle min-[701px]:col-span-2 min-[701px]:col-start-2">{{ lockedReason }}</span>
|
||||
<span v-if="error" class="col-span-full text-xs text-danger min-[701px]:col-span-2 min-[701px]:col-start-2" role="alert">{{ error }}</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -5,7 +5,7 @@ import ConfigCard from "./ConfigCard.vue";
|
||||
import ConfigList from "./ConfigList.vue";
|
||||
import ConfigRow from "./ConfigRow.vue";
|
||||
import { sectionRows, sectionsFor } from "./sections";
|
||||
import { config, configEditable } from "./state";
|
||||
import { config } from "./state";
|
||||
|
||||
/**
|
||||
* The generic schema rows for one page. The daemon serves one catalog of
|
||||
@@ -27,7 +27,6 @@ const sections = computed(() => sectionsFor(config.value?.schema, props.ids));
|
||||
:label="field.label"
|
||||
:value="field.value"
|
||||
:field="field"
|
||||
:editable="configEditable"
|
||||
/>
|
||||
</ConfigList>
|
||||
</ConfigCard>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { TableCell } from "@/components/ui/table";
|
||||
import { api } from "@/lib/api";
|
||||
import { errorText, loadConfig } from "./state";
|
||||
import type { RepoView } from "./types";
|
||||
|
||||
/**
|
||||
* One boolean override on a repository row.
|
||||
*
|
||||
* The box moves before the write and moves back if the write is refused: a
|
||||
* checkbox that waits on a round trip reads as a dropped click. It follows the
|
||||
* repository's own value afterwards, so a reload that changed it elsewhere is
|
||||
* not hidden behind a stale local copy.
|
||||
*/
|
||||
const props = defineProps<{ repo: RepoView; field: "allow_concurrent" | "review_enabled"; editable: boolean }>();
|
||||
|
||||
const checked = ref(Boolean(props.repo[props.field]));
|
||||
const loading = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
|
||||
watch(
|
||||
() => props.repo[props.field],
|
||||
(next) => {
|
||||
checked.value = Boolean(next);
|
||||
},
|
||||
);
|
||||
|
||||
async function change(next: boolean | "indeterminate"): Promise<void> {
|
||||
const value = next === true;
|
||||
checked.value = value;
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
await api.configRepoUpdate(props.repo.owner, props.repo.name, props.field, value);
|
||||
await loadConfig();
|
||||
} catch (err) {
|
||||
checked.value = !value;
|
||||
error.value = errorText(err);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableCell>
|
||||
<template v-if="editable">
|
||||
<Checkbox :model-value="checked" :disabled="loading" :aria-label="field" @update:model-value="change" />
|
||||
<span v-if="error" class="ml-2 text-xs text-danger" role="alert">{{ error }}</span>
|
||||
</template>
|
||||
<template v-else>{{ checked ? "yes" : "no" }}</template>
|
||||
</TableCell>
|
||||
</template>
|
||||
@@ -1,68 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { TableCell } from "@/components/ui/table";
|
||||
import { api } from "@/lib/api";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { errorText, loadConfig } from "./state";
|
||||
import type { RepoView } from "./types";
|
||||
|
||||
/**
|
||||
* One integer override on a repository row. The value commits on blur or on
|
||||
* Enter, not on every keystroke: half-typed numbers are not configuration.
|
||||
*/
|
||||
const props = defineProps<{ repo: RepoView; field: "max_retries"; editable: boolean }>();
|
||||
|
||||
const draft = ref(String(props.repo[props.field] ?? 0));
|
||||
const loading = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
|
||||
watch(
|
||||
() => props.repo[props.field],
|
||||
(next) => {
|
||||
draft.value = String(next ?? 0);
|
||||
},
|
||||
);
|
||||
|
||||
function update(value: unknown): void {
|
||||
draft.value = String(value ?? "");
|
||||
}
|
||||
|
||||
async function commit(): Promise<void> {
|
||||
const parsed = parseInt(draft.value, 10);
|
||||
if (Number.isNaN(parsed)) {
|
||||
error.value = "Enter a whole number";
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
await api.configRepoUpdate(props.repo.owner, props.repo.name, props.field, parsed);
|
||||
await loadConfig();
|
||||
} catch (err) {
|
||||
error.value = errorText(err);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableCell :class="cn({ 'font-mono': !editable })">
|
||||
<template v-if="editable">
|
||||
<Input
|
||||
:model-value="draft"
|
||||
:disabled="loading"
|
||||
:aria-label="field"
|
||||
class="w-24"
|
||||
autocomplete="off"
|
||||
@update:model-value="update"
|
||||
@blur="commit"
|
||||
@keydown.enter.prevent="($event.target as HTMLElement).blur()"
|
||||
/>
|
||||
<span v-if="error" class="ml-2 text-xs text-danger" role="alert">{{ error }}</span>
|
||||
</template>
|
||||
<template v-else>{{ draft }}</template>
|
||||
</TableCell>
|
||||
</template>
|
||||
@@ -4,19 +4,15 @@ import { computed } from "vue";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import ConfigCard from "./ConfigCard.vue";
|
||||
import RepoBoolCell from "./RepoBoolCell.vue";
|
||||
import RepoIntCell from "./RepoIntCell.vue";
|
||||
import { config, configEditable } from "./state";
|
||||
import { config } from "./state";
|
||||
|
||||
/**
|
||||
* Each repository Archie polls, and the quality gate a change must pass before
|
||||
* it opens a pull request.
|
||||
*
|
||||
* Concurrent tasks, retries and self-review are per-repository overrides,
|
||||
* written through PATCH /api/config/repos/{owner}/{name} rather than into
|
||||
* config.toml directly, so a change here takes effect without editing a file
|
||||
* on the host. A process with no write path renders those three as values: its
|
||||
* PATCH route answers 503 (archie-core-ymut).
|
||||
* Concurrent tasks, retries and self-review are per-repository policy. They
|
||||
* are edited as the repository-policies control-plane resource, so this table
|
||||
* reports what each repository is running with.
|
||||
*/
|
||||
const repos = computed(() => config.value?.repositories ?? []);
|
||||
|
||||
@@ -58,9 +54,9 @@ function gateSummary(gate?: string[][]): string {
|
||||
<TableCell>{{ repo.ecosystem || "go" }}</TableCell>
|
||||
<TableCell class="font-mono">{{ gateSummary(repo.gate) }}</TableCell>
|
||||
<TableCell class="font-mono">{{ repo.protect?.length ? repo.protect.join(", ") : "—" }}</TableCell>
|
||||
<RepoBoolCell :repo="repo" field="allow_concurrent" :editable="configEditable" />
|
||||
<RepoIntCell :repo="repo" field="max_retries" :editable="configEditable" />
|
||||
<RepoBoolCell :repo="repo" field="review_enabled" :editable="configEditable" />
|
||||
<TableCell>{{ repo.allow_concurrent ? "yes" : "no" }}</TableCell>
|
||||
<TableCell class="font-mono">{{ repo.max_retries ?? 0 }}</TableCell>
|
||||
<TableCell>{{ repo.review_enabled ? "yes" : "no" }}</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { ConfigFieldType } from "./types";
|
||||
|
||||
/** The empty marker. A value the server did not send is shown as an em dash,
|
||||
* which is a fact about the running config, not a missing render. */
|
||||
export function valueText(value: unknown): string {
|
||||
@@ -7,19 +5,3 @@ export function valueText(value: unknown): string {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
/** parseEdit turns the editor's text back into the value the wire expects, or
|
||||
* says why it cannot. Types without a numeric or boolean form are sent as the
|
||||
* text as typed, which is what the daemon's own parser then validates. */
|
||||
export function parseEdit(type: ConfigFieldType, text: string): { value?: unknown; error?: string } {
|
||||
switch (type) {
|
||||
case "int": {
|
||||
const n = parseInt(text, 10);
|
||||
if (Number.isNaN(n)) return { error: "Enter a whole number" };
|
||||
return { value: n };
|
||||
}
|
||||
case "bool":
|
||||
return { value: text === "true" };
|
||||
default:
|
||||
return { value: text };
|
||||
}
|
||||
}
|
||||
@@ -32,11 +32,6 @@ function isMissing(err: unknown): boolean {
|
||||
export const config = ref<ConfigView | null>(null);
|
||||
export const configError = ref<string | null>(null);
|
||||
|
||||
/** Whether this process can apply configuration changes. False means every row
|
||||
* renders as a value: the write routes answer 503, so a control would only
|
||||
* invite a failure. An unknown config (still loading, or unreadable) is not
|
||||
* read-only, so only an explicit false is treated as one. */
|
||||
export const configEditable = computed(() => config.value?.editable !== false);
|
||||
|
||||
/** Nothing to render: either the read failed, or archied is running without a
|
||||
* config file wired into the dashboard. */
|
||||
|
||||
@@ -14,17 +14,13 @@
|
||||
export type ConfigFieldType = "string" | "int" | "bool" | "duration" | "enum" | "structured";
|
||||
|
||||
export interface ConfigField {
|
||||
/** The dotted path PATCH /api/config accepts this value under. */
|
||||
/** The dotted path this value lives at in the running config. */
|
||||
key: string;
|
||||
label: string;
|
||||
description?: string;
|
||||
type: ConfigFieldType;
|
||||
value?: unknown;
|
||||
/** The dashboard may change it. Distinct from locked_reason, which is a
|
||||
* runtime property of the running config rather than of the field. */
|
||||
editable: boolean;
|
||||
locked_reason?: string;
|
||||
overridden?: boolean;
|
||||
options?: string[];
|
||||
/** Changing it will not take effect until archied restarts. */
|
||||
restart_required?: boolean;
|
||||
@@ -78,11 +74,6 @@ export interface ConfigView {
|
||||
providers?: Record<string, ProviderView>;
|
||||
provenance?: ConfigOrigin[];
|
||||
reload?: ReloadStatus;
|
||||
/** Whether this process can apply configuration changes at all. False makes
|
||||
* the pages render values rather than controls, which is the honest offer
|
||||
* from a process serving a published snapshot: its write routes answer 503
|
||||
* (archie-core-ymut). */
|
||||
editable: boolean;
|
||||
schema?: ConfigSection[];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user