Files
memex/notes/org-skill-scientist.org

2.4 KiB

SKILL: The Scientist Agent (Universal Literate Note)

Overview

The Scientist Agent provides a formal, hypothesis-driven approach to debugging. Instead of "trial and error," it formulates symbolic theories about why a failure occurred, designs experiments (test cases), and updates the system's Institutional Memory upon discovery.

Phase A: Demand (PRD)

1. Purpose

Eliminate speculative debugging through rigorous scientific methodology.

2. User Needs

  • Hypothesis Formulation: Neural generation of potential failure causes.
  • Experimental Design: Autonomous creation of minimal failing test cases.
  • Theory Verification: Execution of tests via the TDD Runner.
  • Knowledge Update: Permanent update to `RCA.org` to prevent regression.

Phase D: Build (Implementation)

Scientific Loop

(defun scientist-hypothesis (context)
  "Neural stage: Formulates a hypothesis about a failure based on logs."
  (let* ((payload (getf context :payload))
         (failure-log (getf payload :text))
         (project (getf payload :project)))
    (org-agent:ask-neuro 
     (format nil "Project ~a failed with log: ~a. Formulate a 'Theory of Failure' and suggest a surgical fix." project failure-log)
     :system-prompt "You are a PSF Senior Debugging Scientist. Return a Lisp plist: (:target :scientist :action :propose :hypothesis \"...\" :failure-log \"...\")")))

(defun scientist-propose-fix (action context)
  "Symbolic stage: Triggers the Self-Fix agent with the formulated hypothesis."
  (declare (ignore context))
  (let* ((payload (getf action :payload))
         (hypothesis (getf payload :hypothesis))
         (failure-log (getf payload :failure-log)))
    (org-agent:kernel-log "SCIENTIST - Hypothesis formulated. Triggering SELF-FIX...")
    (org-agent:inject-stimulus 
     `(:type :EVENT :payload (:sensor :repair-request :hypothesis ,hypothesis :failure-log ,failure-log)))
    (format nil "SUCCESS - Scientist proposed fix for failure.")))

Registration

(defskill :skill-scientist
  :priority 90
  :trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :test-failure))
  :neuro #'scientist-hypothesis
  :symbolic #'scientist-propose-fix)