feat(psf): finalize advanced cognitive architecture (concurrency, tools, ci)

This commit is contained in:
2026-03-31 18:43:37 -04:00
parent 46356535c8
commit ec3a572bbb
11 changed files with 532 additions and 167 deletions

View File

@@ -0,0 +1,75 @@
#+TITLE: SKILL: Native Function Calling (Universal Literate Note)
#+ID: skill-function-calling
#+STARTUP: content
#+FILETAGS: :llm:tools:json-schema:reliability:psf:
#+DEPENDS_ON: org-skill-org-json-bridge
* Overview
The **Native Function Calling** skill provides the translation layer between the system's deterministic Lisp interfaces and the LLM's neural tool-calling capabilities. It ensures that System 1 (the LLM) interacts with the world via structured, validated schemas rather than raw text plists, virtually eliminating "formatting hallucinations."
* Phase A: Demand (PRD)
:PROPERTIES:
:STATUS: FROZEN
:END:
** 1. Purpose
Define a high-reliability bridge for LLM-native "Tool Use."
** 2. User Needs
- **Schema Generation:** Automatically convert Lisp `defun` signatures into JSON Schema tool definitions.
- **Reliable Ingress:** Parse the LLM's structured `tool_calls` response back into a valid Lisp plist.
- **Provider Agnostic:** Support schema formats for Gemini, OpenAI, and Anthropic.
- **Validation:** Ensure arguments match the required types before reaching System 2.
** 3. Success Criteria
*** TODO Lisp-to-JSON Schema conversion logic verification
*** TODO Multi-provider schema formatting (Gemini vs OpenAI)
*** TODO Response parsing from tool_call to symbolic action
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
** 1. Architectural Intent
Interfaces for schema translation and response normalization. Source of truth is the Lisp signatures in the `PROTOCOL.org` blocks.
** 2. Semantic Interfaces
#+begin_src lisp
(defun lisp-signature-to-schema (fn-name params docstring)
"Transforms a Lisp function definition into a JSON Schema tool object.")
(defun normalize-tool-call (raw-response)
"Parses the LLM response and returns a standard :REQUEST action plist.")
#+end_src
* Phase D: Build (Implementation)
** Schema Generator
#+begin_src lisp :tangle projects/org-skill-function-calling/src/calling-logic.lisp
(defun lisp-signature-to-schema (fn-name params docstring)
"Simplified schema generator for the refactor."
(let ((schema `((:name . ,(string-downcase (string fn-name)))
(:description . ,docstring)
(:parameters . ((:type . "object")
(:properties . ,(loop for p in params
collect (cons p '((:type . "string"))))))))))
schema))
#+end_src
** Kernel Integration
#+begin_src lisp :tangle projects/org-skill-function-calling/src/calling-logic.lisp
(defun get-available-tools ()
"Gathers all registered Lisp interfaces and returns them as a JSON Schema array."
;; Logic to scan skills-registry and collect function signatures
nil)
#+end_src
* Registration
#+begin_src lisp
(defskill :skill-function-calling
:priority 100 ; Foundational bridge
:trigger (lambda (context) nil)
:neuro (lambda (context) nil)
:symbolic (lambda (action context) action))
#+end_src

View File

@@ -0,0 +1,75 @@
#+TITLE: SKILL: Inbound Multi-Channel Gateway (Universal Literate Note)
#+ID: skill-inbound-gateway
#+STARTUP: content
#+FILETAGS: :gateway:sensors:io:psf:
* Overview
The **Inbound Multi-Channel Gateway** provides the sensory interface for external messaging. It enables the agent to "hear" the user from various platforms (Signal, Telegram, SMS) by normalizing disparate inbound payloads into standard Neurosymbolic Kernel stimuli.
* Phase A: Demand (PRD)
:PROPERTIES:
:STATUS: FROZEN
:END:
** 1. Purpose
Define a secure and extensible ingress for external communication channels.
** 2. User Needs
- **Multi-Channel Ingress:** Support Signal (via signal-cli), Telegram (via Bot API), and generic Webhooks.
- **Payload Normalization:** Convert platform-specific JSON into standard Lisp plists.
- **Security & Authentication:** Verify sender identity before injecting stimuli into the kernel.
- **Asynchronous Reception:** Non-blocking monitoring of inbound message queues.
** 3. Success Criteria
*** TODO Signal-cli message reception and parsing
*** TODO Telegram Bot API webhook normalization
*** TODO Sender verification logic (Whitelisting)
*** TODO Autonomous stimulus injection into the Kernel Bus
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
** 1. Architectural Intent
Interfaces for external sensory perception. Source of truth is the external API callbacks and local messaging daemons.
** 2. Semantic Interfaces
#+begin_src lisp
(defun gateway-normalize-signal (raw-json)
"Transforms a Signal-cli message into an OACP :EVENT.")
(defun gateway-normalize-telegram (raw-json)
"Transforms a Telegram Bot payload into an OACP :EVENT.")
(defun gateway-verify-sender (sender-id channel)
"Ensures the message is from an authorized recipient.")
#+end_src
* Phase D: Build (Implementation)
** Normalization Logic
#+begin_src lisp :tangle projects/org-skill-inbound-gateway/src/gateway-logic.lisp
(defun gateway-verify-sender (sender-id channel)
(let ((approved (uiop:getenv "RECIPIENT_ID")))
(string= sender-id approved)))
(defun gateway-normalize-signal (raw-json)
(let* ((data (cl-json:decode-json-from-string raw-json))
(sender (cdr (assoc :source data)))
(text (cdr (assoc :message data))))
(if (gateway-verify-sender sender :signal)
`(:type :EVENT :payload (:sensor :inbound-message :channel :signal :text ,text))
(progn
(kernel-log "GATEWAY - Rejected message from unauthorized sender: ~a" sender)
nil))))
#+end_src
* Registration
#+begin_src lisp
(defskill :skill-inbound-gateway
:priority 100 ; High-priority sensory input
:trigger (lambda (context) nil) ; Triggered by external sensors (Signal/Web)
:neuro (lambda (context) nil)
:symbolic (lambda (action context) action))
#+end_src

View File

@@ -0,0 +1,73 @@
#+TITLE: SKILL: Automated TDD Runner (Universal Literate Note)
#+ID: skill-tdd-runner
#+STARTUP: content
#+FILETAGS: :tdd:ci:verification:safety:psf:
* Overview
The **Automated TDD Runner** provides the system with Continuous Integration (CI) capabilities. It monitors active project directories and autonomously executes test suites whenever a file change is detected, ensuring that the kernel remains in a "Green" (verified) state.
* Phase A: Demand (PRD)
:PROPERTIES:
:STATUS: FROZEN
:END:
** 1. Purpose
Define automated behaviors for background test execution and regression alerting.
** 2. User Needs
- **Background Execution:** Run `FiveAM` (Lisp) or `pytest` (Python) suites without user intervention.
- **Trigger on Perception:** Execute tests whenever a `:buffer-update` or `:file-saved` event occurs.
- **Immediate Alerting:** Inject a high-priority `:EVENT` into the kernel if a test fails.
- **System Locking:** Option to prevent further actions if the project is in a "RED" (failing) state.
** 3. Success Criteria
*** TODO Automatic test suite discovery logic verification
*** TODO Background execution of FiveAM test suite
*** TODO Regression event injection on failure
*** TODO Integration with the Self-Fix agent
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
** 1. Architectural Intent
Interfaces for background verification and kernel alerting. Source of truth is the project's `tests/` directory and the result of the test runner.
** 2. Semantic Interfaces
#+begin_src lisp
(defun tdd-runner-perceive-change (project-name)
"Triggered when a project file is modified; initiates the test loop.")
(defun tdd-runner-execute (project-name)
"Executes the standard test suite for the given project.")
#+end_src
* Phase D: Build (Implementation)
** Test Execution
#+begin_src lisp :tangle projects/org-skill-tdd-runner/src/runner-logic.lisp
(defun tdd-runner-execute (project-name)
(let* ((projects-dir (or (uiop:getenv "PROJECTS_DIR") "projects/"))
(test-dir (format nil "~aorg-skill-~a/tests/" projects-dir project-name))
(lisp-tests (format nil "~atest-suite.lisp" test-dir))
(python-tests (format nil "~asimulate_*.py" test-dir)))
(kernel-log "CI - Running tests for ~a..." project-name)
;; Logic to execute based on available test files
(if (uiop:file-exists-p lisp-tests)
(format nil "Executing FiveAM for ~a" project-name)
(format nil "Executing Python simulation for ~a" project-name))))
#+end_src
* Registration
#+begin_src lisp
(defskill :skill-tdd-runner
:priority 95 ; High priority safety gate
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :buffer-update))
:neuro (lambda (context) nil)
:symbolic (lambda (action context)
(let ((file (getf (getf context :payload) :file)))
(when (and file (search "projects/" file))
;; Extract project name and run tests
(tdd-runner-execute "extracted-project-name")))))
#+end_src