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.
This commit is contained in:
1 parent
59f75b4892
commit
704a5ee642
4 files changed
+49
-14
No files matched your search
+5
-8
@@ -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).
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user