Documentation
¶
Index ¶
- func AllowedCategories() []string
- func AllowedScopes() []string
- func IsAllowedCategory(head string) bool
- func IsAllowedScope(scope string) bool
- func IsMandatoryCategory(head string) bool
- func SortByWeightedScore(entries []Entry)
- func WeightedScore(entry Entry) float64
- func WithAdditionalMandatoryCategories(categories []string)
- type Entry
- type HeadInfo
- type NoopStore
- func (s *NoopStore) All(scopes []Scope) ([]Entry, error)
- func (s *NoopStore) AllByCategory(category string, topK int, scopes []Scope) ([]Entry, error)
- func (s *NoopStore) Delete(id string) error
- func (s *NoopStore) Get(id string) (*Entry, error)
- func (s *NoopStore) ListHeads(scopes []Scope) ([]HeadInfo, error)
- func (s *NoopStore) Promote(id string, targetScope Scope) error
- func (s *NoopStore) Query(category string, tags []string) ([]Entry, error)
- func (s *NoopStore) QueryByCategory(category, query string, topK int, scopes []Scope) ([]Entry, error)
- func (s *NoopStore) Score(id string, delta float64) error
- func (s *NoopStore) Upsert(entry *Entry) error
- type QueryOptions
- type Scope
- type SnapshotStore
- func (s *SnapshotStore) All(scopes []Scope) ([]Entry, error)
- func (s *SnapshotStore) AllByCategory(category string, topK int, scopes []Scope) ([]Entry, error)
- func (s *SnapshotStore) Delete(id string) error
- func (s *SnapshotStore) Get(id string) (*Entry, error)
- func (s *SnapshotStore) ListHeads(scopes []Scope) ([]HeadInfo, error)
- func (s *SnapshotStore) Promote(id string, targetScope Scope) error
- func (s *SnapshotStore) Query(category string, tags []string) ([]Entry, error)
- func (s *SnapshotStore) QueryByCategory(category, query string, topK int, scopes []Scope) ([]Entry, error)
- func (s *SnapshotStore) Score(id string, delta float64) error
- func (s *SnapshotStore) Upsert(entry *Entry) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowedCategories ¶
func AllowedCategories() []string
AllowedCategories returns the list of allowed categories (heads).
func AllowedScopes ¶ added in v0.0.10
func AllowedScopes() []string
AllowedScopes returns the list of allowed scopes.
func IsAllowedCategory ¶
IsAllowedCategory checks if a category is allowed (i.e. can be used as a head).
func IsAllowedScope ¶ added in v0.0.10
IsAllowedScope checks if a scope is allowed.
func IsMandatoryCategory ¶
func SortByWeightedScore ¶ added in v0.0.8
func SortByWeightedScore(entries []Entry)
SortByWeightedScore sorts entries by weighted score descending, then by ID.
func WeightedScore ¶ added in v0.0.8
WeightedScore adds a recency bias to the entry's score. Recent hits increase the score, while old entries decay over time. The half-life is ~14 days (ln(2) / 0.05). LastHit is used as the recency reference; Created is the fallback for entries that have never been queried or reinforced.
func WithAdditionalMandatoryCategories ¶
func WithAdditionalMandatoryCategories(categories []string)
WithAdditionalMandatoryCategories allows extending mandatory categories (heads).
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id" yaml:"id"`
Content string `json:"content" yaml:"content"`
Tags []string `json:"tags" yaml:"tags"`
Category string `json:"category" yaml:"category"`
Scope string `json:"scope" yaml:"scope"`
Score float64 `json:"score" yaml:"score"`
HitCount int `json:"hit_count" yaml:"hit_count"`
LastHit time.Time `json:"last_hit" yaml:"last_hit"`
Created time.Time `json:"created" yaml:"created"`
Source string `json:"source" yaml:"source"`
}
Entry represents a single knowledge nugget.
type NoopStore ¶
type NoopStore struct{}
func (*NoopStore) AllByCategory ¶
func (*NoopStore) QueryByCategory ¶
type QueryOptions ¶
type QueryOptions struct{}
type Scope ¶
type Scope string
Scope represents a logical grouping for entries. Examples of scopes include "global", "team:acme", "project:mnemonic".
const ScopeGlobal Scope = "global"
type SnapshotStore ¶ added in v0.0.10
type SnapshotStore struct {
// contains filtered or unexported fields
}
SnapshotStore is an in-memory implementation of Store. It is used when a daemon is running to cache all entries fetched from the daemon. This allows local components (like the lint command) to wrap it in a MemoryController and build ephemeral, client-side vector indexes for fast local analysis, without interfering with the daemon's state or file locks.
func NewSnapshotStore ¶ added in v0.0.10
func NewSnapshotStore(entries []Entry) *SnapshotStore
func (*SnapshotStore) All ¶ added in v0.0.10
func (s *SnapshotStore) All(scopes []Scope) ([]Entry, error)
func (*SnapshotStore) AllByCategory ¶ added in v0.0.10
func (*SnapshotStore) Delete ¶ added in v0.0.10
func (s *SnapshotStore) Delete(id string) error
func (*SnapshotStore) ListHeads ¶ added in v0.0.10
func (s *SnapshotStore) ListHeads(scopes []Scope) ([]HeadInfo, error)
func (*SnapshotStore) Promote ¶ added in v0.0.10
func (s *SnapshotStore) Promote(id string, targetScope Scope) error
func (*SnapshotStore) Query ¶ added in v0.0.10
func (s *SnapshotStore) Query(category string, tags []string) ([]Entry, error)
func (*SnapshotStore) QueryByCategory ¶ added in v0.0.10
func (*SnapshotStore) Score ¶ added in v0.0.10
func (s *SnapshotStore) Score(id string, delta float64) error
func (*SnapshotStore) Upsert ¶ added in v0.0.10
func (s *SnapshotStore) Upsert(entry *Entry) error
type Store ¶
type Store interface {
ListHeads(scopes []Scope) ([]HeadInfo, error)
All(scopes []Scope) ([]Entry, error)
AllByCategory(category string, topK int, scopes []Scope) ([]Entry, error)
Get(id string) (*Entry, error)
Query(category string, tags []string) ([]Entry, error)
QueryByCategory(category, query string, topK int, scopes []Scope) ([]Entry, error)
Upsert(entry *Entry) error
Score(id string, delta float64) error
Delete(id string) error
Promote(id string, targetScope Scope) error
}
Store defines the persistent storage contract (YAML, Chroma, etc.).