internal/curator is a conforming engine family per the strict plugin engine rule: typed CuratorEngine contract (Lifecycle + domain ops), owning Registry (registration, discovery, start/health/stop with failure isolation, reverse-order shutdown, ctx-bounded stop), and a narrow typed Registrar — each curator receives a capability-filtered view of the host at Bind, never the daemon. Runtime: one loop per curator on an injectable clock (fake-clock testable), best-effort wake nudges with the trigger decision kept in Check (a dropped nudge only delays to the next check-in, never corrupts accounting), per-pass timeout and a max-concurrent-passes slot so curator bursts cannot starve chat turns, per-pass panic recovery, and bounded shutdown even when a pass ignores cancellation. curator_run / curator_action / curator_error ride the in-process event bus so activity stays attributable. Wired in cmd/archied/main.go (constructed beside memory, Start after daemon startup, shutdown ordered before memory/LLM teardown) and exposed as daemon.Daemon.Curators.
73 lines
1.5 KiB
Go
73 lines
1.5 KiB
Go
package curator
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestManifestValidate(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
manifest Manifest
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "valid minimal",
|
|
manifest: Manifest{Interval: time.Hour},
|
|
},
|
|
{
|
|
name: "valid full",
|
|
manifest: Manifest{
|
|
Interval: time.Hour,
|
|
Cooldown: time.Minute,
|
|
OnInput: true,
|
|
Tools: []string{"skills.list", "skills.write"},
|
|
Skills: true,
|
|
MemoryEngine: "builtin",
|
|
Model: "provider/model",
|
|
},
|
|
},
|
|
{
|
|
name: "zero interval",
|
|
manifest: Manifest{},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "negative interval",
|
|
manifest: Manifest{Interval: -time.Hour},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "empty tool name",
|
|
manifest: Manifest{Interval: time.Hour, Tools: []string{""}},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "blank tool name",
|
|
manifest: Manifest{Interval: time.Hour, Tools: []string{" "}},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
err := tt.manifest.Validate()
|
|
if (err != nil) != tt.wantErr {
|
|
t.Fatalf("Validate() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestManifestValidateRejectsDuplicateTools(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
m := Manifest{Interval: time.Hour, Tools: []string{"skills.list", "skills.list"}}
|
|
if err := m.Validate(); err != nil {
|
|
t.Fatalf("Validate() = %v, want nil (duplicates are the builder's problem)", err)
|
|
}
|
|
}
|