Documentation
¶
Overview ¶
Package collection — multi-collection registry for Engram (W20 Day2 Phase 1).
Engram supports multiple logical collections (engram_user, engram_agent_self, engram_reflection) so that writes from different caller types can be isolated. This avoids polluting the user-facing memory recall with reflection-engine generated insights, while still letting cross-collection search merge them when needed.
Phase 1 scope (this file): in-memory registry only. Collections are resolved from the X-Caller-Type HTTP header; default = engram_user.
Phase 2+ will wire actual Qdrant collection creation/teardown and lifecycle management. Persistence of the registry (SQLite vs in-memory rebuild on startup) is an open question for Day3 review.
Index ¶
Constants ¶
const ( CollectionUser = "engram_user" CollectionAgentSelf = "engram_agent_self" CollectionReflection = "engram_reflection" )
Canonical collection names (single source of truth).
Variables ¶
var DefaultRegistry = &Registry{ collections: make(map[string]CollectionInfo), }
DefaultRegistry is the process-global registry. cmd/engram/main.go calls Init() at startup to register the three baseline collections.
Functions ¶
This section is empty.
Types ¶
type CollectionInfo ¶
type CollectionInfo struct {
Name string `json:"name"`
TTL *time.Duration `json:"-"` // serialised separately as human-readable string
CreatedAt time.Time `json:"created_at"`
}
CollectionInfo describes one registered collection.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a thread-safe in-memory map of registered collections.
func (*Registry) Get ¶
func (r *Registry) Get(name string) (CollectionInfo, bool)
Get fetches one collection by name. Returns (info, true) on hit.
func (*Registry) Init ¶
func (r *Registry) Init()
Init registers the three baseline collections. Idempotent: re-registration errors are swallowed (process restart is the normal path that re-invokes Init on an empty registry; explicit re-init via tests is also fine).
func (*Registry) List ¶
func (r *Registry) List() []CollectionInfo
List returns a snapshot of all registered collections (unsorted).