feat(curator): engine family contract, registry, and runtime (archie-core-rfp, archie-core-89x)

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.
This commit is contained in:
sam committed 2026-08-05 14:54:12 +10:00
1 parent 0ddc43081e
commit 4ece064026
11 files changed
+2054

No files matched your search

@@ -40,3 +40,34 @@ A plugin:
Plugins may be internally cohesive like small services. They do not become
network services without a concrete security or operational reason.
## Curator surprisal sampling (deferred)
The curator engine family (epic `archie-core-yp9`) selects which memories
deserve agentic attention via surprisal-based sampling: score memories by how
surprising they are and spend the sampled reasoner's agentic budget on the
most surprising items. Wave 1 of the epic ships the `Sampler` strategy seam in
`internal/curator` with cheap, embedding-free strategies (recency, random,
all, and a staleness proxy). The embedding-backed strategy is a documented
extension point and is gated behind an embedding capability Archie does not
yet have — **any surprisal-style sampling is gated behind adding one**.
Requirements for the deferred work, so it can be picked up without
re-deriving the design (tracked as `archie-core-yp9.1` embeddings capability,
then `archie-core-yp9.2` surprisal strategies):
- A `Sampler` implementation behind the same interface as the cheap
strategies; selection deterministic given fixed inputs.
- Algorithm: sample up to a candidate cap; build a k-NN graph over embedding
vectors; row-normalize the adjacency with self-loops; power-iterate to the
stationary distribution; surprisal = −log(stationary probability of the
nearest point); select the highest-surprisal items.
- Degradation: content without an embedding is skipped; an embedding failure
aborts sampling and falls back to free exploration — a sampling failure
must never fail or crash a curator pass.
- Cost bound: the graph build is quadratic in the candidate cap; the cap must
be a named constant with a documented bound.
- The embedding capability itself: a narrow typed client usable by in-process
components, config-driven provider/model, credential-missing degrades to
"capability unavailable" (daemon still starts), timeouts on network calls,
tests via httptest only.