feat: add goals, drives, affect state, predictions and curiosity
Phase 9. Goals form a mind-scoped tree with kind, priority, progress and blockers; their deterministic relevance to a candidate feeds the goal_relevance attention feature and a goal monitor raises stalled goals and observations that touch one. Drives are a closed set of eight scalars with operator-configured ranges and personality-derived baselines; there is no self-preservation, replication or acquisition drive and no way to add one at runtime. Affect is ten scalars moved by an explicit rule table over events and decaying towards baseline; both modulate attention weights each cycle and the effective weights are recorded with every cycle and shown beside the configured ones. Predictions carry a window and machine-checkable criteria (event terms occurring or staying absent, a belief reaching a confidence, or operator judgement). A resolver job judges them deterministically, keeps an append-only outcome history for calibration (accuracy, Brier score, confidence buckets, overconfidence flag), emits prediction_error events scaled by how confident the miss was, and feeds the outcome back into the linked belief as evidence. Causal hypotheses derive predictions automatically. Curiosity turns misses, contradictions and unexplained observations into questions that compete for attention and become investigation goals when admitted. Brain gains after-cycle hooks and goal/motivation state. API, UI (goals, prediction dashboard, cognitive state panel, effective weights) and CLI (goal, prediction, state). Demo scenario 4 verified end to end.
This commit is contained in:
@@ -11,10 +11,13 @@ import (
|
||||
|
||||
"github.com/andydixon/noema/internal/attention"
|
||||
"github.com/andydixon/noema/internal/beliefs"
|
||||
"github.com/andydixon/noema/internal/goals"
|
||||
"github.com/andydixon/noema/internal/llm/prompts"
|
||||
"github.com/andydixon/noema/internal/llm/router"
|
||||
"github.com/andydixon/noema/internal/memory"
|
||||
"github.com/andydixon/noema/internal/minds"
|
||||
"github.com/andydixon/noema/internal/motivation"
|
||||
"github.com/andydixon/noema/internal/predictions"
|
||||
"github.com/andydixon/noema/internal/workspace"
|
||||
"github.com/andydixon/noema/pkg/events"
|
||||
"github.com/andydixon/noema/pkg/ids"
|
||||
@@ -66,7 +69,10 @@ type State struct {
|
||||
NewEvents []events.Event // since the last cycle, ascending
|
||||
Workspace workspace.State // snapshot before this cycle
|
||||
Services Services
|
||||
llmCalls atomic.Int32 // model calls made in this cycle; processes and handlers share the cap
|
||||
Goals []goals.Goal // active goals, for relevance scoring
|
||||
Motiv motivation.State // drives and affect at the start of the cycle
|
||||
Weights map[string]float64 // effective attention weights after modulation
|
||||
llmCalls atomic.Int32 // model calls made in this cycle; processes and handlers share the cap
|
||||
}
|
||||
|
||||
// AllowLLM reserves one model call against the mind's per-cycle cap and
|
||||
@@ -85,11 +91,14 @@ func (s *State) AllowLLM() bool {
|
||||
|
||||
// Services are read handles processes may use. Extended per phase.
|
||||
type Services struct {
|
||||
Events EventReader
|
||||
Memory *memory.Store
|
||||
Beliefs *beliefs.Store
|
||||
LLM *router.Router
|
||||
Prompts *prompts.Store
|
||||
Events EventReader
|
||||
Memory *memory.Store
|
||||
Beliefs *beliefs.Store
|
||||
LLM *router.Router
|
||||
Prompts *prompts.Store
|
||||
Goals *goals.Store
|
||||
Motivation *motivation.Store
|
||||
Predictions *predictions.Store
|
||||
}
|
||||
|
||||
// EventReader is the subset of the event store processes may call.
|
||||
@@ -102,10 +111,18 @@ type EventReader interface {
|
||||
// receive the cycle's emitter so provenance links are consistent.
|
||||
type Handler func(ctx context.Context, c *Cycle, t workspace.Thought) error
|
||||
|
||||
// Registry holds processes and handlers. It is immutable after construction.
|
||||
// Hook runs after the executive handlers of a cycle, with the events emitted
|
||||
// so far, for cross-cutting updates such as drives and affect.
|
||||
type Hook interface {
|
||||
Name() string
|
||||
AfterCycle(ctx context.Context, c *Cycle, emitted []events.Event) error
|
||||
}
|
||||
|
||||
// Registry holds processes, handlers and hooks. It is immutable after construction.
|
||||
type Registry struct {
|
||||
processes []Process
|
||||
handlers map[string]Handler
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// NewRegistry builds a registry.
|
||||
@@ -117,5 +134,8 @@ func (r *Registry) AddProcess(p Process) *Registry { r.processes = append(r.proc
|
||||
// Handle registers the handler for a thought kind.
|
||||
func (r *Registry) Handle(kind string, h Handler) *Registry { r.handlers[kind] = h; return r }
|
||||
|
||||
// AddHook registers an after-cycle hook.
|
||||
func (r *Registry) AddHook(h Hook) *Registry { r.hooks = append(r.hooks, h); return r }
|
||||
|
||||
// Processes returns the registered processes.
|
||||
func (r *Registry) Processes() []Process { return r.processes }
|
||||
|
||||
Reference in New Issue
Block a user