feat: add beliefs with evidence-derived confidence, contradictions and corrections
Phase 6. Beliefs are propositions with a prior set by epistemic kind and a confidence computed from typed evidence: sigmoid(logit(prior) + slope × (support × diversity − opposition)), where support from a single source is discounted so repetition cannot manufacture certainty, and bounds keep the mind away from absolute certainty. Every evaluation stores its breakdown and appends a version row protected by the append-only trigger; the belief page shows the arithmetic, evidence for and against, alternatives, contradictions and history. Contradiction detection is deterministic first (negation plus token overlap): a hit emits contradiction_detected, links both beliefs and makes each counter-evidence for the other so both trend to contested. Operators can assert beliefs (their statement is the evidence), add evidence, mark a belief wrong (pinned rejected, history kept) and forbid an inference; do-not-infer corrections block matching hypotheses. Retracting a memory retracts the evidence that cited it and re-evaluates the beliefs concerned. The associate process proposes low-confidence causal hypotheses from co-occurring notable observations, and the hypothesis handler turns admitted ones into beliefs with automatic alternatives, closing demo scenarios 1 and 2 without any model call.
This commit is contained in:
@@ -60,6 +60,32 @@ func (c *Cycle) Emit(n events.New) {
|
||||
c.pending = append(c.pending, n)
|
||||
}
|
||||
|
||||
// EmitNow appends one event immediately inside the cycle transaction and
|
||||
// returns it, for handlers that need the event id for provenance. It is still
|
||||
// published only after commit.
|
||||
func (c *Cycle) EmitNow(ctx context.Context, n events.New) (events.Event, error) {
|
||||
if err := c.flush(ctx); err != nil {
|
||||
return events.Event{}, err
|
||||
}
|
||||
n.MindID = c.State.Mind.ID
|
||||
if n.CorrelationID.IsZero() {
|
||||
n.CorrelationID = c.State.CycleID
|
||||
}
|
||||
if n.OccurredAt.IsZero() {
|
||||
n.OccurredAt = c.State.Now
|
||||
}
|
||||
if n.Metadata == nil {
|
||||
n.Metadata = map[string]any{}
|
||||
}
|
||||
n.Metadata["cycle"] = c.State.Cycle
|
||||
evs, err := c.Runtime.events.AppendIn(ctx, c.Tx, n)
|
||||
if err != nil {
|
||||
return events.Event{}, err
|
||||
}
|
||||
c.emitted = append(c.emitted, evs...)
|
||||
return evs[0], nil
|
||||
}
|
||||
|
||||
// flush writes queued events inside the transaction and returns them.
|
||||
func (c *Cycle) flush(ctx context.Context) error {
|
||||
if len(c.pending) == 0 {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/andydixon/noema/internal/attention"
|
||||
"github.com/andydixon/noema/internal/beliefs"
|
||||
"github.com/andydixon/noema/internal/memory"
|
||||
"github.com/andydixon/noema/internal/minds"
|
||||
"github.com/andydixon/noema/internal/workspace"
|
||||
@@ -66,8 +67,9 @@ type State struct {
|
||||
|
||||
// Services are read handles processes may use. Extended per phase.
|
||||
type Services struct {
|
||||
Events EventReader
|
||||
Memory *memory.Store
|
||||
Events EventReader
|
||||
Memory *memory.Store
|
||||
Beliefs *beliefs.Store
|
||||
}
|
||||
|
||||
// EventReader is the subset of the event store processes may call.
|
||||
|
||||
Reference in New Issue
Block a user