ARCH: Finalize Microkernel Decoupling - Move behavioral skills to dynamic user-space

This commit is contained in:
2026-04-13 16:11:09 -04:00
parent 34f59a6e43
commit 19fb888434
74 changed files with 129 additions and 2744 deletions

View File

@@ -23,8 +23,7 @@ While the *Formal Prover* ensures an action is "legal" (e.g., "Yes, you are allo
*** Secret Exposure Check
Retrieves all active secrets from the vault and scans the payload for potential leaks.
#+begin_src lisp :tangle ../src/bouncer.lisp
(in-package :org-agent)
#+begin_src lisp
(defun bouncer-scan-secrets (text)
"Returns the name of the secret found in TEXT, or NIL if clean."
(when (and text (stringp text))
@@ -40,8 +39,7 @@ Retrieves all active secrets from the vault and scans the payload for potential
*** Network Exfiltration Check
Inspects shell commands for unwhitelisted domains or IP addresses.
#+begin_src lisp :tangle ../src/bouncer.lisp
(in-package :org-agent)
#+begin_src lisp
(defun bouncer-check-network-exfil (cmd)
"Returns T if the command appears to target an unwhitelisted external host."
(when (and cmd (stringp cmd))
@@ -58,8 +56,7 @@ Inspects shell commands for unwhitelisted domains or IP addresses.
** Runtime Guard (bouncer-check)
The primary entry point for all high-impact actions.
#+begin_src lisp :tangle ../src/bouncer.lisp
(in-package :org-agent)
#+begin_src lisp
(defun bouncer-check (action context)
"The 5-Vector security gate. Blocks or queues actions based on risk."
(let* ((target (getf action :target))
@@ -100,8 +97,7 @@ The primary entry point for all high-impact actions.
#+end_src
** Approval Processing
#+begin_src lisp :tangle ../src/bouncer.lisp
(in-package :org-agent)
#+begin_src lisp
(defun bouncer-process-approvals ()
"Scans the object store for APPROVED flight plans and re-injects their actions."
(let ((approved-nodes (list-objects-with-attribute :TODO "APPROVED"))
@@ -123,8 +119,7 @@ The primary entry point for all high-impact actions.
#+end_src
** Skill Definition
#+begin_src lisp :tangle ../src/bouncer.lisp
(in-package :org-agent)
#+begin_src lisp
(defskill :skill-bouncer
:priority 100
:trigger (lambda (ctx)

View File

@@ -49,8 +49,7 @@ Interfaces for conversational event handling and UI integration. Source of truth
* Phase D: Build (Implementation)
** Event Perception
#+begin_src lisp :tangle ../src/chat-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun chat-archive-message (text &key (role :user) channel chat-id)
"Archives a chat message into the persistent Memory and triggers a snapshot."
@@ -76,7 +75,7 @@ Interfaces for conversational event handling and UI integration. Source of truth
#+end_src
** Deterministic Verification
#+begin_src lisp :tangle ../src/chat-logic.lisp
#+begin_src lisp
(defun verify-skill-chat (proposed-action context)
(let* ((payload (getf proposed-action :payload))
(action (or (getf payload :action) (getf proposed-action :action)))
@@ -108,7 +107,7 @@ Interfaces for conversational event handling and UI integration. Source of truth
** Neural Response Generation
The Chat skill acts as the conversational UI. Because the ~org-agent~ kernel evaluates LLM output via ~read-from-string~ (expecting a valid s-expression) and the chat verifier strictly expects an Emacs ~:insert-at-end~ actuation, we must explicitly mandate that the LLM wraps its conversational output in a Common Lisp property list.
#+begin_src lisp :tangle ../src/chat-logic.lisp
#+begin_src lisp
(defun probabilistic-skill-chat (context)
"Generates a conversational response, stripping system errors from context."
(let* ((payload (getf context :payload))
@@ -138,7 +137,7 @@ REQUIRED FORMATS:
#+end_src
* Registration
#+begin_src lisp :tangle ../src/chat-logic.lisp
#+begin_src lisp
(defskill :skill-chat
:priority 100
:trigger #'trigger-skill-chat

View File

@@ -27,8 +27,7 @@ Enable reliable, cross-instance coordination without a central master.
* Phase D: Build (Implementation)
** Consensus Algorithm (Simplified Raft)
#+begin_src lisp :tangle ../src/consensus-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun consensus-propose-vote (proposal)
"Broadcasts a proposal to the peer swarm and collects votes.
Implements PSF Social Consensus Protocol."

View File

@@ -61,14 +61,13 @@ Tests in `tests/vault-tests.lisp` will verify:
* Phase D: Build (Implementation)
** Package Context
#+begin_src lisp :tangle ../src/credentials-vault.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** Vault State
We maintain an in-memory hash table for secrets, which is hydrated from and persisted to the Memory.
#+begin_src lisp :tangle ../src/credentials-vault.lisp
#+begin_src lisp
(defvar *vault-memory* (make-hash-table :test 'equal)
"In-memory cache of sensitive credentials.")
#+end_src
@@ -76,7 +75,7 @@ We maintain an in-memory hash table for secrets, which is hydrated from and pers
** Helper: Secret Masking
The `vault-mask-string` function ensures that diagnostic output never contains the full plaintext of a sensitive token.
#+begin_src lisp :tangle ../src/credentials-vault.lisp
#+begin_src lisp
(defun vault-mask-string (str)
"Returns a masked version of a sensitive string."
(if (and str (> (length str) 8))
@@ -87,7 +86,7 @@ The `vault-mask-string` function ensures that diagnostic output never contains t
** Retrieval (vault-get-secret)
This function is the secure getter for all system secrets. It prioritizes the Vault (Memory) and falls back to environment variables for legacy compatibility.
#+begin_src lisp :tangle ../src/credentials-vault.lisp
#+begin_src lisp
(defun vault-get-secret (provider &key (type :api-key))
"Retrieves a credential. Type can be :api-key or :session."
(let* ((key (format nil "~a-~a" provider type))
@@ -113,7 +112,7 @@ This function is the secure getter for all system secrets. It prioritizes the Va
** Persistence (vault-set-secret)
When a secret is updated, we immediately snapshot the Memory to ensure the credential change is versioned and durable.
#+begin_src lisp :tangle ../src/credentials-vault.lisp
#+begin_src lisp
(defun vault-set-secret (provider secret &key (type :api-key))
"Securely stores a secret and triggers a Merkle snapshot."
(let ((key (format nil "~a-~a" provider type)))
@@ -126,7 +125,7 @@ When a secret is updated, we immediately snapshot the Memory to ensure the crede
** Onboarding Logic
Retained from the legacy Google skill, this provides the instructions for the sovereign cookie handshake.
#+begin_src lisp :tangle ../src/credentials-vault.lisp
#+begin_src lisp
(defun vault-onboard-gemini-web ()
"Instructions for the Sovereign Cookie Handshake."
(harness-log "--- GEMINI WEB ONBOARDING ---")
@@ -138,7 +137,7 @@ Retained from the legacy Google skill, this provides the instructions for the so
#+end_src
** Registration
#+begin_src lisp :tangle ../src/credentials-vault.lisp
#+begin_src lisp
(progn
(defskill :skill-credentials-vault
:priority 200 ; High priority, foundational
@@ -152,7 +151,7 @@ Retained from the legacy Google skill, this provides the instructions for the so
* Phase E: Chaos (Verification)
** 1. Unit Tests (FiveAM)
#+begin_src lisp :tangle ../tests/vault-tests.lisp
#+begin_src lisp
(defpackage :org-agent-vault-tests
(:use :cl :fiveam :org-agent))
(in-package :org-agent-vault-tests)

View File

@@ -51,8 +51,7 @@ Move heavy neural and mathematical logic out of `core.lisp` and `probabilistic.l
* Phase D: Build (Implementation)
** Vector Operations
#+begin_src lisp :tangle ../src/embedding-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun get-embedding (text)
"Retrieves a vector representation of text via the configured neural provider."
@@ -104,7 +103,7 @@ Move heavy neural and mathematical logic out of `core.lisp` and `probabilistic.l
#+end_src
* Registration
#+begin_src lisp :tangle ../src/embedding-logic.lisp
#+begin_src lisp
(defskill :skill-embedding
:priority 50
:trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :embedding-request))

View File

@@ -34,8 +34,7 @@ Define a standardized `CONFIG` object type in the Memory. Provide getter/setter
** 2. Semantic Interfaces
*** Fleet Configuration
#+begin_src lisp :tangle ../src/config-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun set-llm-model (provider model-id)
"Registers a preferred model for a provider in the Memory."

View File

@@ -66,14 +66,13 @@ Tests in `tests/orchestrator-tests.lisp` will verify hook execution order, cron-
* Phase D: Build (Implementation)
** Package Context
#+begin_src lisp :tangle ../src/event-orchestrator.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** Registry State
We maintain our internal registries in hash-tables, which will be serialized via the State Persistence layer.
#+begin_src lisp :tangle ../src/event-orchestrator.lisp
#+begin_src lisp
(defvar *hook-registry* (make-hash-table :test 'equal)
"Maps hook-names (symbols) to lists of functions.")
@@ -84,7 +83,7 @@ We maintain our internal registries in hash-tables, which will be serialized via
** Hook: Registration
Allows external skills to register logic at system lifecycle points.
#+begin_src lisp :tangle ../src/event-orchestrator.lisp
#+begin_src lisp
(defun orchestrator-register-hook (hook-name fn)
"Registers a function for a named hook. Triggers a Merkle snapshot."
(pushnew fn (gethash hook-name *hook-registry*))
@@ -96,7 +95,7 @@ Allows external skills to register logic at system lifecycle points.
** Hook: Triggering
Executes all functions associated with a specific hook.
#+begin_src lisp :tangle ../src/event-orchestrator.lisp
#+begin_src lisp
(defun orchestrator-trigger-hook (hook-name &rest args)
"Executes all registered functions for the given hook name."
(let ((functions (gethash hook-name *hook-registry*)))
@@ -108,7 +107,7 @@ Executes all functions associated with a specific hook.
** Cron: Task Scheduling
Registers a recurring task to be executed during heartbeats.
#+begin_src lisp :tangle ../src/event-orchestrator.lisp
#+begin_src lisp
(defun orchestrator-schedule-task (task-id schedule fn)
"Schedules a task for execution. Schedule can be an interval (integer seconds) or 'heartbeat'."
(setf (gethash task-id *cron-registry*) (list :schedule schedule :fn fn :last-run 0))
@@ -120,7 +119,7 @@ Registers a recurring task to be executed during heartbeats.
** Cron: Heartbeat Processor
The internal loop that checks the cron-registry during every system pulse.
#+begin_src lisp :tangle ../src/event-orchestrator.lisp
#+begin_src lisp
(defun orchestrator-process-cron ()
"Checked by the harness on every heartbeat."
(let ((now (get-universal-time)))
@@ -139,7 +138,7 @@ The internal loop that checks the cron-registry during every system pulse.
** Router: Complexity Classification
Deterministic logic to classify incoming stimuli into complexity tiers.
#+begin_src lisp :tangle ../src/event-orchestrator.lisp
#+begin_src lisp
(defun orchestrator-classify-complexity (context)
"Returns the complexity tier (:REFLEX, :COGNITION, :REASONING) for a stimulus."
(let* ((payload (getf context :payload))
@@ -162,7 +161,7 @@ Deterministic logic to classify incoming stimuli into complexity tiers.
** Registration
We register the orchestrator as a core skill and hot-patch the harness's routing hook to use our classification logic.
#+begin_src lisp :tangle ../src/event-orchestrator.lisp
#+begin_src lisp
(progn
;; Hook into kernel routing
(setf org-agent::*model-selector-fn* #'orchestrator-classify-complexity)
@@ -179,7 +178,7 @@ We register the orchestrator as a core skill and hot-patch the harness's routing
* Phase E: Chaos (Verification)
** 1. Unit Tests (FiveAM)
#+begin_src lisp :tangle ../tests/orchestrator-tests.lisp
#+begin_src lisp
(defpackage :org-agent-orchestrator-tests
(:use :cl :fiveam :org-agent))
(in-package :org-agent-orchestrator-tests)

View File

@@ -48,20 +48,19 @@ The gate operates as high-priority middleware. It decomposes proposed actions an
* Phase D: Build (Implementation)
** Package Context
#+begin_src lisp :tangle ../src/verification-logic.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** Invariant Registry
Global store for all registered security invariants.
#+begin_src lisp :tangle ../src/verification-logic.lisp
#+begin_src lisp
(defvar *formal-invariants* (make-hash-table :test 'equal)
"Registry of security invariants used by the Formal Verification Gate.")
#+end_src
** Invariant Definition Macro
#+begin_src lisp :tangle ../src/verification-logic.lisp
#+begin_src lisp
(defmacro def-invariant (name action-type (action context) &body body)
"Defines a formal security invariant.
BODY must return T for safe actions and NIL for unsafe ones."
@@ -74,7 +73,7 @@ Global store for all registered security invariants.
** Invariant: Path Confinement
Ensures all file-related operations (including shell calls that touch files) are confined to the memex root.
#+begin_src lisp :tangle ../src/verification-logic.lisp
#+begin_src lisp
(def-invariant path-confinement :all (action context)
"Forces all path-based operations to reside within the Sovereign Memex."
(declare (ignore context))
@@ -99,7 +98,7 @@ Ensures all file-related operations (including shell calls that touch files) are
** Invariant: No Network Exfiltration
Blocks common tools and patterns used for data exfiltration via the shell.
#+begin_src lisp :tangle ../src/verification-logic.lisp
#+begin_src lisp
(def-invariant no-network-exfil :shell (action context)
"Prevents shell commands from establishing unauthorized external connections."
(declare (ignore context))
@@ -115,7 +114,7 @@ Blocks common tools and patterns used for data exfiltration via the shell.
** Verification Engine
The core prover that applies all relevant invariants to an action.
#+begin_src lisp :tangle ../src/verification-logic.lisp
#+begin_src lisp
(defun verify-action-formally (action context)
"Deterministically proves that ACTION satisfies all applicable security invariants."
(let ((action-target (getf action :target))
@@ -137,7 +136,7 @@ The core prover that applies all relevant invariants to an action.
#+end_src
** Registration: Skill
#+begin_src lisp :tangle ../src/verification-logic.lisp
#+begin_src lisp
(defskill :skill-formal-verification
:priority 95 ; Just below Bouncer
:trigger (lambda (context) (declare (ignore context)) nil) ; Middleware only

View File

@@ -38,38 +38,37 @@ Autonomous background polling of the Matrix homeserver. Uses `dexador` for HTTP
* Phase D: Build (Implementation)
** Package Context
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** State: Sync Token
Tracks the last processed event to ensure we only receive new messages.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defvar *matrix-since-token* nil)
#+end_src
** State: Polling Thread
Reference to the background thread responsible for sync requests.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defvar *matrix-polling-thread* nil)
#+end_src
** Credential Retrieval: Homeserver
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defun get-matrix-homeserver () (vault-get-secret :matrix-homeserver))
#+end_src
** Credential Retrieval: Token
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defun get-matrix-token () (vault-get-secret :matrix-token))
#+end_src
** Actuator: sendMessage
Sends an `m.room.message` to a Matrix room.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defun execute-matrix-action (action context)
"Sends a message via Matrix Client API."
(declare (ignore context))
@@ -94,7 +93,7 @@ Sends an `m.room.message` to a Matrix room.
** Sensor: Sync loop & Injection
Polls the `/sync` endpoint and processes timeline events.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defun matrix-process-sync ()
"Calls Matrix sync and injects new messages."
(let* ((hs (get-matrix-homeserver))
@@ -138,7 +137,7 @@ Polls the `/sync` endpoint and processes timeline events.
** Start Polling
Initializes the Matrix background thread.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defun start-matrix-gateway ()
"Initializes the Matrix background thread."
(unless (and *matrix-polling-thread* (bt:thread-alive-p *matrix-polling-thread*))
@@ -155,7 +154,7 @@ Initializes the Matrix background thread.
** Stop Polling
Gracefully terminates the background thread.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defun stop-matrix-gateway ()
(when (and *matrix-polling-thread* (bt:thread-alive-p *matrix-polling-thread*))
(bt:destroy-thread *matrix-polling-thread*)
@@ -165,14 +164,14 @@ Gracefully terminates the background thread.
** Registration: Actuator
Register the Matrix channel as a physical actuator.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(register-actuator :matrix #'execute-matrix-action)
#+end_src
** Registration: Skill
Define the passive skill entry for the gateway.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(defskill :skill-gateway-matrix
:priority 150
:trigger (lambda (ctx) (declare (ignore ctx)) nil)
@@ -183,6 +182,6 @@ Define the passive skill entry for the gateway.
** Initialization
Trigger the sync loop upon loading.
#+begin_src lisp :tangle ../src/gateway-matrix.lisp
#+begin_src lisp
(start-matrix-gateway)
#+end_src

View File

@@ -38,28 +38,27 @@ Wraps the `signal-cli` binary. Polling is done in a background thread to prevent
* Phase D: Build (Implementation)
** Package Context
#+begin_src lisp :tangle ../src/gateway-signal.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** State: Signal Identity
Retrieves the Signal account number from the secure vault.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(defun get-signal-account () (vault-get-secret :signal))
#+end_src
** State: Polling Thread
Reference to the background thread responsible for message reception.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(defvar *signal-polling-thread* nil)
#+end_src
** Actuator: sendMessage
Executes the `signal-cli send` command.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(defun execute-signal-action (action context)
"Sends a message via signal-cli."
(declare (ignore context))
@@ -78,7 +77,7 @@ Executes the `signal-cli send` command.
** Sensor: receive & Injection
Polls for new messages and injects them into the harness.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(defun signal-process-updates ()
"Polls for new messages via signal-cli and injects them into the harness."
(let ((account (get-signal-account)))
@@ -108,7 +107,7 @@ Polls for new messages and injects them into the harness.
** Start Polling
Initializes the Signal background thread.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(defun start-signal-gateway ()
"Initializes the Signal background thread."
(unless (and *signal-polling-thread* (bt:thread-alive-p *signal-polling-thread*))
@@ -125,7 +124,7 @@ Initializes the Signal background thread.
** Stop Polling
Gracefully terminates the background thread.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(defun stop-signal-gateway ()
(when (and *signal-polling-thread* (bt:thread-alive-p *signal-polling-thread*))
(bt:destroy-thread *signal-polling-thread*)
@@ -135,14 +134,14 @@ Gracefully terminates the background thread.
** Registration: Actuator
Register the Signal channel as a physical actuator.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(register-actuator :signal #'execute-signal-action)
#+end_src
** Registration: Skill
Define the passive skill entry for the gateway.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(defskill :skill-gateway-signal
:priority 150
:trigger (lambda (ctx) (declare (ignore ctx)) nil) ;; Passive
@@ -153,6 +152,6 @@ Define the passive skill entry for the gateway.
** Initialization
Trigger the polling loop upon loading.
#+begin_src lisp :tangle ../src/gateway-signal.lisp
#+begin_src lisp
(start-signal-gateway)
#+end_src

View File

@@ -38,28 +38,27 @@ The gateway operates as an autonomous background service. It uses `dexador` for
* Phase D: Build (Implementation)
** Package Context
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** State: Update Tracking
Tracks the last processed message ID to prevent duplicates.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defvar *telegram-last-update-id* 0)
#+end_src
** State: Polling Thread
Reference to the background thread responsible for message reception.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defvar *telegram-polling-thread* nil)
#+end_src
** State: Authorized Chats
Whitelist of chat IDs permitted to interact with the agent.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defvar *telegram-authorized-chats* nil
"List of chat IDs allowed to interact with the bot. Hydrated from environment.")
#+end_src
@@ -67,12 +66,12 @@ Whitelist of chat IDs permitted to interact with the agent.
** Token Retrieval
Fetches the Bot API token from the secure vault.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defun get-telegram-token () (vault-get-secret :telegram))
#+end_src
** Actuator: sendMessage
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defun execute-telegram-action (action context)
"Sends a message back to Telegram."
(declare (ignore context))
@@ -92,7 +91,7 @@ Fetches the Bot API token from the secure vault.
#+end_src
** Sensor: getUpdates & Injection
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defun telegram-process-updates ()
"Polls for new messages and injects them into the harness."
(let* ((token (get-telegram-token))
@@ -124,7 +123,7 @@ Fetches the Bot API token from the secure vault.
** Start Polling
Initializes the Telegram background thread.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defun start-telegram-gateway ()
"Initializes the Telegram background thread."
(unless (and *telegram-polling-thread* (bt:thread-alive-p *telegram-polling-thread*))
@@ -141,7 +140,7 @@ Initializes the Telegram background thread.
** Stop Polling
Gracefully terminates the background thread.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defun stop-telegram-gateway ()
(when (and *telegram-polling-thread* (bt:thread-alive-p *telegram-polling-thread*))
(bt:destroy-thread *telegram-polling-thread*)
@@ -151,14 +150,14 @@ Gracefully terminates the background thread.
** Registration: Actuator
Register the Telegram channel as a physical actuator.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(register-actuator :telegram #'execute-telegram-action)
#+end_src
** Registration: Skill
Define the passive skill entry for the gateway.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(defskill :skill-gateway-telegram
:priority 150
:trigger (lambda (ctx) (declare (ignore ctx)) nil) ;; Passive, handles its own loop
@@ -169,6 +168,6 @@ Define the passive skill entry for the gateway.
** Initialization
Trigger the polling loop upon loading.
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
#+begin_src lisp
(start-telegram-gateway)
#+end_src

View File

@@ -12,8 +12,7 @@ The *Harness Monitor* provides tools for inspecting the internal state and healt
* Implementation
#+begin_src lisp :tangle ../src/harness-monitor.lisp
(in-package :org-agent)
#+begin_src lisp
(org-agent:def-cognitive-tool :harness-status \"Returns the current operational status of the Org-Agent harness, including loaded skills and telemetry.\"
nil

View File

@@ -60,14 +60,13 @@ Tests in `tests/memory-suite-tests.lisp` will verify the round-trip conversion a
* Phase D: Build (Implementation)
** Package Context
#+begin_src lisp :tangle ../src/homoiconic-memory.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** Node Structure Definition
We define the standard `org-node` structure used throughout the harness.
#+begin_src lisp :tangle ../src/homoiconic-memory.lisp
#+begin_src lisp
(defun make-memory-node (headline &key content properties children)
"Constructor for a normalized Org node alist."
(list :type :HEADLINE
@@ -79,7 +78,7 @@ We define the standard `org-node` structure used throughout the harness.
** ID Generation (org-id-get-create)
Mandated standard for ID creation. This function ensures that every node in the Memex has a unique, deterministic identifier.
#+begin_src lisp :tangle ../src/homoiconic-memory.lisp
#+begin_src lisp
(defun org-id-get-create ()
"Generates a new unique ID for an Org node. This is the system-wide standard."
(format nil "node-~a" (get-universal-time)))
@@ -88,7 +87,7 @@ Mandated standard for ID creation. This function ensures that every node in the
** ID Injection (memory-ensure-id)
Ensures every headline has a unique ID property using the system standard `org-id-get-create`. This is foundational for the Merkle-Tree object store.
#+begin_src lisp :tangle ../src/homoiconic-memory.lisp
#+begin_src lisp
(defun memory-ensure-id (node)
"Injects a unique ID into an Org node if missing, using the standard org-id-get-create mechanism."
(let* ((props (getf node :properties))
@@ -104,7 +103,7 @@ Ensures every headline has a unique ID property using the system standard `org-i
** Recursive Normalization (memory-normalize-ast)
Recursively walks the AST to enforce structural rules.
#+begin_src lisp :tangle ../src/homoiconic-memory.lisp
#+begin_src lisp
(defun memory-normalize-ast (ast)
"Recursively normalizes an Org AST."
(let ((type (getf ast :type))
@@ -124,7 +123,7 @@ Recursively walks the AST to enforce structural rules.
** JSON Bridge: Org-to-JSON
Utilizes the Emacs bridge (or local parser) to convert text to JSON.
#+begin_src lisp :tangle ../src/homoiconic-memory.lisp
#+begin_src lisp
(defun memory-org-to-json (source-path)
"Routes to the Emacs-based Org-JSON bridge."
;; Future implementation will use the org-json-convert CLI tool
@@ -135,7 +134,7 @@ Utilizes the Emacs bridge (or local parser) to convert text to JSON.
** JSON Bridge: JSON-to-Org
Converts a structured AST back into Org-mode text.
#+begin_src lisp :tangle ../src/homoiconic-memory.lisp
#+begin_src lisp
(defun memory-json-to-org (ast)
"Materializes a JSON AST into Org-mode text."
;; Placeholder for org-element-interpret-data equivalent
@@ -144,7 +143,7 @@ Converts a structured AST back into Org-mode text.
#+end_src
** Registration
#+begin_src lisp :tangle ../src/homoiconic-memory.lisp
#+begin_src lisp
(progn
(defskill :skill-homoiconic-memory
:priority 300 ; Core foundational skill
@@ -159,7 +158,7 @@ Converts a structured AST back into Org-mode text.
* Phase E: Chaos (Verification)
** 1. Unit Tests (FiveAM)
#+begin_src lisp :tangle ../tests/memory-suite-tests.lisp
#+begin_src lisp
(defpackage :org-agent-memory-tests
(:use :cl :fiveam :org-agent))
(in-package :org-agent-memory-tests)

View File

@@ -12,8 +12,7 @@ The *Lisp Repair Syntax Gate* asynchronously intercepts `:syntax-error` events e
* Implementation
** Core Repair Logic
#+begin_src lisp :tangle ../src/lisp-repair.lisp
(in-package :org-agent)
#+begin_src lisp
(defun count-char (char string)
(let ((count 0))
@@ -46,7 +45,7 @@ MANDATE: Output EXACTLY ONE valid Common Lisp list. Do not explain. Do not use m
** Skill Definition
Reacts to syntax error events and transforms them into repaired requests.
#+begin_src lisp :tangle ../src/lisp-repair.lisp
#+begin_src lisp
(defskill :skill-lisp-repair
:priority 90
:trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :syntax-error))

View File

@@ -33,12 +33,11 @@ Define a high-integrity, recursive security sandbox for Lisp execution.
* Implementation
** Package
#+begin_src lisp :tangle ../src/lisp-validator.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** Whitelist Definition
#+begin_src lisp :tangle ../src/lisp-validator.lisp
#+begin_src lisp
(defparameter *lisp-validator-whitelist*
'(;; Math & Logic
+ - * / = < > <= >= 1+ 1- min max
@@ -84,7 +83,7 @@ Define a high-integrity, recursive security sandbox for Lisp execution.
** Dynamic Symbol Registration
We allow other skills to register safe symbols for the validator.
#+begin_src lisp :tangle ../src/lisp-validator.lisp
#+begin_src lisp
(defvar *lisp-validator-registry* nil
"List of dynamically registered safe symbols.")
@@ -100,7 +99,7 @@ We allow other skills to register safe symbols for the validator.
#+end_src
** Recursive AST Walker
#+begin_src lisp :tangle ../src/lisp-validator.lisp
#+begin_src lisp
(defun lisp-validator-ast-walk (form)
"Recursively walks the Lisp AST. Returns T if safe, NIL if unsafe."
(cond
@@ -125,7 +124,7 @@ We allow other skills to register safe symbols for the validator.
#+end_src
** Cognitive Tools
#+begin_src lisp :tangle ../src/lisp-validator.lisp
#+begin_src lisp
(org-agent:def-cognitive-tool :lisp-validator-status "Returns validator-related telemetry, including blocked actions and harness status."
nil
:body (lambda (args)
@@ -140,7 +139,7 @@ We allow other skills to register safe symbols for the validator.
#+end_src
** Skill Definition
#+begin_src lisp :tangle ../src/lisp-validator.lisp
#+begin_src lisp
(org-agent:defskill :skill-lisp-validator
:priority 900 ; High priority, before most skills
:trigger (lambda (ctx)
@@ -157,7 +156,7 @@ We allow other skills to register safe symbols for the validator.
* Phase E: Chaos (Verification)
#+begin_src lisp :tangle ../tests/lisp-validator-tests.lisp
#+begin_src lisp
(defpackage :org-agent-lisp-validator-tests
(:use :cl :fiveam :org-agent)
(:export #:lisp-validator-suite))

View File

@@ -56,14 +56,13 @@ Verification will occur via `tests/llm-gateway-tests.lisp` using the FiveAM fram
* Phase D: Build (Implementation)
** Package Context
#+begin_src lisp :tangle ../src/llm-gateway.lisp
(in-package :org-agent)
#+begin_src lisp
#+end_src
** Nested Extraction Helper (get-nested)
A robust utility to navigate deeply nested JSON alists produced by `cl-json`, handling both objects and arrays.
#+begin_src lisp :tangle ../src/llm-gateway.lisp
#+begin_src lisp
(defun get-nested (alist &rest keys)
"Recursively extracts nested values from an alist, handling both objects and arrays."
(let ((val alist))
@@ -82,7 +81,7 @@ A robust utility to navigate deeply nested JSON alists produced by `cl-json`, ha
** Unified Request Executor (execute-llm-request)
This is the primary actuator for neural reasoning. It handles the specific JSON payload formats and HTTP headers required by each provider. It retrieves secrets from the [[file:org-skill-credentials-vault.org][Credentials Vault]], ensuring that API keys are masked in all diagnostic output.
#+begin_src lisp :tangle ../src/llm-gateway.lisp
#+begin_src lisp
(defun execute-llm-request (prompt system-prompt &key provider model)
"Unified entry point for all LLM providers."
(let ((api-key (vault-get-secret provider :type :api-key))
@@ -144,7 +143,7 @@ The `:ask-llm` tool exposes the gateway's power to Probabilistic Engine, allowin
** Registration: Tool
Register the unified gateway as a cognitive tool.
#+begin_src lisp :tangle ../src/llm-gateway.lisp
#+begin_src lisp
(def-cognitive-tool :ask-llm
"Queries an LLM provider via the unified gateway."
((:prompt :type :string :description "The user prompt.")
@@ -159,7 +158,7 @@ Register the unified gateway as a cognitive tool.
#+end_src
Register each supported provider with the harness's neural registry.
#+begin_src lisp :tangle ../src/llm-gateway.lisp
#+begin_src lisp
(dolist (p '(:anthropic :gemini-api :gemini-web :groq :ollama :openai :openrouter))
(org-agent:register-probabilistic-backend p (lambda (prompt system-prompt &key model)
(execute-llm-request prompt system-prompt :provider p :model model))))
@@ -168,7 +167,7 @@ Register each supported provider with the harness's neural registry.
** Registration: Skill
Define the foundational skill entry for the gateway.
#+begin_src lisp :tangle ../src/llm-gateway.lisp
#+begin_src lisp
(defskill :skill-llm-gateway
:priority 150 ; Higher than individual old skills
:trigger (lambda (context) (declare (ignore context)) nil)

View File

@@ -48,8 +48,7 @@ Move context pruning and rendering logic out of `context.lisp` to allow for more
* Phase D: Build (Implementation)
** Foveal-Peripheral Pruning
#+begin_src lisp :tangle ../src/context-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun context-render-to-org (obj &key (depth 1) (foveal-id nil) (semantic-threshold 0.75) (foveal-vector nil))
"Recursively renders an org-object and its children to an Org string using a Foveal-Peripheral Hybrid model."
@@ -113,7 +112,7 @@ Move context pruning and rendering logic out of `context.lisp` to allow for more
#+end_src
* Registration
#+begin_src lisp :tangle ../src/context-logic.lisp
#+begin_src lisp
(defskill :skill-peripheral-vision
:priority 90
:dependencies ("org-skill-embedding")

View File

@@ -19,8 +19,7 @@ Unlike traditional software where a "Kernel" might have hardcoded rules, the Org
* Implementation
#+begin_src lisp :tangle ../src/policy-enforcer.lisp
(in-package :org-agent)
#+begin_src lisp
(defskill :skill-policy-enforcer
:priority 1000 ; Absolute highest priority

View File

@@ -15,8 +15,7 @@ The *Self-Fix Agent* is the system's "Repair Mechanism." It takes failure hypoth
* Phase D: Build (Implementation)
** Repair Logic
#+begin_src lisp :tangle ../src/self-fix.lisp
(in-package :org-agent)
#+begin_src lisp
(defun self-fix-apply (action context)
"Applies a surgical code fix and reloads the modified skill."
@@ -64,7 +63,7 @@ The *Self-Fix Agent* is the system's "Repair Mechanism." It takes failure hypoth
#+end_src
** Registration
#+begin_src lisp :tangle ../src/self-fix.lisp
#+begin_src lisp
(def-cognitive-tool :repair-file
"Applies a surgical code modification to a file and reloads the skill if applicable."
((:file :type :string :description "Path to the target file")

View File

@@ -78,16 +78,14 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu
** Allowed Commands
Whitelist of permitted host binaries.
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defparameter *allowed-commands* '("ls" "git" "rg" "grep" "date" "echo" "cat" "node" "python3" "sbcl"))
#+end_src
** Shell Metacharacters
Dangerous characters that are banned to prevent command injection.
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defparameter *shell-metacharacters* '(#\; #\& #\| #\> #\< #\$ #\` #\\ #\!)
"Characters that are banned in shell commands to prevent injection.")
#+end_src
@@ -95,8 +93,7 @@ Dangerous characters that are banned to prevent command injection.
** Safety Check (shell-command-safe-p)
Predicate to verify a command string is free of metacharacters.
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun shell-command-safe-p (cmd-string)
"Returns T if the command string contains no dangerous metacharacters."
(not (some (lambda (char) (find char cmd-string)) *shell-metacharacters*)))
@@ -105,8 +102,7 @@ Predicate to verify a command string is free of metacharacters.
** Shell Execution (execute-shell-safely)
The primary secure actuator for host system calls.
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun execute-shell-safely (action context)
(let* ((cmd-string (getf (getf action :payload) :cmd))
(executable (car (uiop:split-string (string-trim " " cmd-string) :separator '(#\Space)))))
@@ -136,8 +132,7 @@ The primary secure actuator for host system calls.
** Script Synthesis (execute-sandboxed-script)
Executes a synthesized script (Python/Lisp/JS) in a controlled directory.
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun execute-sandboxed-script (action context)
"Executes a synthesized script (Python/Lisp/JS) in a controlled directory.
This enables SOTA-level Tool Synthesis and Iterative Fixing."
@@ -166,8 +161,7 @@ Executes a synthesized script (Python/Lisp/JS) in a controlled directory.
** Infrastructure: MicroVM Provisioning
Hardware-Level Isolation for future security evolution.
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun provision-microvm (id &key (cpu 1) (ram 512))
"Hardware-Level Isolation: Provisions an ephemeral Firecracker MicroVM.
This is the high-security evolution of directory-based sandboxing."
@@ -177,8 +171,7 @@ Hardware-Level Isolation for future security evolution.
#+end_src
** Feedback Perception
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun trigger-skill-shell-actuator (context)
(let ((type (getf context :type))
(payload (getf context :payload)))
@@ -187,8 +180,7 @@ Hardware-Level Isolation for future security evolution.
#+end_src
** Probabilistic-Cognitive Analysis
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defun probabilistic-skill-shell-actuator (context)
(let* ((p (getf context :payload))
(cmd (getf p :cmd))
@@ -229,16 +221,14 @@ Hardware-Level Isolation for future security evolution.
** Registration: Actuator
Register the shell channel as a physical actuator.
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(org-agent:register-actuator :shell #'execute-shell-safely)
#+end_src
** Registration: Skill
Define the skill entry for the shell actuator.
#+begin_src lisp :tangle ../src/shell-logic.lisp
(in-package :org-agent)
#+begin_src lisp
(defskill :skill-shell-actuator
:priority 80
:trigger #'trigger-skill-shell-actuator

View File

@@ -90,7 +90,7 @@ Serializes the Merkle history and current pointers to a Lisp file.
(ensure-directories-exist image-file)
(harness-log "PERSISTENCE - Dumping local image to ~a..." (uiop:native-namestring image-file))
(with-open-file (out image-file :direction :output :if-exists :supersede)
(format out "(in-package :org-agent)~%")
(format out "~%")
;; 1. Dump all immutable objects in the history store
(maphash (lambda (hash obj)
(print `(setf (gethash ,hash *history-store*) ,obj) out))

View File

@@ -39,8 +39,7 @@ Define automated behaviors for GTD state consistency and dependency verification
* Implementation
** Semantic Mapping
#+begin_src lisp :tangle ../src/task-integrity.lisp
(in-package :org-agent)
#+begin_src lisp
(defun semantic-mapping (task-state)
"Maps Org-mode task states to semantic categories."
@@ -51,7 +50,7 @@ Define automated behaviors for GTD state consistency and dependency verification
#+end_src
** Active Children Detection
#+begin_src lisp :tangle ../src/task-integrity.lisp
#+begin_src lisp
(defun detect-active-children (task-id)
"Checks if a task has any child tasks in an active state."
(let ((children (list-objects-with-attribute :PARENT task-id)))
@@ -64,7 +63,7 @@ Define automated behaviors for GTD state consistency and dependency verification
** Integrity Check (task-integrity-check)
Enforces high-integrity semantic rules for task management.
#+begin_src lisp :tangle ../src/task-integrity.lisp
#+begin_src lisp
(defun task-integrity-check (action)
"Enforces semantic GTD integrity rules on proposed actions."
(let* ((payload (getf action :payload))
@@ -81,7 +80,7 @@ Enforces high-integrity semantic rules for task management.
#+begin_src
** Skill Definition
#+begin_src lisp :tangle ../src/task-integrity.lisp
#+begin_src lisp
(defskill :skill-task-integrity
:priority 90
:trigger (lambda (ctx) (declare (ignore ctx)) nil)