Documentation
¶
Overview ¶
Package memory implements the filesystem stores of the per-app explore state directory: learned per-screen recipes, operator-authored hints, saved plans, and cached research maps.
Layout under one state directory:
knowledge/ operator-authored hints (*.md) experience/ machine-learned recipes, one file per screen key plans/ saved scenario plans as markdown research-cache/ cached UI maps as JSON with a TTL
Index ¶
- Constants
- type Experience
- func (e *Experience) Get(ctx context.Context, screen explore.ScreenSignature, title string) (string, error)
- func (e *Experience) Index(ctx context.Context, screen explore.ScreenSignature) ([]string, error)
- func (e *Experience) Record(ctx context.Context, screen explore.ScreenSignature, entry explore.MemoryEntry) error
- type Knowledge
- type Plans
- type ResearchCache
Constants ¶
const DefaultResearchTTL = 6 * time.Hour
DefaultResearchTTL bounds how long a cached UI map stays valid.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Experience ¶
type Experience struct {
// contains filtered or unexported fields
}
Experience persists machine-learned per-screen recipes as markdown files, one file per screen key, one "## <title>" section per entry.
func NewExperience ¶
func NewExperience(stateDir string) *Experience
NewExperience returns a store rooted at stateDir/experience.
func (*Experience) Get ¶
func (e *Experience) Get(ctx context.Context, screen explore.ScreenSignature, title string) (string, error)
Get fetches one entry body by title.
func (*Experience) Index ¶
func (e *Experience) Index(ctx context.Context, screen explore.ScreenSignature) ([]string, error)
Index lists entry titles for a screen. A screen with no file yet has an empty index.
func (*Experience) Record ¶
func (e *Experience) Record(ctx context.Context, screen explore.ScreenSignature, entry explore.MemoryEntry) error
Record replaces a same-title entry or appends a new one. Secret values are redacted before anything reaches disk; an entry whose body is empty after redaction is skipped.
type Knowledge ¶
type Knowledge struct {
// contains filtered or unexported fields
}
Knowledge serves operator-authored hints from knowledge/*.md. A file whose first line is "match: <pattern>" applies only to screens the pattern matches; a file without the directive applies to every screen of the app. Bodies interpolate ${env.NAME} through the injected getenv, so credentials stay out of the files themselves.
func NewKnowledge ¶
NewKnowledge returns a store rooted at stateDir/knowledge. A nil getenv resolves every ${env.NAME} to empty rather than reading ambient state.
type Plans ¶
type Plans struct {
// contains filtered or unexported fields
}
Plans saves and loads scenario plans as readable markdown under stateDir/plans. Save then Load returns an equal Plan value.
type ResearchCache ¶
type ResearchCache struct {
// contains filtered or unexported fields
}
ResearchCache persists researched UI maps as JSON files under stateDir/research-cache with a TTL. It is a cache: any unreadable, stale, or unwritable entry degrades to a miss, never to bad data.
func NewResearchCache ¶
NewResearchCache returns a cache rooted at stateDir/research-cache. A non-positive ttl falls back to DefaultResearchTTL; a nil clock uses wall time.
func (*ResearchCache) Get ¶
func (c *ResearchCache) Get(screen explore.ScreenSignature) (*explore.UIMap, bool)
Get returns the cached map for screen, or a miss when the entry is absent, unreadable, older than the TTL, or filed for another screen.
func (*ResearchCache) Put ¶
func (c *ResearchCache) Put(screen explore.ScreenSignature, m *explore.UIMap)
Put stores the map for screen. A failed write leaves at most a future miss, so Put reports nothing.