collection

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	CollectionUser       = "engram_user"
	CollectionAgentSelf  = "engram_agent_self"
	CollectionReflection = "engram_reflection"
)

Canonical collection names (single source of truth).

Variables

View Source
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).

func (*Registry) Register

func (r *Registry) Register(name string, ttl *time.Duration) error

Register adds a new collection. Returns an error if a collection with the same name already exists.

func (*Registry) Resolve

func (r *Registry) Resolve(callerType string) string

Resolve maps an X-Caller-Type header value to its target collection name. Unknown / empty values fall back to engram_user (safe default — never silently routes user traffic to a privileged collection).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL