Documentation
¶
Overview ¶
Package store holds context-guru's cross-call state behind one interface so both hosts (bifrost proxy, AuthBridge plugin) share it. v1 ships an in-memory TTL+LRU backend; SQLite/Redis slot in behind the same interface when a durable or multi-replica deployment is real (see the design doc, D5).
It carries three things keyed by session:
- Rewind: cache_key -> original bytes, so Offload components are reversible (the expand(id) tool loop resolves originals from here).
- Sticky: the set of content ids already reduced on prior turns, so a component can keep its output byte-stable across turns (cache stability).
- per-session token/metric rollups (added with metrics in P0/P5).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is an in-memory Store: a TTL+LRU cache for rewind payloads plus a bounded per-session sticky-id set. Defaults mirror headroom's CCR store (1800s TTL, 1000 entries).
func NewMemory ¶
NewMemory builds an in-memory store. Zero/negative option fields fall back to defaults (1800s TTL, 1000 entries, 100 sessions of sticky sets).
func (*Memory) MarkSticky ¶
type Nop ¶
type Nop struct{}
Nop is a Store that persists nothing: Put discards, Get/Sticky always miss. Used when the store is disabled — the expand loop resolves nothing and lossy offloads become irreversible, which is why they must use marker_mode: off.
func (Nop) MarkSticky ¶
type Options ¶
type Options struct {
// Enabled toggles the state store. nil/absent => on (backward-compatible).
// false => no store: reversibility is off, so offload components must run
// marker_mode: off (a full-marker offload would leave dangling markers).
Enabled *bool `yaml:"enabled"`
TTLSeconds int `yaml:"ttl_seconds"`
MaxEntries int `yaml:"max_entries"`
MaxSessions int `yaml:"max_sessions"`
}
Options configures a Memory store; the zero value yields sane defaults. yaml tags let it drop straight into the config file's store: block.
type Store ¶
type Store interface {
// Put stashes an original payload under key with the store's default TTL.
Put(key string, payload []byte)
// Get returns a stashed payload; ok=false if absent or expired.
Get(key string) (payload []byte, ok bool)
// Sticky returns the per-session set of already-reduced content ids.
Sticky(session string) map[string]struct{}
// MarkSticky records that id was reduced in this session.
MarkSticky(session, id string)
// Persists reports whether Put actually retains payloads. false (the Nop
// store) means offloads cannot be made reversible, so a full marker_mode must
// degrade to an irreversible drop rather than leave an unresolvable marker.
Persists() bool
}
Store is the interface components and adapters depend on. Implementations must be safe for concurrent use — one instance serves all requests.