A framework for testing functional properties of the architecture (Part C). None of it claims consciousness; every measure has an operational definition in research.Measures. - Ablations (attention, memory retrieval, affect, metacognition, commitments, volition, global workspace, curiosity, association, goals, narrative, notifications) and workspace overrides (force a matching candidate in or out of admission) live in a fork's cognitive configuration. Original minds refuse them on create and update; only snapshot restores may carry them, so they are part of the configuration digest. Excluded candidates are recorded with fate "excluded". - Self-model experiments override a fork's self-model (capabilities, identity, goals, knowledge gaps) without touching policy. When an action's effective policy disagrees with the self-model, cognition records a self_model_mismatch and corrects the entry; experiments report self-model accuracy and correction latency. - Counterfactual experiments replay a mind's recorded stimuli from a snapshot with chosen events omitted; the report lists what differed in beliefs, wants, intentions, memories, attention and capability decisions, in a form introspection can cite. - Experiments record a protocol (kind, independent variable, controlled variables, measures), per-variant volition, plan, downstream-by-category (events reachable from each stimulus through recorded links), introspection and self-model measures and event ranges; comparisons add want, intention and plan-capability overlap, measure ranges, a descriptive architecture share and a downstream delta; reproducibility is labelled against the previous run of the same definition. - research.Agency computes want→intention, intention→action, abandonment, commitment fulfilment and conflict, blocked intentions, replanning, outcome success and introspection accuracy; MetacognitiveCalibration relates confidence and expressed uncertainty in replies to later belief revision, with Brier scores for each half of the period. - The sandbox test harness gains volition, planning, agency and research but not the motivation hook, whose wall-clock decay would make replay comparisons timing-dependent.
82 lines
3.6 KiB
Go
82 lines
3.6 KiB
Go
// Package replaytest wires a deterministic cognitive stack for replay and
|
|
// experiment tests.
|
|
package replaytest
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"testing"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
|
|
"github.com/andydixon/noema/internal/agency"
|
|
"github.com/andydixon/noema/internal/beliefs"
|
|
"github.com/andydixon/noema/internal/brain"
|
|
"github.com/andydixon/noema/internal/capabilities"
|
|
"github.com/andydixon/noema/internal/capabilities/host"
|
|
"github.com/andydixon/noema/internal/cognition"
|
|
"github.com/andydixon/noema/internal/conversation"
|
|
"github.com/andydixon/noema/internal/epistemics"
|
|
evstore "github.com/andydixon/noema/internal/events"
|
|
"github.com/andydixon/noema/internal/goals"
|
|
"github.com/andydixon/noema/internal/graph"
|
|
"github.com/andydixon/noema/internal/identity"
|
|
"github.com/andydixon/noema/internal/memory"
|
|
"github.com/andydixon/noema/internal/minds"
|
|
"github.com/andydixon/noema/internal/motivation"
|
|
"github.com/andydixon/noema/internal/observability"
|
|
"github.com/andydixon/noema/internal/planning"
|
|
"github.com/andydixon/noema/internal/predictions"
|
|
"github.com/andydixon/noema/internal/research"
|
|
"github.com/andydixon/noema/internal/scheduler"
|
|
"github.com/andydixon/noema/internal/snapshots"
|
|
"github.com/andydixon/noema/internal/storage"
|
|
"github.com/andydixon/noema/internal/volition"
|
|
"github.com/andydixon/noema/migrations"
|
|
)
|
|
|
|
// Harness wires the deterministic cognitive registry without a model.
|
|
type Harness struct {
|
|
Pool *pgxpool.Pool
|
|
Events *evstore.Store
|
|
Minds *minds.Store
|
|
Snaps *snapshots.Store
|
|
Brain brain.Config
|
|
Identity *identity.Capturer
|
|
}
|
|
|
|
// NewHarness is shared with the experiments tests.
|
|
func NewHarness(t *testing.T) *Harness {
|
|
t.Helper()
|
|
pool := storage.TestPool(t, migrations.FS)
|
|
ctx := context.Background()
|
|
log := slog.New(slog.DiscardHandler)
|
|
es := evstore.NewStore(pool, evstore.NewBus(64), nil)
|
|
ms := minds.NewStore(pool)
|
|
mem := memory.NewStore(ctx, pool, nil)
|
|
bs := beliefs.NewStore(pool)
|
|
caps := &capabilities.Service{Registry: capabilities.NewRegistry(), DB: pool, Events: es, Log: log}
|
|
for _, c := range capabilities.Builtins() {
|
|
caps.Registry.Add(c)
|
|
}
|
|
for _, c := range host.Capabilities(host.Options{}) {
|
|
caps.Registry.Add(c)
|
|
}
|
|
caps.Registry.Freeze()
|
|
vol := volition.NewStore(pool)
|
|
plans := planning.NewStore(pool)
|
|
gs := goals.NewStore(pool)
|
|
ps := predictions.NewStore(pool)
|
|
exec := &planning.Executor{Plans: plans, Volition: vol, Caps: caps, Predictions: ps, Events: es, Minds: ms, Memory: mem, Log: log,
|
|
Planner: &planning.Planner{Registry: caps.Registry, Effect: planning.PolicyEffect(caps)}}
|
|
rs := research.NewStore(pool)
|
|
ag := &agency.Service{DB: pool, Caps: caps, Plans: plans, Volition: vol, Goals: gs, Beliefs: bs, Predictions: ps, Events: es}
|
|
reg := cognition.NewRegistry(cognition.Stores{Memory: mem, Beliefs: bs, Conversations: conversation.NewStore(pool), Graph: graph.NewStore(pool), Assertions: epistemics.NewStore(pool), Agency: ag, Research: rs})
|
|
// No motivation hook: affect decay depends on elapsed wall-clock time,
|
|
// which would make replay comparisons in these tests timing-dependent.
|
|
cfg := brain.Config{DB: pool, Events: es, Minds: ms, Registry: reg, Pool: scheduler.NewPool(2), Log: log, Metrics: observability.NewMetrics(),
|
|
Services: brain.Services{Events: es, Memory: mem, Beliefs: bs, Goals: gs, Motivation: motivation.NewStore(pool), Predictions: ps, Capabilities: caps, Volition: vol, Plans: plans, Executor: exec, Minds: ms}}
|
|
ident := &identity.Capturer{DB: pool, Minds: ms}
|
|
return &Harness{Pool: pool, Events: es, Minds: ms, Snaps: &snapshots.Store{DB: pool, Events: es, Minds: ms, Identity: ident}, Brain: cfg, Identity: ident}
|
|
}
|