store

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

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

func IsAllowedCategory(head string) bool

IsAllowedCategory checks if a category is allowed (i.e. can be used as a head).

func IsAllowedScope added in v0.0.10

func IsAllowedScope(scope string) bool

IsAllowedScope checks if a scope is allowed.

func IsMandatoryCategory

func IsMandatoryCategory(head string) bool

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

func WeightedScore(entry Entry) float64

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 HeadInfo

type HeadInfo struct {
	Name      string `json:"name" yaml:"name"`
	Count     int    `json:"count" yaml:"count"`
	Mandatory bool   `json:"mandatory" yaml:"mandatory"`
}

type NoopStore

type NoopStore struct{}

func (*NoopStore) All

func (s *NoopStore) All(scopes []Scope) ([]Entry, error)

func (*NoopStore) AllByCategory

func (s *NoopStore) AllByCategory(category string, topK int, scopes []Scope) ([]Entry, error)

func (*NoopStore) Delete

func (s *NoopStore) Delete(id string) error

func (*NoopStore) Get

func (s *NoopStore) Get(id string) (*Entry, error)

func (*NoopStore) ListHeads

func (s *NoopStore) ListHeads(scopes []Scope) ([]HeadInfo, error)

func (*NoopStore) Promote

func (s *NoopStore) Promote(id string, targetScope Scope) error

func (*NoopStore) Query

func (s *NoopStore) Query(category string, tags []string) ([]Entry, error)

func (*NoopStore) QueryByCategory

func (s *NoopStore) QueryByCategory(category, query string, topK int, scopes []Scope) ([]Entry, error)

func (*NoopStore) Score

func (s *NoopStore) Score(id string, delta float64) error

func (*NoopStore) Upsert

func (s *NoopStore) Upsert(entry *Entry) error

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"

func (Scope) String

func (s Scope) String() string

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 (s *SnapshotStore) AllByCategory(category string, topK int, scopes []Scope) ([]Entry, error)

func (*SnapshotStore) Delete added in v0.0.10

func (s *SnapshotStore) Delete(id string) error

func (*SnapshotStore) Get added in v0.0.10

func (s *SnapshotStore) Get(id string) (*Entry, 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 (s *SnapshotStore) QueryByCategory(category, query string, topK int, scopes []Scope) ([]Entry, error)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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