feat(curator): bind curators to memory engines

Closes archie-core-1786637499636 (bind curators to memory engines).

curator.Registrar gets MemoryEngines, a MemoryEngineSource
(Get(name) (domainmemory.MemoryEngine, bool)) mirroring
domain/memory.Registry.Get's exact signature so the real registry
satisfies it with no adapter. Registration enforces presence the same
way Tools/Skills already do: a curator declaring Manifest.MemoryEngine
with no MemoryEngineSource on the host is rejected at Register, and
filter() clears MemoryEngines from a curator's view when it declared no
engine. A curator with a declared name that turns out not to exist in
the registry is not this layer's problem -- Get(name) at call time
returns false, same as ToolBuilder.Build with an undeclared tool.

Resolution is by name at call time, not a value pre-fetched at Bind: a
curator calls MemoryEngines.Get(its own Manifest().MemoryEngine) itself,
the identical trust model ToolBuilder.Build(ctx, declared) already
uses -- the curator is trusted to pass its own declared identifier, not
handed something pre-scoped to it. Swapping the configured engine (a
different name resolving through the same registry) changes where a
curator's memories land with no change to the curator itself, since
nothing about the curator's own code names a concrete engine.

setupCurators wires b.memEngines (*domainmemory.Registry, set by
setupMemoryAll which Run() calls first) straight in -- it already
satisfies MemoryEngineSource.

A curator declaring no memory engine remains valid (existing behavior,
now also covered by the "nothing declared" and "no source" table
cases) and is only ever affected by a memory operation it never has the
means to attempt, since MemoryEngines is nil in its view.
This commit is contained in:
sam committed 2026-09-02 02:47:48 +10:00
1 parent d11fb949a3
commit 49a37118d4
4 files changed
+95 -6

No files matched your search

+5
View File
@@ -825,6 +825,11 @@ func (b *boot) setupCurators(ctx context.Context) {
log := b.log
b.curatorRegistry = curator.NewRegistry(curator.Registrar{
Events: curatorEventSink{b.bus},
// b.memEngines (*domainmemory.Registry) satisfies
// curator.MemoryEngineSource's Get(name) signature directly, no
// adapter needed. Set by setupMemoryAll, which Run() calls before
// setupCurators.
MemoryEngines: b.memEngines,
})
// The runtime owns the per-curator loops (archie-core-89x): one
// goroutine per curator, wake nudges, per-pass budgets, panic
+18
View File
@@ -4,6 +4,7 @@ import (
"context"
"time"
domainmemory "github.com/samcharles93/archie-core/internal/domain/memory"
"github.com/samcharles93/archie-core/internal/tools"
)
@@ -27,6 +28,15 @@ type Registrar struct {
// Skills is the skill-maintenance capability (skill curator,
// archie-core-i7i). Bound when the curator declares Skills.
Skills SkillStore
// MemoryEngines resolves a named memory engine, for a curator that
// declared Manifest.MemoryEngine (archie-core-1786637499636). Bound
// only when declared. Like Tools, resolution is by name at call time,
// not a value pre-fetched at Bind: a curator calls
// MemoryEngines.Get(its own Manifest().MemoryEngine), the same trust
// model ToolBuilder.Build(ctx, declared) already uses -- the caller is
// trusted to pass its own declared identifier, not handed a
// pre-scoped instance.
MemoryEngines MemoryEngineSource
// Events publishes curator activity. Implementations must be
// non-blocking and bounded (drop on overflow), so a curator can never
// apply backpressure to a chat turn or the daemon. Always bound.
@@ -91,6 +101,14 @@ type Skill struct {
Description string
}
// MemoryEngineSource resolves a named memory engine. Mirrors
// domain/memory.Registry.Get's exact signature so the real registry
// satisfies this without an adapter, while this package stays decoupled
// from that package's concrete Registry type.
type MemoryEngineSource interface {
Get(name string) (domainmemory.MemoryEngine, bool)
}
// EventSink publishes curator activity (what ran, what changed, why). It is
// the emission side only; wake signals arrive through the runtime's own
// subscription. Implementations MUST be non-blocking and
+6
View File
@@ -125,6 +125,9 @@ func (r *Registry) validateDeclared(m Manifest) error {
if m.Skills && r.host.Skills == nil {
return errors.New("curator manifest: declares the skills capability but the registrar has no SkillStore")
}
if m.MemoryEngine != "" && r.host.MemoryEngines == nil {
return errors.New("curator manifest: declares a memory engine but the registrar has no MemoryEngineSource")
}
return nil
}
@@ -143,6 +146,9 @@ func (r *Registry) filter(m Manifest) Registrar {
if !m.Skills {
v.Skills = nil
}
if m.MemoryEngine == "" {
v.MemoryEngines = nil
}
return v
}
+66 -6
View File
@@ -9,6 +9,7 @@ import (
"testing"
"time"
domainmemory "github.com/samcharles93/archie-core/internal/domain/memory"
"github.com/samcharles93/archie-core/internal/tools"
)
@@ -35,6 +36,44 @@ func (testStore) Read(context.Context, string) (Skill, error) { return Skill{},
func (testStore) Write(context.Context, Skill) error { return nil }
func (testStore) Delete(context.Context, string) error { return nil }
// testMemoryEngines is a fake MemoryEngineSource with one engine, "builtin".
type testMemoryEngines struct{}
func (testMemoryEngines) Get(name string) (domainmemory.MemoryEngine, bool) {
if name != "builtin" {
return nil, false
}
return fakeMemoryEngine{}, true
}
// fakeMemoryEngine is the minimal domain/memory.MemoryEngine a resolved
// lookup can return; its own behavior is exercised by
// internal/domain/memory's and internal/infrastructure/memory's own test
// suites, not here.
type fakeMemoryEngine struct{}
func (fakeMemoryEngine) Name() string { return "builtin" }
func (fakeMemoryEngine) Version() string { return "test" }
func (fakeMemoryEngine) Manifest() domainmemory.Manifest { return domainmemory.Manifest{} }
func (fakeMemoryEngine) Bind(domainmemory.Registrar) {}
func (fakeMemoryEngine) Start(context.Context) error { return nil }
func (fakeMemoryEngine) Health(context.Context) domainmemory.Health {
return domainmemory.Health{Status: domainmemory.HealthHealthy}
}
func (fakeMemoryEngine) Stop(context.Context) error { return nil }
func (fakeMemoryEngine) Write(context.Context, domainmemory.Observation) (domainmemory.Record, error) {
return domainmemory.Record{}, nil
}
func (fakeMemoryEngine) Query(context.Context, domainmemory.Query) ([]domainmemory.Record, error) {
return nil, nil
}
func (fakeMemoryEngine) List(context.Context, string) ([]domainmemory.Record, error) {
return nil, nil
}
func (fakeMemoryEngine) Forget(context.Context, string) error { return nil }
type testSink struct {
mu sync.Mutex
kinds []string
@@ -304,6 +343,17 @@ func TestRegistryDeclaredCapabilitiesRequireHostServices(t *testing.T) {
host: Registrar{Skills: testStore{}},
manifest: Manifest{Interval: time.Hour, Skills: true},
},
{
name: "memory engine declared, no source",
host: Registrar{},
manifest: Manifest{Interval: time.Hour, MemoryEngine: "builtin"},
wantErr: true,
},
{
name: "memory engine declared, source present",
host: Registrar{MemoryEngines: testMemoryEngines{}},
manifest: Manifest{Interval: time.Hour, MemoryEngine: "builtin"},
},
{
name: "nothing declared, empty host",
host: Registrar{},
@@ -327,12 +377,13 @@ func TestRegistryBindFiltersToDeclaredCapabilities(t *testing.T) {
t.Parallel()
host := Registrar{
Model: "provider/default",
LLM: &testLLM{},
Tools: &testBuilder{},
Skills: testStore{},
Events: &testSink{},
Clock: testClock{now: time.Unix(0, 0)},
Model: "provider/default",
LLM: &testLLM{},
Tools: &testBuilder{},
Skills: testStore{},
MemoryEngines: testMemoryEngines{},
Events: &testSink{},
Clock: testClock{now: time.Unix(0, 0)},
}
// A curator declaring nothing agentic receives no model access and no
@@ -351,6 +402,9 @@ func TestRegistryBindFiltersToDeclaredCapabilities(t *testing.T) {
if plain.view.Skills != nil {
t.Error("view.Skills = non-nil for a curator not declaring skills")
}
if plain.view.MemoryEngines != nil {
t.Error("view.MemoryEngines = non-nil for a curator declaring no memory engine")
}
if plain.view.Events == nil {
t.Error("view.Events = nil; activity must always be attributable")
}
@@ -386,6 +440,12 @@ func TestRegistryBindFiltersToDeclaredCapabilities(t *testing.T) {
if mem.view.Tools != nil {
t.Error("view.Tools = non-nil for a curator declaring no tools")
}
if mem.view.MemoryEngines == nil {
t.Error("view.MemoryEngines = nil for a curator declaring a memory engine")
}
if _, ok := mem.view.MemoryEngines.Get("builtin"); !ok {
t.Error("view.MemoryEngines.Get(builtin) = not found, want the fake engine registered under that name")
}
}
func TestRegistryBindPanicIsolated(t *testing.T) {