Files
memex/notes/org-skill-self-fix.org

50 lines
2.1 KiB
Org Mode

#+TITLE: SKILL: Self-Fix Agent (Universal Literate Note)
#+ID: skill-self-fix
#+STARTUP: content
#+FILETAGS: :self-repair:autonomy:debugging:psf:
#+DEPENDS_ON: skill-scientist skill-shell-actuator
* 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)
:PROPERTIES:
:STATUS: FROZEN
:END:
** 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
#+begin_src lisp :tangle projects/org-skill-self-fix/src/repair-logic.lisp
(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)))
#+end_src
* Registration
#+begin_src lisp
(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))
#+end_src