memory

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package memory is part of the GoFastr harness.

See docs/harness-architecture.md for the architecture this package implements.

Package memory implements file-backed auto-memory matching the markdown+frontmatter pattern documented in docs/harness-architecture.md § Memory.

Layout under the memory root:

MEMORY.md                index ("- [Title](file.md) — hook")
user_role.md             one file per memory
feedback_testing.md
project_harness.md

Frontmatter required: name, description, metadata.type. Four types: user, feedback, project, reference.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name        string // slug, used as filename minus ".md"
	Description string
	Type        Type
	Body        string
	Path        string // absolute path on disk
}

Entry is one memory file.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the file-backed memory store.

func New

func New(root string) (*Store, error)

New returns a Store rooted at the given directory. The directory is created if it doesn't exist.

func (*Store) All

func (s *Store) All() []*Entry

All returns every loaded entry sorted by name.

func (*Store) ByType

func (s *Store) ByType(t Type) []*Entry

ByType returns entries of one type.

func (*Store) Delete

func (s *Store) Delete(name string) error

Delete removes a memory.

func (*Store) Get

func (s *Store) Get(name string) (*Entry, bool)

Get returns a memory by name, or false.

func (*Store) Relevant

func (s *Store) Relevant(query string, n int) []*Entry

Relevant scores every entry against a query string and returns the top n entries. Scoring is a simple tag/keyword overlap; sufficient for the engine middleware's "inject relevant memories per turn" step.

func (*Store) Save

func (s *Store) Save(e Entry) error

Save writes (or overwrites) a memory and updates the index.

type Type

type Type string

Type is the kind of memory.

const (
	TypeUser      Type = "user"
	TypeFeedback  Type = "feedback"
	TypeProject   Type = "project"
	TypeReference Type = "reference"
)

Jump to

Keyboard shortcuts

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