memory

package
v0.2.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

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

func NewKnowledge(stateDir string, getenv func(string) string) *Knowledge

NewKnowledge returns a store rooted at stateDir/knowledge. A nil getenv resolves every ${env.NAME} to empty rather than reading ambient state.

func (*Knowledge) Match

func (k *Knowledge) Match(ctx context.Context, screen explore.ScreenSignature) ([]string, error)

Match returns the interpolated hint bodies that apply to the screen, in filename order.

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.

func NewPlans

func NewPlans(stateDir string) *Plans

NewPlans returns a store rooted at stateDir/plans.

func (*Plans) LoadPlan

func (p *Plans) LoadPlan(name string) (*explore.Plan, error)

LoadPlan reads <name>.md back into a Plan.

func (*Plans) SavePlan

func (p *Plans) SavePlan(name string, plan *explore.Plan) error

SavePlan writes the plan to <name>.md.

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

func NewResearchCache(stateDir string, ttl time.Duration, clock func() time.Time) *ResearchCache

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

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.

Jump to

Keyboard shortcuts

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