engine

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package engine holds the Engine — the single orchestrator and entry point for the SDK / CLI / MCP. All front-ends call the same Engine so behaviour is identical everywhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	Config   *config.Config
	Provider storage.EmbeddingProvider
	Store    storage.Store

	Working     *layers.WorkingMemory
	Episodic    *layers.EpisodicMemory
	Semantic    *layers.SemanticMemory
	Procedural  *layers.ProceduralMemory
	Associative *layers.AssociativeMemory
	// contains filtered or unexported fields
}

Engine is the top-level LadyM orchestrator.

func New

func New(cfg *config.Config) (*Engine, error)

New builds an Engine from cfg (defaults to config.Default() when nil).

func NewWithModels

func NewWithModels(cfg *config.Config, models *adapter.ModelRouting) (*Engine, error)

NewWithModels builds an Engine, optionally injecting host-owned models via routing (embedding provider + per-op LLM providers).

func (*Engine) AttachLLMClassifier

func (e *Engine) AttachLLMClassifier(fn operations.LLMClassifier) error

AttachLLMClassifier wires an explicit consolidation classifier. When fn is nil it builds the consolidate agent from config (offline → heuristic).

func (*Engine) Close

func (e *Engine) Close() error

Close releases the store.

func (*Engine) Consolidate

func (e *Engine) Consolidate(workspace string, since float64) (*operations.ConsolidationReport, error)

Consolidate promotes episodic events into semantic facts.

func (*Engine) CountRecentEpisodes

func (e *Engine) CountRecentEpisodes(workspace string) (int, error)

CountRecentEpisodes counts episodic events in workspace.

func (*Engine) Decay

func (e *Engine) Decay(workspace string, dryRun bool, maxAgeS, activationFloor float64) (*operations.DecayReport, error)

Decay forgets low-activation episodic events.

func (*Engine) ExtractMentalModels

func (e *Engine) ExtractMentalModels(workspace string) (*operations.L5ExtractionReport, error)

ExtractMentalModels runs L5 extraction (skipped when no LLM is configured).

func (*Engine) Forget

func (e *Engine) Forget(memoryID string) error

Forget deletes a single memory by id.

func (*Engine) IndexCode

func (e *Engine) IndexCode(root string, force bool, workspace string, languages []string) (*code.IndexReport, error)

IndexCode indexes a codebase into L2 semantic memory.

func (e *Engine) Link(srcID, dstID, relation string, opts ...LinkOption) (*schema.Edge, error)

Link creates an associative edge, passing weight/metadata/valid_from/valid_to through to the associative layer (Python: link(src, dst, relation, **kw)).

func (*Engine) List added in v0.3.1

func (e *Engine) List(workspace string, layer *schema.Layer, limit, offset int) ([]*schema.Memory, error)

List returns a workspace's memories newest-first, excluding retired items (expired predictions, superseded models). limit<=0 means 20; offset pages (negative offset is clamped to 0). Read-only: it never calls the LLM.

func (*Engine) MinEpisodesToRun

func (e *Engine) MinEpisodesToRun() int

MinEpisodesToRun returns the System 2 episode threshold.

func (*Engine) PredictForwardIntents

func (e *Engine) PredictForwardIntents(workspace string) (*operations.L6PredictionReport, error)

PredictForwardIntents runs L6 prediction (skipped when no LLM is configured).

func (*Engine) Proceduralize

func (e *Engine) Proceduralize(workspace string, minClusterSize int) (*operations.ProceduralizeReport, error)

Proceduralize clusters successful episodes into playbooks.

func (*Engine) Recall

func (e *Engine) Recall(query string, workspace string, topK int, layers_ []schema.Layer, types []schema.MemoryType, minSimilarity float64) (*schema.RecallResponse, error)

Recall runs two-tier retrieval.

func (*Engine) RecordEvent

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

RecordEvent logs an L1 episodic event.

func (*Engine) Remember

func (e *Engine) Remember(content string, layer schema.Layer, type_ schema.MemoryType, tags []string, metadata map[string]any, source, summary string) (*schema.Memory, error)

Remember is the generic write, routing to the right layer. It returns an unpersisted Memory tagged gated=dedropped when the attention gate drops the content.

func (*Engine) SearchCode

func (e *Engine) SearchCode(query string, topK int, workspace string) (*schema.RecallResponse, error)

SearchCode is a code-only shortcut.

func (*Engine) SetWorkspace

func (e *Engine) SetWorkspace(ws string)

SetWorkspace retargets the engine's default workspace (used by the MCP tools which accept a per-call workspace override).

func (*Engine) StartSystem2

func (e *Engine) StartSystem2(intervalS int, workspace string) chan struct{}

StartSystem2 launches a daemon goroutine running System2 cycles. Closing the returned channel asks the worker to stop after its current cycle.

func (*Engine) Stats

func (e *Engine) Stats() (*schema.Stats, error)

Stats returns aggregate store statistics for the engine's default workspace.

func (*Engine) StatsFor added in v0.3.1

func (e *Engine) StatsFor(workspace string) (*schema.Stats, error)

StatsFor returns aggregate store statistics scoped to the given workspace (empty string falls back to the engine's default workspace). Store-wide aggregates (edges, code symbols, workspace list) are not workspace-scoped.

type LinkOption

type LinkOption func(*linkOpts)

LinkOption customises an associative edge created by Link.

func WithMetadata

func WithMetadata(m map[string]any) LinkOption

WithMetadata sets the edge metadata.

func WithValidFrom

func WithValidFrom(t float64) LinkOption

WithValidFrom sets the edge's valid-from timestamp.

func WithValidTo

func WithValidTo(t float64) LinkOption

WithValidTo sets the edge's valid-to timestamp.

func WithWeight

func WithWeight(w float64) LinkOption

WithWeight sets the edge weight. An explicit 0 is preserved (unlike the default, which is 1.0 when WithWeight is not given).

Jump to

Keyboard shortcuts

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