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: Scribe-RCA Agent (Universal Literate Note)
#+TITLE: SKILL: Scribe-RCA (Universal Literate Note)
#+ID: skill-scribe-rca
#+STARTUP: content
#+FILETAGS: :scribe:rca:learning:institutional-memory:psf:
#+FILETAGS: :memory:rca:learning:psf:
#+DEPENDS_ON: skill-atomic-notes
* Overview
The **Scribe-RCA Agent** is a specialized extension of the Scribe role. It closes the "Learning Loop" by extracting Root Cause Analysis (RCA) entries from failures and populating the Institutional Memory.
The **Scribe-RCA** agent is responsible for **Phase F: Memory**. It captures "Permanent Learnings" after significant failures or task completions, ensuring the system's **Institutional Memory** grows with every cycle.
* Phase A: Demand (PRD)
:PROPERTIES:
@@ -12,55 +13,41 @@ The **Scribe-RCA Agent** is a specialized extension of the Scribe role. It close
:END:
** 1. Purpose
Define automated behaviors for failure diagnosis and memory ledger updates.
Automate the extraction of root causes and architectural learnings into the Memex.
** 2. User Needs
- **Perception:** Scan logs for fatal Lisp or System errors.
- **Diagnosis:** Identify underlying technical reasons for failures.
- **Distillation:** Generate high-signal entries (Symptom, Cause, Prevention).
- **Prevention:** Ensure recurrence is avoided via persistent heuristics.
** 3. Success Criteria
*** TODO Error Log Detection
*** TODO RCA Entry Formatting
*** TODO Institutional Memory Append Verification
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
** 1. Architectural Intent
Interfaces for analyzing system "pain" and recording learnings. Source of truth is the system log and `institutional-memory.org`.
** 2. Semantic Interfaces
#+begin_src lisp
(defun trigger-skill-scribe-rca (context)
"Triggers on fatal error events or log rejections.")
(defun scribe-rca-append (symptom cause prevention)
"Appends entry to institutional-memory.org.")
#+end_src
- **Root Cause Analysis:** Automatically draft an RCA note after a `skip-event` recovery.
- **Permanent Learning:** Update `SOUL.org` or a dedicated `RCA.org` with new invariants.
- **Version Control Integration:** Commit new RCA notes to Gitea autonomously.
- **Traceability:** Link every learning back to the original failure stimulus.
* Phase D: Build (Implementation)
** Memory Append
** Memory Extraction
#+begin_src lisp :tangle projects/org-skill-scribe-rca/src/rca-logic.lisp
(defun scribe-rca-append (symptom cause prevention)
(let* ((notes-dir (or (uiop:getenv "MEMEX_NOTES") "notes/"))
(memory-file (format nil "~ainstitutional-memory.org" notes-dir))
(timestamp (local-time:format-timestring nil (local-time:now) :format '("[" :year "-" :month "-" :day " " :weekday "]"))))
(with-open-file (out memory-file :direction :output :if-exists :append)
(format out "~%** ~a ~a~%- **Symptom:** ~a~%- **Root Cause:** ~a~%- **Prevention:** ~a~%"
timestamp cause symptom cause prevention))
(format nil "SUCCESS - Updated Memory: ~a" cause)))
(defun scribe-rca-draft (failure-context)
"Drafts an RCA note based on a recent kernel failure."
(let* ((payload (getf failure-context :payload))
(error-msg (getf payload :text))
(timestamp (local-time:format-timestring nil (local-time:now)))
(gitea-url (org-agent::get-env "GITEA_URL")))
(org-agent:ask-neuro
(format nil "Create a Root Cause Analysis (RCA) note for the following error: ~a" error-msg)
:system-prompt "You are the PSF Scribe. Extract the deep architectural failure and propose a new invariant for SOUL.org.")))
(defun scribe-rca-commit (rca-note)
"Commits the drafted RCA note to the Gitea repository."
(let ((gitea-url (org-agent::get-env "GITEA_URL")))
(kernel-log "SCRIBE - Committing learning to Gitea: ~a" gitea-url)
;; Logic to use 'git commit' via shell-actuator
(org-agent:spawn-task (format nil "Commit this RCA note to Gitea: ~a" rca-note))))
#+end_src
* Registration
#+begin_src lisp
(defskill :skill-scribe-rca
:priority 90
:trigger #'trigger-skill-scribe-rca
:neuro #'neuro-skill-scribe-rca
:symbolic #'scribe-rca-append)
:trigger (lambda (context) (search "SYSTEM ERROR" (format nil "~a" (getf (getf context :payload) :text))))
:neuro #'scribe-rca-draft
:symbolic (lambda (action context) action))
#+end_src