store

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 7 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 IsAllowedCategory

func IsAllowedCategory(head string) bool

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

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