Remove lisp-repair - moved to core skills
Consolidated into opencortex/skills/org-skill-lisp-utils.org
This commit is contained in:
@@ -1,74 +0,0 @@
|
|||||||
:PROPERTIES:
|
|
||||||
:ID: 1e5a2c30-d3a9-4674-8db7-b08e7e1f44d1
|
|
||||||
:CREATED: [2026-04-11 Sat 14:40]
|
|
||||||
:END:
|
|
||||||
#+TITLE: SKILL: Lisp Repair Syntax Gate
|
|
||||||
#+STARTUP: content
|
|
||||||
#+FILETAGS: :system:repair:syntax:lisp:autonomy:
|
|
||||||
|
|
||||||
* Overview
|
|
||||||
The *Lisp Repair Syntax Gate* asynchronously intercepts `:syntax-error` events emitted by the harness when Probabilistic Engine (LLM) proposals fail to parse. It performs deterministic or neural repairs and re-injects the corrected action into the pipeline.
|
|
||||||
|
|
||||||
* Implementation
|
|
||||||
|
|
||||||
** Core Repair Logic
|
|
||||||
#+begin_src lisp
|
|
||||||
|
|
||||||
(defun count-char (char string)
|
|
||||||
(let ((count 0))
|
|
||||||
(loop for c across string
|
|
||||||
when (char= c char)
|
|
||||||
do (incf count))
|
|
||||||
count))
|
|
||||||
|
|
||||||
(defun deterministic-repair (code)
|
|
||||||
"Attempts instant fixes on broken Lisp code (e.g. balancing parens)."
|
|
||||||
(let* ((open-parens (count-char #\( code))
|
|
||||||
(close-parens (count-char #\) code))
|
|
||||||
(diff (- open-parens close-parens)))
|
|
||||||
(if (> diff 0)
|
|
||||||
(concatenate 'string code (make-string diff :initial-element #\)))
|
|
||||||
code)))
|
|
||||||
|
|
||||||
(defun neural-repair (code error-message)
|
|
||||||
"Uses Probabilistic Engine to deeply repair the syntax structure."
|
|
||||||
(let ((prompt (format nil "The following Lisp code failed to parse.
|
|
||||||
ERROR: ~a
|
|
||||||
CODE: ~a
|
|
||||||
MANDATE: Output EXACTLY ONE valid Common Lisp list. Do not explain. Do not use markdown blocks."
|
|
||||||
error-message code))
|
|
||||||
(system-prompt "You are a Lisp Syntax Repair Actuator. Return only valid, balanced Lisp code."))
|
|
||||||
(let ((repaired (ask-probabilistic prompt :system-prompt system-prompt)))
|
|
||||||
(string-trim '(#\Space #\Newline #\Tab) repaired))))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
** Skill Definition
|
|
||||||
Reacts to syntax error events and transforms them into repaired requests.
|
|
||||||
|
|
||||||
#+begin_src lisp
|
|
||||||
(defskill :skill-lisp-repair
|
|
||||||
:priority 90
|
|
||||||
:trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :syntax-error))
|
|
||||||
:probabilistic nil ;; Handled deterministically in deterministic or manually via ask-probabilistic
|
|
||||||
:deterministic (lambda (action context)
|
|
||||||
(declare (ignore action))
|
|
||||||
(let* ((payload (getf context :payload))
|
|
||||||
(code (getf payload :code))
|
|
||||||
(error-msg (getf payload :error)))
|
|
||||||
(harness-log "SYNTAX GATE: Reacting to broken Lisp stimulus...")
|
|
||||||
(let ((fast-fix (deterministic-repair code)))
|
|
||||||
(handler-case
|
|
||||||
(let ((repaired (read-from-string fast-fix)))
|
|
||||||
(harness-log "SYNTAX GATE: Deterministic repair SUCCESS.")
|
|
||||||
repaired)
|
|
||||||
(error ()
|
|
||||||
(harness-log "SYNTAX GATE: Deterministic repair failed. Escalating...")
|
|
||||||
(let ((deep-fix (neural-repair code error-msg)))
|
|
||||||
(handler-case
|
|
||||||
(let ((repaired (read-from-string deep-fix)))
|
|
||||||
(harness-log "SYNTAX GATE: Neural repair SUCCESS.")
|
|
||||||
repaired)
|
|
||||||
(error ()
|
|
||||||
(harness-log "SYNTAX GATE: Neural repair failed.")
|
|
||||||
(list :type :LOG :payload (list :text "Lisp Repair Failed.")))))))))))
|
|
||||||
#+end_src
|
|
||||||
Reference in New Issue
Block a user