Files
archie/internal/domain/memory/registrar.go
T
sam 4a85725a69 feat(memory): typed memory engine contract, registry, and registrar
Part of archie-core-1786637490069-11-e245c170 (memory engine contract
and owning registry), under epic archie-core-1786637499161 (pluggable
memory engine).

Stands up internal/domain/memory as a conforming engine family per the
strict plugin engine rule, mirroring internal/domain/curator's split
exactly as that issue's notes specify:

- contract.go: MemoryEngine (Lifecycle + Store + identity + Bind), with
  Store carrying the real domain operations the epic requires --
  Write/Query/List/Forget -- not just Name/Version. Store is split out
  from MemoryEngine so the interface stays under golangci-lint's
  interfacebloat threshold the same way curator's embedded Lifecycle
  does: an embedded interface counts as one slot, not its expanded
  method count.
- registrar.go: narrow typed host access (EventSink, Clock). No
  capability-gated fields yet -- unlike curator's Tools/Skills, no
  memory-specific host service exists to gate on today, so Registry.Bind
  passes the host straight through rather than filtering.
- registry.go: Register/Get/Names/Start/Health/Stop with the same
  duplicate/nil/panic/failure-isolation guarantees as curator's registry,
  ctx-bounded Stop, reverse-order shutdown.

This is the contract only -- no engine implements it yet, and
internal/memory's existing ad-hoc MemoryProvider/Manager (pre-migration)
is untouched, per the issue's explicit "do not extend in place" note.
2026-09-02 01:55:11 +10:00

35 lines
1.1 KiB
Go

package memory
import "time"
// Registrar is the narrow typed host access an engine receives at
// registration. Fields are typed contracts declared here — this package
// never names who implements them, and the daemon itself is never part of
// it.
type Registrar struct {
// Events publishes engine activity (writes, forgets, failures) for
// observability. Implementations must be non-blocking and bounded (drop
// on overflow), matching the curator family's EventSink contract, so an
// engine can never apply backpressure to a chat turn or the daemon.
// Always bound.
Events EventSink
// Clock is injectable time. Always bound; nil at construction is
// replaced with the system clock.
Clock Clock
}
// EventSink publishes engine activity. Mirrors curator.EventSink: emission
// side only, non-blocking and bounded.
type EventSink interface {
Emit(kind, detail string, data map[string]any)
}
// Clock is injectable time: Now for timestamps.
type Clock interface {
Now() time.Time
}
type systemClock struct{}
func (systemClock) Now() time.Time { return time.Now() }