docs: Rename cognitive architecture to Associative/Deliberate and Foreground/Background

This commit is contained in:
2026-04-12 14:09:47 -04:00
parent 04df131f63
commit c46c4d4fd7
11 changed files with 459 additions and 65 deletions

View File

@@ -16,9 +16,9 @@ The original `cognitive-loop` used asynchronous recursion to handle stimuli. Whi
graph TD
S1[Signal: User Message] --> P[Perceive Gate]
S2[Signal: Heartbeat] --> P
P --> N[Neuro Gate: Multi-Backend]
P --> N[Associative Gate: Multi-Backend]
N --> C[Consensus Gate]
C --> V[Validation Gate: System 2]
C --> V[Validation Gate: Deliberate]
V --> D[Dispatch Gate: Actuators]
D -- Feedback Signal --> S1
#+end_src
@@ -162,15 +162,15 @@ Normalizes raw stimuli and updates the Object Store knowledge graph.
signal))
#+end_src
*** Neuro Gate
Invokes the neural System 1 engine to generate intuition-based proposals. If parallel consensus is enabled, this gate returns a list of proposals.
*** Associative Gate
Invokes the Associative engine to generate intuition-based proposals. If parallel consensus is enabled, this gate returns a list of proposals.
#+begin_src lisp :tangle ../src/core.lisp
(defun neuro-gate (signal)
"System 1: Intuition and proposed actions."
"Associative: Intuition and proposed actions."
(unless (eq (getf signal :type) :EVENT)
(return-from neuro-gate signal))
(kernel-log "GATE [Neuro]: Consulting System 1...")
(kernel-log "GATE [Associative]: Consulting System 1...")
(let ((thoughts (think signal)))
(setf (getf signal :proposals) (if (and (listp thoughts) (listp (car thoughts)))
thoughts
@@ -214,19 +214,19 @@ Compares multiple proposals (from parallel backends) and selects the most consis
#+end_src
*** Decide Gate
The System 2 safety gate. Validates the candidate action against formal rules and PSF invariants.
The Deliberate safety gate. Validates the candidate action against formal rules and PSF invariants.
**** Phase A: Demand
- *Need:* Ensure that malformed candidates (e.g., raw strings from System 1) do not crash the `decide` or `safety-harness` logic, which expect property lists.
- *Need:* Ensure that malformed candidates (e.g., raw strings from Associative) do not crash the `decide` or `safety-harness` logic, which expect property lists.
- *Success:* Coerce non-list candidates into valid `:RESPONSE` property lists before validation.
**** Phase B: Blueprint
Before passing the candidate to `decide`, the gate checks its type. If it's a string, it wraps it in `(:type :RESPONSE :payload (:text <string>))`.
Before passing the candidate to `decide`, the gate checks its type. If it's a string, it wraps it in `(:type :RESPONSE :payload (list :text <string>))`.
**** Phase D: Build
#+begin_src lisp :tangle ../src/core.lisp
(defun decide-gate (signal)
"System 2: Safety and validation."
"Deliberate: Safety and validation."
(let ((candidate (getf signal :candidate)))
(if candidate
(let* ((normalized-candidate (if (listp candidate) candidate (list :type :RESPONSE :payload (list :text candidate))))

View File

@@ -5,11 +5,11 @@
* The Neurosymbolic Bridge (neuro.lisp & symbolic.lisp)
** Deep Reasoning: Imagination Checked by Physics
System 1 (LLM) is creative but hallucination-prone. System 2 (Lisp) is rigid but 100% accurate.
- **The Safety Gate:** We never allow the LLM to talk to the actuators directly. It must propose a Lisp form. System 2 intercepts this form and validates it against mathematical rules and PSF invariants.
Associative (LLM) is creative but hallucination-prone. Deliberate (Lisp) is rigid but 100% accurate.
- **The Safety Gate:** We never allow the LLM to talk to the actuators directly. It must propose a Lisp form. Deliberate intercepts this form and validates it against mathematical rules and PSF invariants.
- **Sovereign Decoupling:** By moving the physical API logic into skills, the core remains a neutral "Thinking Engine" that doesn't care if the imagination comes from Google, Anthropic, or a local Llama instance.
* Neural Engine (neuro.lisp)
* Associative Engine (neuro.lisp)
This module handles the interaction with Large Language Models, providing a unified interface for multiple backends.
** Package Context
@@ -60,7 +60,7 @@ Retrieves authentication credentials for a provider, falling back to environment
(list :api-key legacy)))))))))
#+end_src
** Neuro Backends Registry
** Associative Backends Registry
Tracks the actual implementation functions for each LLM provider.
#+begin_src lisp :tangle ../src/neuro.lisp
@@ -74,7 +74,7 @@ The ordered list of backends to attempt for neural reasoning.
(defvar *provider-cascade* '(:openrouter :gemini))
#+end_src
** Register Neuro Backend
** Register Associative Backend
Maps a keyword identifier to a backend implementation function.
#+begin_src lisp :tangle ../src/neuro.lisp
@@ -88,13 +88,13 @@ A hook for dynamic model selection based on the current context.
(defvar *model-selector-fn* nil "A function called with (provider context) to return a model ID.")
#+end_src
** Neural Dispatch (ask-neuro)
The primary entry point for System 1. It handles the retry logic and backend selection. It supports a parallel consensus mode where all backends are queried simultaneously.
** Associative Dispatch (ask-neuro)
The primary entry point for Associative. It handles the retry logic and backend selection. It supports a parallel consensus mode where all backends are queried simultaneously.
#+begin_src lisp :tangle ../src/neuro.lisp
(defvar *consensus-enabled-p* t "If T, ask-neuro queries all backends in parallel.")
(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 Associative engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
"Dispatches a neural request through the provider cascade or parallel consensus."
(let ((backends (cond
((and cascade (listp cascade)) cascade)
@@ -110,7 +110,7 @@ The primary entry point for System 1. It handles the retry logic and backend sel
(when backend-fn
(push (bt:make-thread
(lambda ()
(kernel-log "SYSTEM 1 [Consensus]: Querying backend ~a..." backend)
(kernel-log "ASSOCIATIVE [Consensus]: Querying backend ~a..." backend)
(let* ((model (when *model-selector-fn* (funcall *model-selector-fn* backend context)))
(result (ignore-errors
(if model
@@ -134,7 +134,7 @@ The primary entry point for System 1. It handles the retry logic and backend sel
(or (dolist (backend backends)
(let ((backend-fn (gethash backend *neuro-backends*)))
(when backend-fn
(kernel-log "SYSTEM 1: Attempting backend ~a..." backend)
(kernel-log "ASSOCIATIVE: Attempting backend ~a..." backend)
(let* ((model (when *model-selector-fn* (funcall *model-selector-fn* backend context)))
(result (if model
(funcall backend-fn prompt system-prompt :model model)
@@ -154,19 +154,19 @@ Standard functions that can be overridden by specific skills to provide enhanced
'(:openrouter :gemini))
#+end_src
** Neural Reasoning (think)
Invokes the System 1 engine to generate a proposed Lisp action. It automatically injects the tool documentation and global context into the prompt.
** Associative Reasoning (think)
Invokes the Associative engine to generate a proposed Lisp action. It automatically injects the tool documentation and global context into the prompt.
#+begin_src lisp :tangle ../src/neuro.lisp
(defun think (context)
"Invokes the neural System 1 engine to propose a Lisp action based on context.
"Invokes the neural Associative engine to propose a Lisp action based on context.
If consensus is enabled, it returns a list of proposals from different backends."
(let ((active-skill (find-triggered-skill context))
(tool-belt (generate-tool-belt-prompt))
(global-context (context-assemble-global-awareness)))
(if active-skill
(progn
(kernel-log "SYSTEM 1: Engaging skill '~a'~%" (skill-name active-skill))
(kernel-log "ASSOCIATIVE: Engaging skill '~a'~%" (skill-name active-skill))
(let* ((prompt-generator (skill-neuro-prompt active-skill))
(raw-prompt (when prompt-generator (funcall prompt-generator context)))
(full-system-prompt (concatenate 'string
@@ -194,7 +194,7 @@ To call a tool, you MUST use:
(raw-thoughts (cl-ppcre:split (cl-ppcre:quote-meta-chars "|CONSENSUS-SEP|") thought))
(suggestions nil))
(dolist (raw-thought raw-thoughts)
(kernel-log "SYSTEM 1 RAW: ~a~%" raw-thought)
(kernel-log "ASSOCIATIVE RAW: ~a~%" raw-thought)
(let* ((cleaned-thought
(let ((match (cl-ppcre:scan-to-strings "(?s)```(?:lisp)?\\n?(.*?)\\n?```" raw-thought)))
(if match
@@ -208,7 +208,7 @@ To call a tool, you MUST use:
(list :sensor :syntax-error
:code cleaned-thought
:error (format nil "~a" c)))))))
(kernel-log "SYSTEM 1 Suggestion: ~a~%" cleaned-thought)
(kernel-log "ASSOCIATIVE Suggestion: ~a~%" cleaned-thought)
(when (and suggestion (listp suggestion))
(push suggestion suggestions))))
(if (and *consensus-enabled-p* suggestions)
@@ -227,7 +227,7 @@ Allows the agent to self-optimize its own prompts.
(ask-neuro (format nil "PROMPT: ~a~%RESULT: ~a" full-prompt successful-output) :system-prompt system-instr)))
#+end_src
* Symbolic Logic (symbolic.lisp)
* Deliberate Logic (symbolic.lisp)
The deterministic gatekeeper that ensures all proposed actions are safe and logically valid.
** Package Context
@@ -255,7 +255,7 @@ Enforces high-integrity semantic rules for task management (e.g. blocking closin
#+end_src
** Authorization Gate (Bouncer)
The Bouncer intercepts high-risk or complex actions and requires manual Sovereign approval.
The Bouncer intercepts high-risk or complex actions and requires manual Foreground approval.
#+begin_src lisp :tangle ../src/symbolic.lisp
(defun bouncer-check (action)
@@ -274,20 +274,20 @@ The Bouncer intercepts high-risk or complex actions and requires manual Sovereig
#+end_src
** Validation Gate (decide)
The "System 2" supervisor. It intercepts every action proposed by System 1 and runs it through the task integrity check, the bouncer, the skill's symbolic gate, and the global safety harness.
The "Deliberate" supervisor. It intercepts every action proposed by Associative and runs it through the task integrity check, the bouncer, the skill's symbolic gate, and the global safety harness.
#+begin_src lisp :tangle ../src/symbolic.lisp
(defun decide (proposed-action context)
"The System 2 Safety Gate: validates or rejects proposed neural actions."
"The Deliberate Safety Gate: validates or rejects proposed neural actions."
;; 1. Task Integrity Check (GTD Semantics)
(let ((integrity-error (task-integrity-check proposed-action)))
(when integrity-error
(kernel-log "SYSTEM 2 [INTEGRITY]: ~a~%" integrity-error)
(kernel-log "DELIBERATE [INTEGRITY]: ~a~%" integrity-error)
(return-from decide (list :type :LOG :payload (list :text integrity-error)))))
;; 2. Bouncer Check (Authorization Gate)
(when (bouncer-check proposed-action)
(kernel-log "SYSTEM 2 [BOUNCER]: Action requires manual approval.~%")
(kernel-log "DELIBERATE [BOUNCER]: Action requires manual approval.~%")
(return-from decide
(list :type :EVENT
:payload (list :sensor :approval-required :action proposed-action))))
@@ -305,18 +305,19 @@ The "System 2" supervisor. It intercepts every action proposed by System 1 and r
(let ((harness-pkg (find-package :org-agent.skills.org-skill-safety-harness)))
(when (and code harness-pkg)
(unless (ignore-errors (uiop:symbol-call :org-agent.skills.org-skill-safety-harness :safety-harness-validate code))
(kernel-log "SYSTEM 2 [GLOBAL]: Security violation blocked.~%")
(kernel-log "DELIBERATE [GLOBAL]: Security violation blocked.~%")
(return-from decide '(:type :LOG :payload (:text "Blocked by Global Safety Harness")))))))
;; Skill-specific verification
(if symbolic-gate
(let ((decision (funcall symbolic-gate proposed-action context)))
(if decision
(progn (kernel-log "SYSTEM 2: Verified by skill '~a'.~%" (skill-name active-skill)) decision)
(progn (kernel-log "SYSTEM 2: REJECTED by skill '~a'.~%" (skill-name active-skill))
(progn (kernel-log "DELIBERATE: Verified by skill '~a'.~%" (skill-name active-skill)) decision)
(progn (kernel-log "DELIBERATE: REJECTED by skill '~a'.~%" (skill-name active-skill))
'(:type :LOG :payload (:text "Action rejected by skill heuristics")))))
(progn (kernel-log "SYSTEM 2: Verified (Implicitly safe for skill '~a').~%" (skill-name active-skill)) proposed-action)))
(progn (kernel-log "DELIBERATE: Verified (Implicitly safe for skill '~a').~%" (skill-name active-skill)) proposed-action)))
proposed-action)))
#+end_src
#+end_src
** Store Filtering (list-objects-with-attribute)
A symbolic helper function to find nodes with specific attributes.

View File

@@ -92,7 +92,9 @@ Parsing is the inverse of framing. This function performs three critical safety
;; SECURITY: Prevent Reader Macro Injection (e.g. #. ) during deserialization
(let ((*read-eval* nil))
(read-from-string actual-msg)))))
(let ((msg (read-from-string actual-msg)))
(validate-oacp-schema msg)
msg)))))
#+end_src
** Handshaking (make-hello-message)

View File

@@ -15,9 +15,12 @@
:serial t
:components ((:file "src/package")
(:file "src/protocol")
(:file "src/protocol-validator")
(:file "src/object-store")
(:file "src/embedding")
(:file "src/embedding-logic")
(:file "src/context")
(:file "src/context-logic")
(:file "src/skills")
(:file "src/neuro")
(:file "src/credentials-vault")