From 704a5ee642653011060cd68638b2f3b3b745bd37 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 2 Sep 2026 02:50:35 +1000 Subject: [PATCH] fix(config): reject memory.provider instead of silently ignoring it Closes archie-core-1786637499161-356-e424e40d.1. setupMemory's own doc comment claimed external providers are added via RegisterExternal when cfg.Memory.Provider is set -- no such call existed. Investigated wiring it for real: there is no external MemoryProvider implementation anywhere in the repo to construct and register (only internal/memory/builtin.Provider exists), so there is nothing to route memory.provider's value to yet. Wiring the call would be dead plumbing to nothing, not a fix. The actual defect is that setting memory.provider has always silently done nothing -- an operator who set it reasonably believed they configured something. validateMemory now rejects it outright with a clear reason, turning a silent no-op into a loud one at config load, same failure-loudly posture as every other unimplemented-value check in this file. Drop the rejection once a real external provider (or the new domain/memory engine family's Honcho proof, archie-core-1786637492031) gives the field an effect again. Updated setupMemory's doc comment and config.example.toml to match -- the provider_config example is removed too, since it has nothing left to configure. --- config.example.toml | 13 ++++------ internal/app/archied/bootstrap.go | 8 +++++-- .../infrastructure/configuration/validate.go | 18 ++++++++++---- .../configuration/validate_test.go | 24 +++++++++++++++++++ 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/config.example.toml b/config.example.toml index c2023f597..87ba68ed5 100644 --- a/config.example.toml +++ b/config.example.toml @@ -210,17 +210,14 @@ listen = "127.0.0.1:8484" # work_dir) is always on -- nothing here is required to get memory at all. # engine selects among the domain/memory engine family; "builtin" (the # default, same as leaving it unset) is the only one implemented so far. -# provider is a separate, older mechanism: an external provider identifier -# for internal/memory.Manager.RegisterExternal. As of this writing that -# wiring is not called anywhere in cmd/archied, so setting provider -# currently has no effect -- left here so the schema is documented, not -# because it does anything yet. +# provider is a separate, older mechanism -- an external provider identifier +# for internal/memory.Manager.RegisterExternal -- but no external provider +# is implemented anywhere in the repo to construct and register, so +# setting it is REJECTED at config load rather than silently doing +# nothing. Leave it unset. # [memory] # engine = "builtin" # "builtin" is the only engine implemented so far -# provider = "" # external provider identifier; currently unwired # session_ttl = "0s" -# [memory.provider_config] -# # key = "value" # provider-specific settings # Notifications for human-in-the-loop moments # (approval requests, gate failures, parked tasks). diff --git a/internal/app/archied/bootstrap.go b/internal/app/archied/bootstrap.go index c3bde1c20..abccd1406 100644 --- a/internal/app/archied/bootstrap.go +++ b/internal/app/archied/bootstrap.go @@ -725,8 +725,12 @@ func (b *boot) registerNATSRPC() error { // setupMemory starts the memory manager. The built-in file-backed // provider (MEMORY.md + USER.md) lives under the daemon work directory. -// External providers from config are added via RegisterExternal when -// cfg.Memory.Provider is set. +// memory.Manager.RegisterExternal exists for an external provider, but +// nothing calls it here: no external MemoryProvider is implemented +// anywhere in the repo to construct and register, and +// configuration.validateMemory now rejects cfg.Memory.Provider being set +// at all rather than silently accepting a value with no effect +// (archie-core-1786637499161-356-e424e40d.1). func (b *boot) setupMemory() error { cfg, log := b.cfg, b.log memProvider, memDir := memoryProvider(cfg.WorkDir, log) diff --git a/internal/infrastructure/configuration/validate.go b/internal/infrastructure/configuration/validate.go index 92a37d56d..3f7fb3994 100644 --- a/internal/infrastructure/configuration/validate.go +++ b/internal/infrastructure/configuration/validate.go @@ -95,12 +95,22 @@ func validate(cfg *config.Config) error { // before this runs on the real load path); it is not "unknown" so it does // not error here. func validateMemory(cfg *config.Config) error { - if cfg.Memory.Engine == "" { - return nil - } - if !oneOf(cfg.Memory.Engine, memoryEngines) { + if cfg.Memory.Engine != "" && !oneOf(cfg.Memory.Engine, memoryEngines) { return fmt.Errorf("%w: memory.engine %q (want %s)", ErrInvalidInput, cfg.Memory.Engine, list(memoryEngines)) } + // memory.provider is the legacy external-MemoryProvider identifier for + // internal/memory.Manager.RegisterExternal. No external provider is + // implemented anywhere in the repo to construct and register (only the + // builtin file-backed one exists), so setupMemory has never called + // RegisterExternal and setting this field has always silently done + // nothing -- an operator who sets it reasonably believes they + // configured something. Reject it loudly instead of accepting a value + // with no effect; drop this once a real external provider (or the new + // domain/memory engine family's Honcho proof, + // archie-core-1786637492031) makes the field meaningful again. + if cfg.Memory.Provider != "" { + return fmt.Errorf("%w: memory.provider %q is set, but no external memory provider is implemented -- remove it (memory.engine selects the new engine family instead)", ErrInvalidInput, cfg.Memory.Provider) + } return nil } diff --git a/internal/infrastructure/configuration/validate_test.go b/internal/infrastructure/configuration/validate_test.go index fa735c689..274357784 100644 --- a/internal/infrastructure/configuration/validate_test.go +++ b/internal/infrastructure/configuration/validate_test.go @@ -153,6 +153,11 @@ func TestValidate_RejectsTheSameProblemsAsLoaderLoad(t *testing.T) { mutate: func(cfg *config.Config) { cfg.Memory.Engine = "" }, wantErr: false, }, + { + name: "memory.provider set is rejected: no external provider is implemented", + mutate: func(cfg *config.Config) { cfg.Memory.Provider = "honcho" }, + wantErr: true, + }, { name: "negative capture.retention", mutate: func(cfg *config.Config) { cfg.Capture.Retention = config.Duration(-time.Hour) }, @@ -356,3 +361,22 @@ func TestValidateMemoryNamesTheValidSet(t *testing.T) { t.Errorf("error text = %q, want it to contain %q", got, want) } } + +// TestValidateMemoryRejectsProviderSetToAnything is the regression case for +// archie-core-1786637499161-356-e424e40d.1: memory.provider being set has +// always silently done nothing (no external MemoryProvider exists +// anywhere in the repo for setupMemory to construct and pass to +// RegisterExternal). An operator who set it reasonably believed they +// configured something; this must fail loudly instead. +func TestValidateMemoryRejectsProviderSetToAnything(t *testing.T) { + cfg := minimalValidConfig() + cfg.Memory.Provider = "honcho" + + err := validateMemory(&cfg) + if !errors.Is(err, ErrInvalidInput) { + t.Fatalf("validateMemory(provider set) = %v, want wrapping ErrInvalidInput", err) + } + if !strings.Contains(err.Error(), `memory.provider "honcho"`) { + t.Errorf("error text = %q, want it to name the field and the value", err.Error()) + } +}