ARCH: Clean Core Refactor & Terminology Alignment

This commit is contained in:
2026-04-13 09:03:42 -04:00
parent 8ee1c0c4df
commit b6b39472da
16 changed files with 163 additions and 78 deletions

View File

@@ -1,6 +1,6 @@
(in-package :org-agent)
(defun ask-neuro (prompt &key (system-prompt "You are the System 1 engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
(defun ask-neuro (prompt &key (system-prompt "You are the Probabilistic Engine engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
"Dispatches a neural request through the provider cascade.
If CASCADE is a function, it is called with CONTEXT to determine backends."
(let ((backends (cond
@@ -11,7 +11,7 @@
(dolist (backend backends)
(let ((backend-fn (gethash backend *neuro-backends*)))
(when backend-fn
(kernel-log "SYSTEM 1: Attempting backend ~a..." backend)
(kernel-log "PROBABILISTIC ENGINE: Attempting backend ~a..." backend)
(let* (;; Consult the Economist for the model ID if the skill is available
(model (ignore-errors
(uiop:symbol-call :org-agent.skills.org-skill-economist :economist-get-model-for-provider backend)))
@@ -19,7 +19,7 @@
(funcall backend-fn prompt system-prompt :model model)
(funcall backend-fn prompt system-prompt))))
(if (and (stringp result) (search ":LOG" result) (or (search "Failure" result) (search "missing" result)))
(kernel-log "SYSTEM 1: Backend ~a failed. Falling back..." backend)
(kernel-log "PROBABILISTIC ENGINE: Backend ~a failed. Falling back..." backend)
(return-from ask-neuro result))))))
"(:type :LOG :payload (:text \"Neural Cascade Failure\"))"))

View File

@@ -1,6 +1,6 @@
(in-package :org-agent)
(defun ask-neuro (prompt &key (system-prompt "You are the System 1 engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
(defun ask-neuro (prompt &key (system-prompt "You are the Probabilistic Engine engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
(let ((backends (cond
((listp cascade) cascade)
((functionp cascade) (funcall cascade context))
@@ -9,14 +9,14 @@
(dolist (backend backends)
(let ((backend-fn (gethash backend *neuro-backends*)))
(when backend-fn
(kernel-log "SYSTEM 1: Attempting backend ~a..." backend)
(kernel-log "PROBABILISTIC ENGINE: Attempting backend ~a..." backend)
(let* ((model (ignore-errors
(uiop:symbol-call :org-agent.skills.org-skill-economist :economist-get-model-for-provider backend)))
(result (if model
(funcall backend-fn prompt system-prompt :model model)
(funcall backend-fn prompt system-prompt))))
(kernel-log "SYSTEM 1: Backend ~a returned: ~a" backend (if (stringp result) (subseq result 0 (min 50 (length result))) result))
(kernel-log "PROBABILISTIC ENGINE: Backend ~a returned: ~a" backend (if (stringp result) (subseq result 0 (min 50 (length result))) result))
(if (and (stringp result) (search ":LOG" result) (or (search "Failure" result) (search "missing" result)))
(kernel-log "SYSTEM 1: Backend ~a failed. Falling back..." backend)
(kernel-log "PROBABILISTIC ENGINE: Backend ~a failed. Falling back..." backend)
(return-from ask-neuro result))))))
"(:type :LOG :payload (:text \"Neural Cascade Failure\"))"))

View File

@@ -4,7 +4,7 @@
(let ((active-skill (find-triggered-skill context)))
(if active-skill
(progn
(kernel-log "SYSTEM 1: Engaging skill '~a'~%" (skill-name active-skill))
(kernel-log "PROBABILISTIC ENGINE: Engaging skill '~a'~%" (skill-name active-skill))
(let* ((prompt-generator (skill-neuro-prompt active-skill))
(prompt (when prompt-generator (funcall prompt-generator context))))
(if prompt
@@ -17,17 +17,17 @@
(if (and regs (> (length regs) 0)) (elt regs 0) thought))
(string-trim '(#\Space #\Newline #\Tab) thought))))
(suggestion (ignore-errors (read-from-string cleaned-thought))))
(kernel-log "SYSTEM 1 Suggestion: ~a~%" cleaned-thought)
(kernel-log "PROBABILISTIC ENGINE Suggestion: ~a~%" cleaned-thought)
(cond
((and suggestion (listp suggestion)) suggestion)
;; SALVAGE: If LLM returned plain text or a non-list symbol
((and (let ((p (getf context :payload))) (eq (getf p :sensor) :chat-message))
(> (length cleaned-thought) 0))
(kernel-log "SYSTEM 1: SALVAGING plain-text response.~%")
(kernel-log "PROBABILISTIC ENGINE: SALVAGING plain-text response.~%")
(let* ((no-prefix (cl-ppcre:regex-replace "(?i)^(okay,? |sure,? |i will |i've |i have |here is |got it\\.? |understood\\.? |done\\.? |yes,? )+" cleaned-thought "")))
`(:target :emacs :payload (:action :insert-at-end :buffer "*org-agent-chat*" :text ,no-prefix))))
(t
(kernel-log "SYSTEM 1 ERROR: Could not parse response as Lisp plist.~%")
(kernel-log "PROBABILISTIC ENGINE ERROR: Could not parse response as Lisp plist.~%")
nil)))
nil)))
nil)))