feat(psf): transition to Order 2 (Sovereign Architect) with advanced skill graph and philosophical alignment

This commit is contained in:
2026-03-31 20:28:06 -04:00
parent ec3a572bbb
commit ce39227327
581 changed files with 165563 additions and 25735 deletions

View File

@@ -1,10 +1,11 @@
#+TITLE: SKILL: Self-Fix Agent (Universal Literate Note)
#+ID: skill-self-fix
#+STARTUP: content
#+FILETAGS: :self-fix:immune:meta-cognitive:psf:
#+FILETAGS: :self-repair:autonomy:debugging:psf:
#+DEPENDS_ON: skill-scientist skill-shell-actuator
* Overview
The **Self-Fix Agent** acts as the system's "Immune System." It monitors kernel logs for failures (Lisp errors, rejections, hallucinations) and proactively drafts fixes for offending skills.
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:
@@ -12,64 +13,37 @@ The **Self-Fix Agent** acts as the system's "Immune System." It monitors kernel
:END:
** 1. Purpose
Define the interfaces for autonomous log surveillance and self-repair drafting.
Enable autonomous, verified code correction without human intervention.
** 2. User Needs
- **Constant Surveillance:** Periodic monitoring of system logs via heartbeats.
- **Autonomous Recovery:** Root cause identification and corrective skill drafting.
- **Neuro-Symbolic Alignment:** Refining neural prompts to meet symbolic constraints.
- **Safety Verification:** Leveraging Creator validation for "surgeries."
** 3. Success Criteria
*** TODO Error Pattern Detection
*** TODO Skill Repair Drafting
*** TODO Deployment Gatekeeping Verification
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
** 1. Architectural Intent
Interfaces for log analysis and self-correction. Source of truth is the kernel log and the Skill Creator's validation logic.
** 2. Semantic Interfaces
#+begin_src lisp
(defun trigger-skill-self-fix (context)
"Triggers on :sensor :heartbeat.")
(defun neuro-skill-self-fix (context)
"Neural analysis of system logs and fix drafting.")
(defun verify-skill-self-fix (proposed-action context)
"Ensures repair actions target the correct system actuators.")
#+end_src
- **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)
** Heartbeat Surveillance
#+begin_src lisp :tangle projects/org-skill-self-fix/src/fix-logic.lisp
(defun trigger-skill-self-fix (context)
(let ((type (getf context :type))
(payload (getf context :payload)))
(and (eq type :EVENT)
(eq (getf payload :sensor) :heartbeat))))
#+end_src
** 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))))
** Symbolic Gatekeeping
#+begin_src lisp :tangle projects/org-skill-self-fix/src/fix-logic.lisp
(defun verify-skill-self-fix (proposed-action context)
(let ((action (getf proposed-action :action)))
(if (eq action :create-skill)
proposed-action
nil)))
(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 40
:trigger #'trigger-skill-self-fix
:neuro #'neuro-skill-self-fix
:symbolic #'verify-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