chore(curator): add embedding client and sampler interface prerequisites (#752)

* feat(curator): add embedding client and sampler wave-1 prerequisites

Bead archie-core-1786637500752-415-434e5bb9 (GitHub #436) was closed with
no linked PR/commits, and the surprisal-sampling bead
archie-core-1786637500776-416-600a66e5 (GitHub #437) found none of its
stated prerequisites -- an embedding client, a Sampler interface, or the
four wave-1 cheap sampling strategies -- actually exist. This builds them:

- internal/domain/embedding + internal/infrastructure/embedding: a narrow
  typed embedding client, config-driven via a providers table + a role in
  [models], mirroring the existing chat model role convention. Degrades to
  capability-unavailable (never fails startup or a call) for a missing
  role, unknown provider, unsupported class, or unresolved credential.
  Wired as an optional capability in bootstrap.go's setupEmbeddings.
- internal/domain/sampling: the Sampler interface plus recency, random,
  all, and staleness-proxy strategies, per docs/prds/curator-sampler-wave1.md.
  Deterministic given fixed inputs, matching GitHub #437's stated
  acceptance criterion for the embedding-backed strategy it will add
  behind this same interface (not part of this change).

Table-driven tests throughout; httptest for the embedding client, no live
service. No curator wiring yet -- nothing consumes either capability in
this change.

* no-mistakes(document): docs(architecture): mark curator sampling prereqs as landed
This commit is contained in:
sam authored and GitHub committed 2026-09-05 22:53:08 +10:00
1 parent cd2ab3516b
commit 6affe0eea3
18 files changed
+1186 -21

No files matched your search

+28
View File
@@ -33,6 +33,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/curator"
"github.com/samcharles93/archie-core/internal/domain/eda/module"
"github.com/samcharles93/archie-core/internal/domain/eda/playbook"
domainembedding "github.com/samcharles93/archie-core/internal/domain/embedding"
domainmemory "github.com/samcharles93/archie-core/internal/domain/memory"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/domain/workflow/skillbuild"
@@ -43,6 +44,7 @@ import (
"github.com/samcharles93/archie-core/internal/gateway"
"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"
"github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog"
@@ -121,6 +123,13 @@ type boot struct {
llm *runtime.Runtime
// embeddings is nil unless models["embedding"] and a working provider
// credential are both configured -- see setupLLMAndChat's "Embeddings
// capability" section. Consumers must treat a nil embeddings the same
// as domainembedding.ErrUnavailable: skip, never fail startup or an
// unrelated call.
embeddings domainembedding.Client
toolReg *tools.Registry
chatModels gateway.ModelManager
personas *gateway.PersonaRegistry
@@ -479,6 +488,23 @@ func (b *boot) setupContainers(ctx context.Context) func() {
return closeDocker
}
// setupEmbeddings builds the optional embedding capability. A client is
// wired only when models["embedding"] names a provider/model and that
// provider's credential resolves -- the same credential-missing-degrades-
// not-fatal rule registerMinimaxTool follows for generate_video. No
// warning when the role was simply never configured; a warning when it was
// configured but couldn't be made to work, so a broken setup doesn't go
// unnoticed the way AGENTS.md already warns an unnoticed optional-provider
// degradation can.
func (b *boot) setupEmbeddings(cfg config.Config, log *slog.Logger) {
if client, ok := infraembedding.New(cfg, infraembedding.Options{}); ok {
b.embeddings = client
log.Info("embedding capability enabled", "role", infraembedding.Role)
} else if cfg.Models[infraembedding.Role] != "" {
log.Warn("embedding capability configured but unavailable; capability disabled", "role", infraembedding.Role)
}
}
// setupLLMAndChat wires the runtime, tool registry, model management,
// personas and the dashboard's chat service.
func (b *boot) setupLLMAndChat(ctx context.Context) {
@@ -494,6 +520,8 @@ func (b *boot) setupLLMAndChat(ctx context.Context) {
chatModels.ApplyModelCatalog(b.catalog)
b.chatModels = chatModels
b.setupEmbeddings(cfg, log)
// ── Persona registry ─────────────────────────────────────────────
b.personas = gateway.NewPersonaRegistry(gateway.DefaultPersonas())