Files
memex/notes/org-skill-ast-normalization.org
Amr Gharbeia fdb55c616d feat: stabilized org-agent two-way communication and UX
- Fixed kernel-to-Emacs communication bridge.
- Resolved boot-time crashes in multiple skeletal skills.
- Refined Chat skill prompt to eliminate conversational filler.
- Updated Emacs UI to automatically clean up status markers.
- Synchronized all fixes via Literate Org-mode documents.
- Verified physical two-way interaction via simulation.
2026-04-03 17:25:01 -04:00

93 lines
2.9 KiB
Org Mode

#+TITLE: SKILL: AST Normalization Agent (Universal Literate Note)
#+ID: skill-ast-normalization
#+STARTUP: content
#+FILETAGS: :ast:normalization:integrity:psf:
* Overview
The *AST Normalization Agent* maintains the structural integrity of the Org-mode Abstract Syntax Tree. It ensures all nodes adhere to strict metadata requirements and handles deterministic refactoring.
* Phase A: Demand (PRD)
:PROPERTIES:
:STATUS: FROZEN
:END:
** 1. Purpose
Define automated structural enforcement and refactoring for the Org AST.
** 2. User Needs
- *Structural Enforcement:* Mandatory unique IDs for all headlines.
- *Deterministic Preemption:* Symbolic verification must override neural suggestions if errors exist.
- *Fidelity:* Preservation of content during metadata normalization.
** 3. Success Criteria
*** TODO ID Injection
*** TODO Neural Preemption
*** TODO Subtree Refactoring Verification
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
** 1. Architectural Intent
Interfaces for AST inspection and transformation. Operates as a "Safety Gate" in the Consensus Loop.
** 2. Semantic Interfaces
#+begin_src lisp
(defun trigger-skill-ast-normalization (context)
"Triggers on :user-command :organize-subtree.")
(defun verify-skill-ast-normalization (proposed-action context)
"Symbolic check for missing IDs and mandatory properties.")
(defun find-headline-missing-id (ast)
"Recursive scan of AST for headlines without IDs.")
#+end_src
* Phase D: Build (Implementation)
** Trigger Perception
#+begin_src lisp :tangle projects/org-skill-ast-normalization/src/normalization-logic.lisp
(defun trigger-skill-ast-normalization (context)
(let ((type (getf context :type))
(payload (getf context :payload)))
(and (eq type :EVENT)
(eq (getf payload :sensor) :user-command)
(eq (getf payload :command) :organize-subtree))))
#+end_src
** Symbolic Verification (System 2)
#+begin_src lisp :tangle projects/org-skill-ast-normalization/src/normalization-logic.lisp
(defun verify-skill-ast-normalization (proposed-action context)
(let* ((ast (getf (getf context :payload) :ast))
(missing-id (find-headline-missing-id ast)))
(if missing-id
`(:type :REQUEST :target :emacs
:payload (:action :refactor-subtree
:properties (("ID" . ,(org-id-new)))))
proposed-action)))
#+end_src
** Neural Suggestion (System 1)
#+begin_src lisp
(defun neuro-skill-ast-normalization (context)
"Neural logic for mapping un-IDed headlines to PARA structure (Skeletal)."
nil)
#+end_src
** ID Generation
#+begin_src lisp
(defun org-id-new ()
"Generates a new PSF-format unique ID."
(format nil "node-~a" (get-universal-time)))
#+end_src
* Registration
#+begin_src lisp
(defskill :skill-ast-normalization
:priority 100
:trigger #'trigger-skill-ast-normalization
:neuro #'neuro-skill-ast-normalization
:symbolic #'verify-skill-ast-normalization)
#+end_src