Documentation
¶
Index ¶
- Variables
- type IndexMetadata
- type MemoryController
- func (mc *MemoryController) All(scopes []store.Scope) ([]store.Entry, error)
- func (mc *MemoryController) AllByCategory(category string, topK int, scopes []store.Scope) ([]store.Entry, error)
- func (mc *MemoryController) BuildIndexes(force bool) error
- func (mc *MemoryController) Close() error
- func (mc *MemoryController) Delete(id string) error
- func (mc *MemoryController) Get(id string) (*store.Entry, error)
- func (mc *MemoryController) ListHeads(scopes []store.Scope) ([]store.HeadInfo, error)
- func (mc *MemoryController) Promote(id string, targetScope store.Scope) error
- func (mc *MemoryController) Query(category string, tags []string) ([]*store.Entry, error)
- func (mc *MemoryController) QueryByCategory(category, query string, topK int, scopes []store.Scope) ([]store.Entry, error)
- func (mc *MemoryController) Score(id string, delta float64) error
- func (mc *MemoryController) SemanticSearch(query string, k int, scopes []store.Scope) ([]store.Entry, error)
- func (mc *MemoryController) Upsert(entry *store.Entry) error
- type Option
- type SemanticSearcher
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmbedderNotAvailable is returned when an operation requires an embedder but one is not available. ErrEmbedderNotAvailable = errors.New("embedder not available") )
Functions ¶
This section is empty.
Types ¶
type IndexMetadata ¶
type IndexMetadata struct {
// Entries maps entry ID to the time it was indexed.
Entries map[string]time.Time `json:"entries"`
}
IndexMetadata tracks which entry IDs have been indexed.
type MemoryController ¶
type MemoryController struct {
// contains filtered or unexported fields
}
MemoryController wraps a Store with optional semantic indexing via HNSW.
When an Embedder is available, it keeps vectors in sync with store entries and supports SemanticSearch. When no Embedder is available, it passes through to the inner store.
func New ¶
func New(conf config.Config, opts ...Option) (*MemoryController, error)
New creates a MemoryController. cfg is required; Embedder, Indexer, and Store are constructed from cfg unless overridden via options. mnemonicDir defaults to ~/.mnemonic unless overridden.
func (*MemoryController) AllByCategory ¶
func (*MemoryController) BuildIndexes ¶
func (mc *MemoryController) BuildIndexes(force bool) error
BuildIndexes builds the index or force rebuilds the entire index from scratch.
func (*MemoryController) Close ¶
func (mc *MemoryController) Close() error
Close stops the flush loop, persists the index, and closes the inner store.
func (*MemoryController) Delete ¶
func (mc *MemoryController) Delete(id string) error
func (*MemoryController) Promote ¶
func (mc *MemoryController) Promote(id string, targetScope store.Scope) error
func (*MemoryController) QueryByCategory ¶
func (*MemoryController) SemanticSearch ¶
func (mc *MemoryController) SemanticSearch(query string, k int, scopes []store.Scope) ([]store.Entry, error)
SemanticSearch embeds the query and returns the k nearest entries. Returns nil when the embedder is unavailable.
type Option ¶
type Option func(*options)
Option defines a functional option for configuring MemoryController.
func WithEmbedder ¶
WithEmbedder overrides the default embedder.
func WithIndexer ¶
WithIndexer overrides the default indexer.
func WithMnemonicDir ¶
WithMnemonicDir sets the mnemonic directory (default: ~/.mnemonic).
func WithSkipInitialSync ¶
WithSkipInitialSync skips the initial index sync on startup. Use this when restarting, or when invoking embedding manually.
type SemanticSearcher ¶
type SemanticSearcher interface {
SemanticSearch(query string, k int, scopes []store.Scope) ([]store.Entry, error)
}
SemanticSearcher implements vector-based semantic search. This is separate from store.Store because SemanticSearch is a responsibility of the embed.Embedder + index.Indexer control structure, not necessarily every future store implementation.