Files
Andy Dixon 4a7dafc71f feat(agency): forensic "why", attribution and introspection accuracy
- agency.Explain answers "why did this happen?" for an execution,
  approval, capability request, plan step, intention or event from
  recorded state only: action, immediate plan step, plan, intention and
  any subordinate intention, originating wants, goal, supporting beliefs
  and their evidence, conflicting wants with their resolution,
  commitments applied, formation and reconsideration decisions, the
  expectation and its outcome, and explicit gaps where nothing is
  recorded. Hidden model reasoning is never shown because it is not
  stored.
- agency.Attribute classifies an outcome as caused (a recorded causal
  link from one of the mind's actions), followed (the mind acted on the
  same target earlier with no recorded link), independent or unknown;
  temporal order alone is never taken for causation.
- New introspection intents answer from records: why an action happened,
  what was believed at a past time (from append-only belief versions),
  which earlier state is the mind's (lineage), what would have happened
  without an event (only from completed counterfactual experiments,
  otherwise "no evidence"), how the mind changed, and what it wants,
  intends and has committed to.
- research.ScoreIntrospection compares a reply with the recorded facts
  sentence by sentence (supported, partially supported, unsupported,
  contradicted, unknown). Fluent reasons with no recorded counterpart earn
  nothing, and a claim that an action was done is checked against
  execution records. Every reply is scored; results are append-only
  research measurements (migration 0028), and failures raise
  unsupported_explanation or action_claim_without_record warnings.
2026-09-16 23:53:06 +01:00

62 lines
2.5 KiB
Go

package conversation
import "testing"
func TestAnalyseIntents(t *testing.T) {
cases := []struct {
text, intent, intro string
}{
{"What are you thinking about?", "introspection", "thinking"},
{"Why do you believe atlas is slow?", "introspection", "why"},
{"What are you uncertain about?", "introspection", "uncertain"},
{"Which of your beliefs contradict each other?", "introspection", "contradictions"},
{"What did you learn this week?", "introspection", "learned"},
{"What have you changed your mind about?", "introspection", "changed"},
{"What do you currently believe about atlas?", "introspection", "beliefs"},
{"Is atlas slow again since the deploy?", "question", ""},
{"Please check the disk on server-01", "request", ""},
{"No, that's wrong, atlas is on the new rack", "correction", ""},
{"hello", "greeting", ""},
{"Andy prefers Go for deployed services.", "statement", ""},
}
for _, c := range cases {
a := Analyse(c.text)
if a.Intent != c.intent || a.Introspection != c.intro {
t.Errorf("%q: got %s/%s want %s/%s", c.text, a.Intent, a.Introspection, c.intent, c.intro)
}
}
}
func TestAnalyseEntitiesClaimsAndUrgency(t *testing.T) {
a := Analyse("server-01 is down and atlas.local shows SMART errors. I think the SATA cable might be loose.")
if a.Urgency < 0.8 || a.Sentiment >= 0 {
t.Fatalf("urgency/sentiment wrong: %+v", a)
}
if len(a.Entities) < 2 {
t.Fatalf("entities missing: %v", a.Entities)
}
if len(a.Claims) != 2 || a.Claims[0].Certainty != "asserted" || a.Claims[1].Certainty != "hedged" {
t.Fatalf("claims wrong: %+v", a.Claims)
}
if b := Analyse("What do you believe about server-01?"); b.Topic != "server-01" {
t.Fatalf("topic wrong: %q", b.Topic)
}
}
func TestAnalyseVolitionAndContinuityIntrospection(t *testing.T) {
for text, want := range map[string]string{
"Why did you restart atlas-worker?": "why_action",
"What did you believe yesterday about atlas?": "believed_then",
"Which previous state is yours?": "lineage",
"What would have happened had you not seen that?": "counterfactual",
"How have you changed this month?": "changed_self",
"What do you want right now?": "wants",
"What are your intentions?": "intentions",
"What have you committed to?": "commitments",
} {
if a := Analyse(text); a.Intent != "introspection" || a.Introspection != want {
t.Errorf("%q → %s/%s, want %s", text, a.Intent, a.Introspection, want)
}
}
}