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

2.9 KiB

SKILL: AST Normalization Agent (Universal Literate Note)

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)

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)

1. Architectural Intent

Interfaces for AST inspection and transformation. Operates as a "Safety Gate" in the Consensus Loop.

2. Semantic Interfaces

(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.")

Phase D: Build (Implementation)

Trigger Perception

(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))))

Symbolic Verification (System 2)

(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)))

Neural Suggestion (System 1)

(defun neuro-skill-ast-normalization (context)
  "Neural logic for mapping un-IDed headlines to PARA structure (Skeletal)."
  nil)

ID Generation

(defun org-id-new ()
  "Generates a new PSF-format unique ID."
  (format nil "node-~a" (get-universal-time)))

Registration

(defskill :skill-ast-normalization
  :priority 100
  :trigger #'trigger-skill-ast-normalization
  :neuro #'neuro-skill-ast-normalization
  :symbolic #'verify-skill-ast-normalization)