feat: add metacognition, reflection, consolidation, narrative and notifications
Phase 10. Metacognition is a cognitive process with deterministic self-checks (insufficient evidence, single-source reliance, model output without evidence, repeated failed hypotheses, stale contradictions, calibration overconfidence); its warnings compete for attention and, when admitted, add counter-evidence or open an investigation goal. Reflection reviews the period since the last run (prediction errors, rejected beliefs, corrections, status changes, completed goals, contradictions, calibration), turns repeated failures into procedural lessons written once, and records a reflection event; a model may only word the prose within the mind's budget. Consolidation clusters unconsolidated episodes by shared stemmed terms, creates a belief whose confidence is computed from the episodes as evidence and a semantic memory linked to each episode by derived_from, and records jobs with inputs and outputs. Wording may come from the consolidate prompt within a per-run model budget; the job says which. Operators can run, pause and reject; originals are never touched. The narrative hook keeps a five-part first-person narrative built from state and stored with narrative_updated events. The notification hook applies explicit thresholded rules, aggregates repeats within a cooldown and records suppressions with reasons. A scheduled job runs consolidation and reflection per mind, switching the runtime mode while it works. API, Background tab, notifications page with unread badge, overview narrative and warnings, CLI commands, docs/cognition.md.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# Background cognition: metacognition, reflection, consolidation, narrative, notifications
|
||||
|
||||
These subsystems run beside the cognitive cycle. Each is deterministic in what it concludes; a language model may only word things, and only within a configured budget.
|
||||
|
||||
## Metacognition (per cycle)
|
||||
|
||||
The `metacognition` process audits the mind's own reasoning with explicit checks and proposes warnings that compete for attention like any thought:
|
||||
|
||||
| Check | Fires when | Effect when admitted |
|
||||
|---|---|---|
|
||||
| insufficient_evidence | a belief is at ≥ 0.7 with a single supporting item | counter-evidence (weight ≈ 0.25) from `metacognition` lowers it |
|
||||
| single_source | all support for a ≥ 0.6 belief comes from one source | counter-evidence |
|
||||
| fluent_without_evidence | a belief rests only on model output or free notes | counter-evidence |
|
||||
| repeated_failure | three or more hypotheses about one subject rejected in a month | warning |
|
||||
| stale_contradiction | a contested belief unresolved for a day | an investigation goal |
|
||||
| overconfidence | calibration shows stated confidence running ahead of outcomes | warning, notification |
|
||||
|
||||
Each warning is a `metacognition` event with `check` and `ref` metadata; the same check on the same target is not repeated within a day. Warnings appear on the mind overview.
|
||||
|
||||
## Reflection (scheduled, per mind)
|
||||
|
||||
`reflection.Service.Run` reviews the period since the last reflection: prediction errors, rejected beliefs, operator corrections, belief status changes, completed goals, contradictions and calibration. Repeated failures on one subject become a **pattern**, and each new pattern is written once as a procedural memory ("Lesson: … seek an independent source before raising confidence"). The findings are stored structurally with a plain rendering; the `reflect` prompt may rewrite the prose when the `narrate` role has a model and the mind's reflection budget allows. A `reflection` event carries everything. Operators can run it now from the Background tab or `noemactl reflect`.
|
||||
|
||||
## Consolidation (scheduled, per mind)
|
||||
|
||||
`consolidation.Service.Run` takes the last 30 days of episodes not yet consolidated, clusters them deterministically by shared stemmed terms (speaker prefixes stripped), and for each cluster of at least `consolidation_min_episodes` episodes creates:
|
||||
|
||||
- a **belief** (epistemic kind inference) whose confidence is computed from the episodes as evidence (weight 0.3 each, credibility from trust, single-source discount), and
|
||||
- a **semantic memory** with the same proposition, linked to every episode by `derived_from`.
|
||||
|
||||
The proposition is a plain deterministic sentence unless the `consolidate` prompt (summarise role) returns a supported generalisation within the job's model budget; the job records which. Episodes are never modified. Jobs record inputs, outputs and errors; operators can run now, pause scheduled runs globally, and reject a generalisation (memory retracted, belief pinned rejected, episodes untouched). Demo scenario 3 ("user repeatedly selects Go") produces a generalisation this way.
|
||||
|
||||
## Narrative (after cycles)
|
||||
|
||||
The narrative hook builds a five-part structure from state: doing (top workspace thoughts), why (recent stimuli), recently (notable emitted events), resolving (contested beliefs, active goals), next (open predictions). It is rendered as short first-person prose and stored with a `narrative_updated` event when it changes. With `narrative_llm` enabled and a `narrate` model, the prompt may rephrase it; it cannot add content.
|
||||
|
||||
## Notifications (after cycles)
|
||||
|
||||
`notifications.Rules` maps events to candidates with explicit thresholds: confident prediction misses (≥ 0.7), clear contradictions, strong beliefs (only for minds whose personality says notify proactively, above `notify_min_confidence` and `notify_min_salience`), completed goals, overconfidence or loop warnings, denied actions, and very salient observations. Repeats sharing an aggregate key within `notify_cooldown` increment the existing notification instead of creating another, and are recorded as `notification_suppressed` events. Every notification stores the rule and the values that fired it.
|
||||
|
||||
## Modes
|
||||
|
||||
While reflection or consolidation runs for a mind, its runtime mode is switched to `reflecting` or `consolidating` and back, with `mode_changed` events, so the dashboard shows what the mind is doing.
|
||||
Reference in New Issue
Block a user