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.
This commit is contained in:
Andy Dixon
2026-09-16 23:53:06 +01:00
parent 38c5dde21f
commit 4a7dafc71f
17 changed files with 1572 additions and 6 deletions
+9 -1
View File
@@ -11,7 +11,7 @@ import (
// the system works without a model and never depends on one for routing.
type Analysis struct {
Intent string `json:"intent"` // question | statement | request | correction | greeting | introspection | other
Introspection string `json:"introspection"` // thinking | beliefs | why | uncertain | contradictions | learned | changed | curious | predictions | surprised | patterns | ""
Introspection string `json:"introspection"` // why_action | believed_then | lineage | counterfactual | changed_self | wants | intentions | commitments | thinking | beliefs | why | uncertain | contradictions | learned | changed | curious | predictions | surprised | patterns | ""
Topic string `json:"topic,omitempty"`
Entities []string `json:"entities"`
Tokens []string `json:"tokens"`
@@ -42,6 +42,14 @@ var (
kind string
pats []string
}{
{"why_action", []string{"why did you restart", "why did you run", "why did you fetch", "why did you request", "why did you ask for", "why did you do that", "why did you do this", "why did you act", "why did you stop", "why did you not", "why didn't you", "why did you send", "why did you read", "why did you query", "why did you check"}},
{"believed_then", []string{"believe yesterday", "believed yesterday", "believe last week", "believed last week", "believe earlier", "believed earlier", "believe before", "believed before", "believe an hour ago", "believed an hour ago", "did you believe"}},
{"lineage", []string{"which previous state is yours", "which earlier state is yours", "are you a fork", "where did you come from", "which state is yours", "were you forked", "your lineage"}},
{"counterfactual", []string{"what would have happened", "what would you have", "had you not", "if you had not", "if that had not happened", "had that not happened"}},
{"changed_self", []string{"how have you changed", "how did you change", "what changed in you"}},
{"wants", []string{"what do you want", "what did you want", "what are your wants", "what would you like to do"}},
{"intentions", []string{"what do you intend", "what are you planning", "what are your intentions", "what are you trying to do", "what did you intend"}},
{"commitments", []string{"what have you committed", "what are your commitments", "what did you promise", "what are you committed"}},
{"thinking", []string{"what are you thinking", "thinking about", "on your mind", "what are you doing", "what are you working on", "current focus"}},
{"why", []string{"why do you believe", "why do you think", "what evidence", "how do you know", "what makes you think", "would change your mind"}},
{"uncertain", []string{"uncertain about", "unsure about", "not sure about", "what don't you know", "what do you not know", "confidence in"}},
+17
View File
@@ -42,3 +42,20 @@ func TestAnalyseEntitiesClaimsAndUrgency(t *testing.T) {
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)
}
}
}