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
+1
View File
@@ -0,0 +1 @@
DROP TABLE IF EXISTS research_measurements;
+19
View File
@@ -0,0 +1,19 @@
-- Research measurements (docs/cognitive-research.md): every value a
-- cognitive measure produces, with its subject and provenance. Append-only.
CREATE TABLE research_measurements (
id uuid PRIMARY KEY,
mind_id uuid NOT NULL REFERENCES minds(id),
measure text NOT NULL, -- name in research.Measures
value double precision,
label text NOT NULL DEFAULT '', -- categorical result, e.g. supported
subject_kind text NOT NULL DEFAULT '',
subject_id text NOT NULL DEFAULT '',
experiment_id uuid,
event_id uuid,
detail jsonb NOT NULL DEFAULT '{}'::jsonb,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX research_measurements_mind_idx ON research_measurements (mind_id, measure, created_at DESC);
CREATE INDEX research_measurements_experiment_idx ON research_measurements (experiment_id) WHERE experiment_id IS NOT NULL;
CREATE TRIGGER research_measurements_append_only BEFORE UPDATE OR DELETE ON research_measurements
FOR EACH ROW EXECUTE FUNCTION noema_forbid_change();