Documentation
¶
Overview ¶
Package metacognitive implements a perpetual self-regulating attention loop that receives persistent state, reasons via LLM, and adapts its own sleep cycle. See issue #319.
Each iteration is a fresh conversation. State persists across iterations via a markdown file (metacognitive.md by default). The loop's cost is self-limiting: quiet periods produce long sleeps and few iterations.
"Dice" randomly select a frontier model for supervisor iterations that review the loop's own behavior, catching blind spots that the cheaper local model's consistent reasoning patterns miss.
The loop lifecycle is managed by the loop package. This package provides BuildLoopConfig to assemble a loop.Config with the correct TaskBuilder, PostIterate, and tool exclusions.
Index ¶
Constants ¶
const DefinitionName = "metacognitive"
DefinitionName is the durable loops-ng definition name for the metacognitive service.
Variables ¶
This section is empty.
Functions ¶
func BuildLoopConfig ¶
BuildLoopConfig returns the engine-facing loop.Config view of the metacognitive loop. Kept as a compatibility bridge while loops-ng adoption is in progress.
func BuildSpec ¶
BuildSpec returns a loop.Spec that implements the metacognitive loop as a standard loops-ng service. The returned spec declares the durable output document and uses runtime hooks to build prompts and append iteration logs.
func DefinitionSpec ¶
DefinitionSpec returns the persistable loops-ng definition for the metacognitive service. Runtime hooks are attached later by HydrateSpec so the definition can live in the durable registry.
Types ¶
type Config ¶
type Config struct {
Enabled bool
StateFile string // fixed filename under workspace/core
MinSleep time.Duration
MaxSleep time.Duration
DefaultSleep time.Duration
Jitter float64 // 0.0–1.0
SupervisorProbability float64 // 0.0–1.0
QualityFloor int // normal iterations
SupervisorQualityFloor int // supervisor iterations
}
Config holds the parsed metacognitive loop configuration with time.Duration fields (as opposed to the YAML string representation in config.MetacognitiveConfig).
func ParseConfig ¶
func ParseConfig(raw config.MetacognitiveConfig) (Config, error)
ParseConfig converts a config.MetacognitiveConfig (string durations) into a Config (time.Duration fields). Call after config validation has passed.
type Opts ¶
type Opts struct {
// WorkspacePath is the absolute path to the workspace directory.
// Used only as a fallback when ProvenanceStore is nil.
WorkspacePath string
// StateFilePath is the resolved absolute path to the state file.
// When a provenance store is configured, this points inside the
// store; otherwise it falls back to workspace-relative resolution.
StateFilePath string
// ProvenanceStore, when non-nil, is used by the iteration logger
// to commit state file updates with SSH signatures.
ProvenanceStore ProvenanceWriter
// StateFileName is the bare filename (e.g. "metacognitive.md") used
// for provenance store reads and writes. Ignored when ProvenanceStore
// is nil.
StateFileName string
}
Opts holds options for BuildLoopConfig that are not part of Config.