2.1 KiB
2.1 KiB
SKILL: Self-Fix Agent (Universal Literate Note)
Overview
The Self-Fix Agent is the system's "Repair Mechanism." It takes the failure hypotheses from the Scientist Agent, applies surgical code modifications in a sandboxed environment, and merges the fix only after rigorous verification by the TDD Runner.
Phase A: Demand (PRD)
1. Purpose
Enable autonomous, verified code correction without human intervention.
2. User Needs
- Surgical Modification: Apply targeted changes to specific Lisp functions or Org headlines.
- Sandboxed Verification: Test every fix in a controlled environment before merging.
- Rollback Capability: Use the Interactive Steering snapshots to revert if a fix fails.
- Audit Logging: Every fix must be documented in `RCA.org`.
Phase D: Build (Implementation)
Repair Logic
(defun self-fix-apply (target-file old-code new-code)
"Applies a surgical code fix in a sandboxed environment."
(let* ((sandbox-dir "/tmp/org-agent-sandbox/fix/")
(target-path (merge-pathnames target-file sandbox-dir)))
(ensure-directories-exist sandbox-dir)
(kernel-log "SELF-FIX - Applying surgical fix to ~a..." target-file)
;; Logic to perform 'replace' or 'write-file' in the sandbox
(org-agent:spawn-task (format nil "Apply this fix to ~a: ~a -> ~a" target-file old-code new-code))))
(defun self-fix-verify-and-merge (project-name)
"Initiates a TDD run. If green, merges the sandboxed fix into the material project."
(org-agent:spawn-task (format nil "Run TDD tests for ~a and merge if Green." project-name)))
Registration
(defskill :skill-self-fix
:priority 95
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :repair-request))
:neuro (lambda (context) "Synthesize a surgical fix based on the scientist's hypothesis.")
:symbolic (lambda (action context) action))