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 ¶
- type Engine
- func (e *Engine) AttachLLMClassifier(fn operations.LLMClassifier) error
- func (e *Engine) Close() error
- func (e *Engine) Consolidate(workspace string, since float64) (*operations.ConsolidationReport, error)
- func (e *Engine) CountRecentEpisodes(workspace string) (int, error)
- func (e *Engine) Decay(workspace string, dryRun bool, maxAgeS, activationFloor float64) (*operations.DecayReport, error)
- func (e *Engine) ExtractMentalModels(workspace string) (*operations.L5ExtractionReport, error)
- func (e *Engine) Forget(memoryID string) error
- func (e *Engine) IndexCode(root string, force bool, workspace string, languages []string) (*code.IndexReport, error)
- func (e *Engine) Link(srcID, dstID, relation string, opts ...LinkOption) (*schema.Edge, error)
- func (e *Engine) List(workspace string, layer *schema.Layer, limit, offset int) ([]*schema.Memory, error)
- func (e *Engine) MinEpisodesToRun() int
- func (e *Engine) PredictForwardIntents(workspace string) (*operations.L6PredictionReport, error)
- func (e *Engine) Proceduralize(workspace string, minClusterSize int) (*operations.ProceduralizeReport, error)
- func (e *Engine) Recall(query string, workspace string, topK int, layers_ []schema.Layer, ...) (*schema.RecallResponse, error)
- func (e *Engine) RecordEvent(agent, action, observation, outcome string, tags []string, ...) (*schema.Memory, error)
- func (e *Engine) Remember(content string, layer schema.Layer, type_ schema.MemoryType, tags []string, ...) (*schema.Memory, error)
- func (e *Engine) SearchCode(query string, topK int, workspace string) (*schema.RecallResponse, error)
- func (e *Engine) SetWorkspace(ws string)
- func (e *Engine) StartSystem2(intervalS int, workspace string) chan struct{}
- func (e *Engine) Stats() (*schema.Stats, error)
- func (e *Engine) StatsFor(workspace string) (*schema.Stats, error)
- type LinkOption
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 NewWithModels ¶
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) Consolidate ¶
func (e *Engine) Consolidate(workspace string, since float64) (*operations.ConsolidationReport, error)
Consolidate promotes episodic events into semantic facts.
func (*Engine) CountRecentEpisodes ¶
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) 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 (*Engine) Link ¶
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 ¶
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 ¶
SetWorkspace retargets the engine's default workspace (used by the MCP tools which accept a per-call workspace override).
func (*Engine) StartSystem2 ¶
StartSystem2 launches a daemon goroutine running System2 cycles. Closing the returned channel asks the worker to stop after its current cycle.
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).