layers

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package layers holds LadyM's five memory layers (L0–L4).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlaybookContent

func PlaybookContent(name string, steps []string) string

PlaybookContent is the canonical content string for a playbook — the single source of truth shared by PutPlaybook and proceduralize. Matches Python “name + "\n" + "\n".join(steps)“: empty steps keeps the trailing newline; non-empty steps end without one.

Types

type AssociativeMemory

type AssociativeMemory struct {
	Store storage.Store
}

AssociativeMemory is L4 — the Zettelkasten graph.

func NewAssociativeMemory

func NewAssociativeMemory(store storage.Store) *AssociativeMemory

NewAssociativeMemory builds an AssociativeMemory.

func (a *AssociativeMemory) Link(srcID, dstID, relation string, weight *float64, metadata map[string]any, validFrom, validTo *float64) (*schema.Edge, error)

Link creates an edge between two memories. A nil weight defaults to 1.0; an explicitly supplied weight (including 0) is stored verbatim.

func (*AssociativeMemory) NeighborCounts

func (a *AssociativeMemory) NeighborCounts() (map[string]int, error)

NeighborCounts returns {memory_id: neighbour_count}.

func (*AssociativeMemory) Neighbors

func (a *AssociativeMemory) Neighbors(memID, relation string) ([]*schema.Edge, error)

Neighbors returns valid edges touching memID.

func (*AssociativeMemory) Retire

func (a *AssociativeMemory) Retire(edgeID string, when *float64) error

Retire marks an edge no longer current (sets valid_to).

type EpisodicMemory

type EpisodicMemory struct {
	Store     storage.Store
	Embedder  storage.EmbeddingProvider
	Workspace string
}

EpisodicMemory is L1 — time-stamped events.

func NewEpisodicMemory

func NewEpisodicMemory(store storage.Store, embedder storage.EmbeddingProvider, workspace string) *EpisodicMemory

NewEpisodicMemory builds an EpisodicMemory.

func (*EpisodicMemory) Recent

func (e *EpisodicMemory) Recent(limit int) ([]*schema.Memory, error)

Recent returns the most recent episodes, newest first (created_at DESC). limit <= 0 returns all episodes in the workspace.

func (*EpisodicMemory) Record

func (e *EpisodicMemory) Record(agent, action, observation, outcome string, tags []string, metadata map[string]any) (*schema.Memory, error)

Record appends an episodic event. Content is a rendered sentence for embedding.

type ProceduralMemory

type ProceduralMemory struct {
	Store     storage.Store
	Embedder  storage.EmbeddingProvider
	Workspace string
}

ProceduralMemory is L3 — reusable playbooks and verified snippets.

func NewProceduralMemory

func NewProceduralMemory(store storage.Store, embedder storage.EmbeddingProvider, workspace string) *ProceduralMemory

NewProceduralMemory builds a ProceduralMemory.

func (*ProceduralMemory) PutPlaybook

func (p *ProceduralMemory) PutPlaybook(name string, steps []string, preconditions []string, expectedOutcome string, tags []string) (*schema.Memory, error)

PutPlaybook writes a playbook.

func (*ProceduralMemory) PutSnippet

func (p *ProceduralMemory) PutSnippet(title, code, language string, tags []string) (*schema.Memory, error)

PutSnippet writes a verified code snippet.

type SemanticMemory

type SemanticMemory struct {
	Store     storage.Store
	Embedder  storage.EmbeddingProvider
	Workspace string
}

SemanticMemory is L2 — consolidated facts and codebase analysis.

func NewSemanticMemory

func NewSemanticMemory(store storage.Store, embedder storage.EmbeddingProvider, workspace string) *SemanticMemory

NewSemanticMemory builds a SemanticMemory.

func (*SemanticMemory) FindByHash

func (s *SemanticMemory) FindByHash(h string) (*schema.Memory, error)

FindByHash returns the memory with the given content hash.

func (*SemanticMemory) PutCodeFile

func (s *SemanticMemory) PutCodeFile(filePath, summary, language string) (*schema.Memory, error)

PutCodeFile writes a whole-file summary as L2 code memory.

func (*SemanticMemory) PutFact

func (s *SemanticMemory) PutFact(content, summary string, tags []string, metadata map[string]any, source string) (*schema.Memory, error)

PutFact writes a semantic fact directly.

type WorkingMemory

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

WorkingMemory is a thread-safe bounded buffer of L0 notes.

func NewWorkingMemory

func NewWorkingMemory(capacity int, workspace string) *WorkingMemory

NewWorkingMemory returns a WorkingMemory of the given capacity.

func (*WorkingMemory) Clear

func (w *WorkingMemory) Clear()

Clear empties the buffer.

func (*WorkingMemory) Drain

func (w *WorkingMemory) Drain() []*schema.Memory

Drain pops and returns all items (used by consolidate to flush L0 → L1).

func (*WorkingMemory) Items

func (w *WorkingMemory) Items() []*schema.Memory

Items returns a snapshot of the buffered items.

func (*WorkingMemory) Len

func (w *WorkingMemory) Len() int

Len returns the number of buffered items.

func (*WorkingMemory) Push

func (w *WorkingMemory) Push(content string, tags []string, metadata map[string]any, source string) *schema.Memory

Push appends an L0 note (dropping the oldest when at capacity).

Jump to

Keyboard shortcuts

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