diff --git a/README.org b/README.org index 7a8c623..6645a38 100644 --- a/README.org +++ b/README.org @@ -26,12 +26,12 @@ There is a beautiful irony to org-agent: Lisp was invented in 1958 specifically Lisp possesses a unique property called *Homoiconicity*: the primary representation of the program is also a data structure (nested lists) within the language itself. Because Lisp code /is/ Lisp data, it is trivially easy for an AI to generate, manipulate, and safely evaluate new tools at runtime. This makes Lisp the ultimate, un-brittle language for a "self-writing" agent. -** 3. The Neuro-Protosymbolic Loop +** 3. The Probabilistic-Protodeterministic Loop org-agent does not let AI models touch your system directly. Instead, it splits cognition into two distinct engines: - *The Probabilistic Engine (The AI Models):* Provides semantic understanding, multimodal translation, and probabilistic creativity. It looks at your Memex and proposes an action by writing a strictly formatted Lisp s-expression. - *The Deterministic Engine (Common Lisp):* Provides deterministic logic, physics, and safety. It intercepts the model's Lisp proposal, formally verifies its structure against your security rules, and only executes it if it is mathematically sound. -Crucially, the Deterministic engine is *continuously progressive*. Right now, it starts by acting as a strict security bouncer—enforcing rules and bounding the AI's actions. But as the system matures, the Deterministic engine will progressively take over more and more of the actual reasoning, reducing the AI models' involvement to a mere semantic translation layer for the messy outside world. We are moving from a /neuro-protosymbolic/ system today, toward a fully autonomous /neurosymbolic/ Lisp machine tomorrow. +Crucially, the Deterministic engine is *continuously progressive*. Right now, it starts by acting as a strict security bouncer—enforcing rules and bounding the AI's actions. But as the system matures, the Deterministic engine will progressively take over more and more of the actual reasoning, reducing the AI models' involvement to a mere semantic translation layer for the messy outside world. We are moving from a /probabilistic-protodeterministic/ system today, toward a fully autonomous /probabilistic-deterministic/ Lisp machine tomorrow. * Architecture: Thin Harness, Fat Skills @@ -62,12 +62,12 @@ When the system boots, it parses these single files, mathematically proves their The agent's "mind" is not a transient chat session; it is a durable, stateful architecture consisting of three layers: 1. *The Linguistic Substrate (Plaintext Files):* The human-readable Source of Truth on your hard drive. You can edit these files in any text editor, and the agent will instantly perceive the changes. 2. *The Lisp Object Store (RAM):* The "Active Brain," a live, threaded graph of Lisp objects representing every headline, paragraph, and tag in your Memex. It allows the agent to navigate your life instantly without constantly re-reading files. -3. *The Telemetry Store (External):* A high-volume database for sub-symbolic sensory data (e.g., smart home logs or system metrics), which the agent monitors and distills. +3. *The Telemetry Store (External):* A high-volume database for sub-deterministic sensory data (e.g., smart home logs or system metrics), which the agent monitors and distills. ** The Psychology: The 2x2 Cognitive Matrix The agent operates on a matrix that balances cognitive speed with cognitive state: -| | Probabilistic (Neural/Intuitive) | Deterministic (Symbolic/Logical) | +| | Probabilistic (Neural/Intuitive) | Deterministic (Deterministic/Logical) | | :--- | :--- | :--- | | Foreground (Active) | *The Interface:* Fast AI models for conversation, multimodal ingestion, and semantic understanding. | *The Steward:* Lisp engine that safely retrieves requested data from the Memex and enforces security rules while the Interface keeps you engaged. | | Background (Passive) | *The Editor:* Deep AI models finding hidden patterns while you sleep. | *The Librarian:* Lisp engine continuously maintaining data integrity and filing away loose notes. | diff --git a/deploy/bare-metal/org-agent.service b/deploy/bare-metal/org-agent.service index 91f404d..085f11e 100644 --- a/deploy/bare-metal/org-agent.service +++ b/deploy/bare-metal/org-agent.service @@ -1,5 +1,5 @@ [Unit] -Description=org-agent: Neurosymbolic Lisp Machine Kernel +Description=org-agent: Probabilistic-Deterministic Lisp Machine Kernel After=network.target [Service] diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile index 37cddae..00d31d7 100644 --- a/deploy/docker/Dockerfile +++ b/deploy/docker/Dockerfile @@ -34,7 +34,7 @@ RUN sbcl --non-interactive \ # Ensure the binary is executable RUN chmod +x /app/org-agent-server -# Expose the Harness Protocol and Web Dashboard ports +# Expose the Harness Communication and Web Dashboard ports EXPOSE 9105 8080 # The app expects the memex to be mounted here diff --git a/docs/quickstart.org b/docs/quickstart.org index 1e61cb1..94b4457 100644 --- a/docs/quickstart.org +++ b/docs/quickstart.org @@ -4,7 +4,7 @@ #+FILETAGS: :quickstart:onboarding:guide: * 1. Introduction -Welcome to ~org-agent~, the "Executive Soul" of your personal OS. This guide will help you set up and interact with your first neurosymbolic agent. +Welcome to ~org-agent~, the "Executive Soul" of your personal OS. This guide will help you set up and interact with your first probabilistic-deterministic agent. * 2. Prerequisites Before launching the harness, ensure your host environment has: @@ -35,7 +35,7 @@ docker-compose up --build -d * 4. Interaction Gateways Once the harness is "Ready", you can interact with it via multiple sensors. -** Gateway A: Emacs (Harness Protocol) +** Gateway A: Emacs (Harness Communication) If you have configured the ~org-agent~ package in Emacs: 1. Open a chat buffer: ~M-x org-agent-chat-open~. 2. Send: "Are you online, agent?" diff --git a/docs/rca/rca-bouncer.org b/docs/rca/rca-bouncer.org index 80e06ac..3039dc6 100644 --- a/docs/rca/rca-bouncer.org +++ b/docs/rca/rca-bouncer.org @@ -11,7 +11,7 @@ Probabilistic Engine proposals involving `shell` or `eval` were executed immedia ** Root Cause Architecture gap. The system lacked an authorization state between "Safe" and "Executed". ** Resolution -1. **Interceptor:** Added `bouncer-check` to `symbolic.lisp`. It flags high-risk actions that lack the `:approved t` property. +1. **Interceptor:** Added `bouncer-check` to `deterministic.lisp`. It flags high-risk actions that lack the `:approved t` property. 2. **Asynchronous Event:** If flagged, the harness emits an `:approval-required` event. 3. **Flight Plan Skill:** Created `org-skill-bouncer.org` to: - Catch the event and create a serialized Org node with state `PLAN`. diff --git a/docs/rca/rca-formal-verification.org b/docs/rca/rca-formal-verification.org index a5a4e29..22e24d6 100644 --- a/docs/rca/rca-formal-verification.org +++ b/docs/rca/rca-formal-verification.org @@ -3,7 +3,7 @@ #+FILETAGS: :rca:security:formal-verification:psf: * Executive Summary -Implemented a Lisp-Native Symbolic Prover to replace heuristic whitelisting with formal security invariants. This ensures that every high-impact action (shell, file I/O) is mathematically proven safe against the Sovereign's core mandates. +Implemented a Lisp-Native Deterministic Prover to replace heuristic whitelisting with formal security invariants. This ensures that every high-impact action (shell, file I/O) is mathematically proven safe against the Sovereign's core mandates. * 1. Architectural Shift: Native vs. External ** Issue @@ -22,7 +22,7 @@ Incorrect assumption about the Quicklisp system name vs. the package name. The l 3. Verified via explicit `ql:quickload` in the test runner. * 3. Formal Invariants Implemented -- **Path Confinement:** Symbolically proves that any file operation or absolute path in a shell command is strictly within the `/home/user/memex` root. +- **Path Confinement:** Deterministically proves that any file operation or absolute path in a shell command is strictly within the `/home/user/memex` root. - **No Network Exfiltration:** Prevents the shell from invoking common exfiltration tools (`nc`, `ssh`, etc.) by inspecting the parsed command structure. * 4. PSF Mandate Alignment diff --git a/docs/rca/rca-gateway-telegram.org b/docs/rca/rca-gateway-telegram.org index 0d6aac9..a61a50d 100644 --- a/docs/rca/rca-gateway-telegram.org +++ b/docs/rca/rca-gateway-telegram.org @@ -11,8 +11,8 @@ During compilation, `gateway-telegram.lisp` failed with `UNDEFINED-FUNCTION` for ** Root Cause Poorly scoped foundational functions. These were defined in `core.lisp` (the loop orchestrator), which was loaded *after* the gateways in `org-agent.asd`. This created a "Circular Intention" where the gateways needed the harness to exist before the harness could load the gateways. ** Resolution -1. **Relocation:** Moved `*actuator-registry*` and `register-actuator` to `protocol.lisp` (the foundation). -2. **Reordering:** Adjusted `org-agent.asd` to load `core.lisp` (containing the stimulus loop) immediately after the symbolic gates but before the physical sensors (gateways). +1. **Relocation:** Moved `*actuator-registry*` and `register-actuator` to `communication.lisp` (the foundation). +2. **Reordering:** Adjusted `org-agent.asd` to load `core.lisp` (containing the stimulus loop) immediately after the deterministic gates but before the physical sensors (gateways). * 2. Issue: Hardcoded Chat UI ** Symptoms diff --git a/docs/rca/rca-lisp-repair-async.org b/docs/rca/rca-lisp-repair-async.org index 4916df1..7a031f8 100644 --- a/docs/rca/rca-lisp-repair-async.org +++ b/docs/rca/rca-lisp-repair-async.org @@ -7,7 +7,7 @@ Reimplemented the `org-skill-lisp-repair` to align with the "Sovereign Boundary" * 1. Issue: Core Bloat & Synchronous Coupling ** Symptoms -The initial implementation of the Lisp Repair gate placed a `handler-case` and a dynamic function call (`repair-lisp-syntax`) directly inside the core `think` function (`neuro.lisp`). This forced the core to wait for repairs and made it "aware" of specific repair logic. +The initial implementation of the Lisp Repair gate placed a `handler-case` and a dynamic function call (`repair-lisp-syntax`) directly inside the core `think` function (`probabilistic.lisp`). This forced the core to wait for repairs and made it "aware" of specific repair logic. ** Root Cause Architectural shortcutting. By placing repair logic in the core execution path, we violated the microkernel principle which mandates that the core should be a "dumb" signal processor. ** Resolution @@ -20,7 +20,7 @@ Architectural shortcutting. By placing repair logic in the core execution path, ** Root Cause Mismatched expectations of signal nesting. The skill expected the code at `(getf context :payload)`, but in the `decide-gate`, `context` is the full signal, and the error details were nested inside the `:candidate` field of that signal. ** Resolution -Updated the symbolic logic to correctly traverse the nested signal structure: `(getf (getf context :candidate) :payload)`. +Updated the deterministic logic to correctly traverse the nested signal structure: `(getf (getf context :candidate) :payload)`. * 3. PSF Mandate Alignment ** Sovereign Boundary @@ -30,4 +30,4 @@ Leveraged the pipeline's ability to re-inject `EVENT` signals to flatten the rec * 4. Permanent Learnings - **Emit, Don't Call:** In a microkernel, if a non-fatal error occurs, always emit a signal rather than calling a recovery function. This allows the system to remain asynchronous and modular. -- **Signal Inspection:** When writing symbolic gates, always verify the exact shape of the `context` signal being passed by the harness to avoid nesting errors. +- **Signal Inspection:** When writing deterministic gates, always verify the exact shape of the `context` signal being passed by the harness to avoid nesting errors. diff --git a/docs/rca/rca-provider-verification.org b/docs/rca/rca-provider-verification.org index 54db889..8e14a34 100644 --- a/docs/rca/rca-provider-verification.org +++ b/docs/rca/rca-provider-verification.org @@ -17,10 +17,10 @@ Implemented a robust `get-nested` helper function that safely traverses both nes ** Symptoms Provider logic was present in the codebase but inaccessible during tests and runtime. ** Root Cause -The `credentials-vault.lisp` and `llm-gateway.lisp` files (consolidated in a previous session) were never added to the `org-agent.asd` system definition. Furthermore, an incorrect loading order caused `UNDEFINED-FUNCTION` errors for `register-neuro-backend`. +The `credentials-vault.lisp` and `llm-gateway.lisp` files (consolidated in a previous session) were never added to the `org-agent.asd` system definition. Furthermore, an incorrect loading order caused `UNDEFINED-FUNCTION` errors for `register-probabilistic-backend`. ** Resolution 1. Added both files to `org-agent.asd`. -2. Enforced strict loading order: `neuro` (defines registry) -> `credentials-vault` -> `llm-gateway` (uses registry). +2. Enforced strict loading order: `probabilistic` (defines registry) -> `credentials-vault` -> `llm-gateway` (uses registry). * 3. Issue: Credential Key Mismatch ** Symptoms diff --git a/docs/rca/rca-self-fix-loop.org b/docs/rca/rca-self-fix-loop.org index a0874c7..10db693 100644 --- a/docs/rca/rca-self-fix-loop.org +++ b/docs/rca/rca-self-fix-loop.org @@ -36,5 +36,5 @@ This eliminates unnecessary nesting levels and drastically reduces the surface a - *Institutional Memory:* This RCA documents the decision to flatten the `.asd` structure to prevent future "Parenthesis Hell" incidents. * 4. Permanent Learnings -- **Flatten Configuration:** Keep `defsystem` definitions as flat as possible. The overhead of `:module` blocks often outweighs their organizational benefit in a neurosymbolic environment where agents frequently edit these files. +- **Flatten Configuration:** Keep `defsystem` definitions as flat as possible. The overhead of `:module` blocks often outweighs their organizational benefit in a probabilistic-deterministic environment where agents frequently edit these files. - **Mocking Probabilistic Engine:** For verifying *loop mechanics*, mocking LLM responses is essential to ensure test determinism, while integration tests can use live LLM calls. diff --git a/docs/rca/rca-task-orchestrator.org b/docs/rca/rca-task-orchestrator.org index ee32817..8754266 100644 --- a/docs/rca/rca-task-orchestrator.org +++ b/docs/rca/rca-task-orchestrator.org @@ -17,7 +17,7 @@ Defined `lisp-validator-validate` as a wrapper around `read-from-string` and `li ** Requirement Multi-backend support to reduce hallucinations and increase reliability. ** Solution -Implemented `bt:make-thread` parallel queries in `ask-neuro`. +Implemented `bt:make-thread` parallel queries in `ask-probabilistic`. ** Trade-off Selected "Majority Rules" over "First-to-Finish". - *Pros:* Higher accuracy, mathematically consistent. @@ -29,7 +29,7 @@ Aligns with PSF Mandate 4 (Radical Transparency) and Invariant 2 (Technical Mast ** Requirement Prevent illegal GTD state transitions. ** Solution -Added `task-integrity-check` in `symbolic.lisp`. +Added `task-integrity-check` in `deterministic.lisp`. ** Invariant Alignment Enforces the "High-Integrity Memory" mandate by ensuring the Org-mode AST remains semantically valid according to GTD rules (e.g., no orphaned active tasks). @@ -40,7 +40,7 @@ Enforces the "High-Integrity Memory" mandate by ensuring the Org-mode AST remain 3. Multi-function edits per block. ** Correction 1. Performed a retrospective commit. -2. Synchronized `neurosymbolic.org` and `core.org` with source code. +2. Synchronized `probabilistic-deterministic.org` and `core.org` with source code. 3. Refactored the Markdown flight plan into an Org-mode flight plan. * 5. Permanent Learnings diff --git a/literate/protocol.org b/literate/communication.org similarity index 83% rename from literate/protocol.org rename to literate/communication.org index ecf9aee..6084c2b 100644 --- a/literate/protocol.org +++ b/literate/communication.org @@ -1,16 +1,18 @@ -#+TITLE: The Harness Protocol (protocol.lisp) +#+TITLE: The Harness Communication (communication.lisp) #+AUTHOR: Amr #+FILETAGS: :harness:protocol: #+STARTUP: content -* The Harness Protocol (protocol.lisp) -** Architectural Intent: Deterministic Framing & Reader Security +* The Harness Communication (communication.lisp) +** Architectural Intent: Secure Inter-Process Communication & Deterministic Framing -The ~org-agent~ harness operates as a perfectly deterministic, highly secure computational engine. When communicating with external actuators—such as an Emacs instance, a web dashboard, or a remote script—the harness cannot rely on unpredictable, "loose" data streams. +Yes, the Harness Communication is fundamentally about **Communication**. It defines the exact physical and semantic boundaries for how the isolated Lisp environment talks to the outside world. + +The ~org-agent~ harness operates as a perfectly deterministic, highly secure computational engine. When communicating with external processes or actuators—such as an Emacs client, a web dashboard, or a remote Shell script—the harness cannot rely on unpredictable, "loose" data streams. Streaming raw Lisp or JSON over a TCP socket is inherently fragile. If a multi-megabyte Org Abstract Syntax Tree (AST) is fragmented by the operating system's network stack during transmission, a standard stream parser might attempt to evaluate an incomplete string, leading to immediate crashes or desynchronization. -To solve this, we implement the **Harness Protocol**, which enforces absolute deterministic boundaries around every message. +To solve this, we implement the **Harness Communication**, which enforces absolute deterministic boundaries around every message. *** 1. Physical Boundary: Hex-Length Prefixing Every message crossing the wire is prefixed with a strict 6-character hexadecimal length string (zero-padded). This creates an unbreakable physical boundary. The harness reads exactly the number of bytes specified by the hex length. It will never under-read (crashing on a partial form) and never over-read (consuming bytes meant for the next message). @@ -19,7 +21,7 @@ Every message crossing the wire is prefixed with a strict 6-character hexadecima The protocol keeps the Lisp harness completely agnostic of its clients. The harness does not care if the client is written in Emacs Lisp, Python, or Rust. Any environment capable of calculating a byte length and opening a TCP socket can interface with the Lisp Machine. *** 3. Preventing Reader Macro Injection -Common Lisp's ~read-from-string~ is extremely powerful but dangerous; it allows "reader macros" (like ~#.~) which execute code during the parsing phase. The Harness Protocol mandates that ~*read-eval*~ is explicitly bound to ~nil~ before any network data is parsed, physically preventing arbitrary code execution. +Common Lisp's ~read-from-string~ is extremely powerful but dangerous; it allows "reader macros" (like ~#.~) which execute code during the parsing phase. The Harness Communication mandates that ~*read-eval*~ is explicitly bound to ~nil~ before any network data is parsed, physically preventing arbitrary code execution. ** Message Framing Logic #+begin_src mermaid @@ -40,14 +42,14 @@ flowchart LR ** Package Context We ensure all protocol logic resides within the isolated harness namespace. -#+begin_src lisp :tangle ../src/protocol.lisp +#+begin_src lisp :tangle ../src/communication.lisp (in-package :org-agent) #+end_src ** Actuator Registry The harness maintains a decoupled registry of target actuators. This allows the system to route messages to Emacs, the Shell, or Web Gateways without hardcoding the routing logic into the protocol itself. -#+begin_src lisp :tangle ../src/protocol.lisp +#+begin_src lisp :tangle ../src/communication.lisp (defvar *actuator-registry* (make-hash-table :test 'equal) "Global registry mapping target keywords to their physical actuator functions.") @@ -59,7 +61,7 @@ The harness maintains a decoupled registry of target actuators. This allows the ** Message Framing (frame-message) The ~frame-message~ function prepares an outgoing Lisp string for transmission. It calculates the byte length, converts it into a 6-character padded hex string, and prefixes it. If ~HARNESS_PROTOCOL_ENFORCE_HMAC~ is enabled in the environment, it also prepends a cryptographic signature to ensure the message hasn't been tampered with. -#+begin_src lisp :tangle ../src/protocol.lisp +#+begin_src lisp :tangle ../src/communication.lisp (defun frame-message (msg-string) "Prefixes MSG-STRING with a 6-character hex length. If security is enabled, prefixes a 64-char HMAC-SHA256 signature." @@ -80,7 +82,7 @@ The ~frame-message~ function prepares an outgoing Lisp string for transmission. ** Message Parsing (parse-message) Parsing is the high-security inverse of framing. This function acts as the final perimeter defense. It validates the length, verifies the HMAC integrity, and—most importantly—jails the Lisp reader by disabling ~*read-eval*~. -#+begin_src lisp :tangle ../src/protocol.lisp +#+begin_src lisp :tangle ../src/communication.lisp (defun parse-message (framed-string) "Extracts and parses the S-expression from a framed string securely." (when (< (length framed-string) 6) @@ -89,7 +91,7 @@ Parsing is the high-security inverse of framing. This function acts as the final (use-hmac (and enforce-hmac (string-equal enforce-hmac "true"))) (prefix-len (if use-hmac 70 6))) (when (< (length framed-string) prefix-len) - (error "Framed string too short for Harness Protocol prefix")) + (error "Framed string too short for Harness Communication prefix")) (let* ((len-str (subseq framed-string 0 6)) (signature (when use-hmac (subseq framed-string 6 70))) @@ -109,7 +111,7 @@ Parsing is the high-security inverse of framing. This function acts as the final (ironclad:update-mac hmac payload-bytes) (let ((expected-signature (ironclad:byte-array-to-hex-string (ironclad:produce-mac hmac)))) (unless (string-equal signature expected-signature) - (error "Harness Protocol Integrity Failure: HMAC mismatch")))))) + (error "Harness Communication Integrity Failure: HMAC mismatch")))))) ;; SECURITY: Disable the reader's ability to execute code during parsing (let ((*read-eval* nil)) @@ -121,7 +123,7 @@ Parsing is the high-security inverse of framing. This function acts as the final ** Handshaking (make-hello-message) Every session begins with a standard ~HELLO~ handshake, allowing the harness to announce its capabilities and protocol version to the connecting client. -#+begin_src lisp :tangle ../src/protocol.lisp +#+begin_src lisp :tangle ../src/communication.lisp (defun make-hello-message (version) "Constructs the standard HELLO handshake message." (list :type :EVENT diff --git a/literate/object-store.org b/literate/object-store.org index 44d7c72..2770b48 100644 --- a/literate/object-store.org +++ b/literate/object-store.org @@ -24,7 +24,7 @@ flowchart TD H -- Pointers --> S2 end subgraph IPCSlow[External Layer] - E[Emacs / Actuators] -. Harness Protocol .-> H + E[Emacs / Actuators] -. Harness Communication .-> H end #+end_src diff --git a/literate/package.org b/literate/package.org index 2cda53e..6622974 100644 --- a/literate/package.org +++ b/literate/package.org @@ -11,7 +11,7 @@ By strictly defining the public interface, we ensure that skills remain decouple #+begin_src mermaid flowchart TD - External[Actuators / Clients] -- Harness Protocol --> Package[Package Membrane: API] + External[Actuators / Clients] -- Harness Communication --> Package[Package Membrane: API] Skills[Dynamic Skills] -- API Calls --> Package Package --> Internal[Harness Internal Modules] style Package fill:#f9f,stroke:#333,stroke-width:4px @@ -22,7 +22,7 @@ flowchart TD (defpackage :org-agent (:use :cl) (:export - ;; --- Harness Protocol --- + ;; --- Harness Communication --- #:frame-message #:parse-message #:make-hello-message @@ -68,7 +68,7 @@ flowchart TD ;; --- Reactive Signal Pipeline --- #:process-signal #:perceive-gate - #:neuro-gate + #:probabilistic-gate #:consensus-gate #:decide-gate #:dispatch-gate @@ -90,8 +90,8 @@ flowchart TD #:skill-priority #:skill-dependencies #:skill-trigger-fn - #:skill-neuro-prompt - #:skill-symbolic-fn + #:skill-probabilistic-prompt + #:skill-deterministic-fn ;; --- Tool Registry --- #:def-cognitive-tool @@ -110,12 +110,12 @@ flowchart TD #:unregister-emacs-client ;; --- Probabilistic Engine --- - #:ask-neuro - #:register-neuro-backend + #:ask-probabilistic + #:register-probabilistic-backend #:distill-prompt #:*provider-cascade* - ;; --- Symbolic Logic --- + ;; --- Deterministic Logic --- #:list-objects-with-attribute #:decide diff --git a/literate/reason.org b/literate/reason.org index 99420cf..9c67cfb 100644 --- a/literate/reason.org +++ b/literate/reason.org @@ -7,7 +7,7 @@ ** Architectural Intent: Unified Cognition The Reason stage is the cognitive engine of the Org-Agent. It unifies two distinct reasoning modes: 1. **Probabilistic Reasoning:** Consulting neural models to generate action proposals based on context. -2. **Deterministic Reasoning:** Running those proposals through symbolic safety gates (Policy and Validation) to ensure alignment. +2. **Deterministic Reasoning:** Running those proposals through deterministic safety gates (Policy and Validation) to ensure alignment. #+begin_src lisp :tangle ../src/reason.lisp (in-package :org-agent) @@ -43,7 +43,7 @@ The Reason stage is the cognitive engine of the Org-Agent. It unifies two distin (tool-belt (generate-tool-belt-prompt)) (global-context (context-assemble-global-awareness))) (if active-skill - (let* ((prompt-generator (skill-neuro-prompt active-skill)) + (let* ((prompt-generator (skill-probabilistic-prompt active-skill)) (raw-prompt (when prompt-generator (funcall prompt-generator context))) (system-prompt (concatenate 'string "IDENTITY: Actuator for org-agent. MANDATE: ONE Lisp plist. " global-context " " tool-belt))) (if (and raw-prompt (> (length raw-prompt) 1)) @@ -57,13 +57,13 @@ The Reason stage is the cognitive engine of the Org-Agent. It unifies two distin ;; --- 2. Deterministic Mechanisms --- (defun deterministic-verify (proposed-action context) - "Iterates through all skill symbolic-gates sorted by priority." + "Iterates through all skill deterministic-gates sorted by priority." (let ((current-action proposed-action) (skills nil)) - (maphash (lambda (name skill) (declare (ignore name)) (when (skill-symbolic-fn skill) (push skill skills))) *skills-registry*) + (maphash (lambda (name skill) (declare (ignore name)) (when (skill-deterministic-fn skill) (push skill skills))) *skills-registry*) (setf skills (sort skills #'> :key #'skill-priority)) (dolist (skill skills) - (let ((gate (skill-symbolic-fn skill))) + (let ((gate (skill-deterministic-fn skill))) (setf current-action (funcall gate current-action context)) (when (and (listp current-action) (member (getf current-action :type) '(:LOG :EVENT))) (harness-log "DETERMINISTIC: Intercepted by skill '~a'" (skill-name skill)) diff --git a/literate/skills.org b/literate/skills.org index 1c1c5dd..a8b4f4f 100644 --- a/literate/skills.org +++ b/literate/skills.org @@ -44,10 +44,10 @@ We begin by ensuring we are in the correct isolated harness namespace. #+end_src ** Skill Metadata (defstruct skill) -The core data structure representing an agent capability. It includes the trigger condition, the neural prompt generator, and the symbolic safety gate. +The core data structure representing an agent capability. It includes the trigger condition, the probabilistic prompt generator, and the deterministic safety gate. #+begin_src lisp :tangle ../src/skills.lisp -(defstruct skill name priority dependencies trigger-fn neuro-prompt symbolic-fn) +(defstruct skill name priority dependencies trigger-fn probabilistic-prompt deterministic-fn) #+end_src ** Skill Catalog Tracking @@ -83,15 +83,15 @@ The primary dispatcher for the Probabilistic Engine. It iterates through the reg The interface used within Org files to register new capabilities. Note that dependencies are explicitly quoted to prevent premature evaluation during the macro expansion phase. #+begin_src lisp :tangle ../src/skills.lisp -(defmacro defskill (name &key priority dependencies trigger neuro symbolic) +(defmacro defskill (name &key priority dependencies trigger probabilistic deterministic) "Registers a new skill into the global registry." `(setf (gethash (string-downcase (string ,name)) *skills-registry*) (make-skill :name (string-downcase (string ,name)) :priority (or ,priority 10) :dependencies ',dependencies :trigger-fn ,trigger - :neuro-prompt ,neuro - :symbolic-fn ,symbolic))) + :probabilistic-prompt ,probabilistic + :deterministic-fn ,deterministic))) #+end_src ** Dependency Resolution (resolve-skill-dependencies) @@ -118,21 +118,19 @@ A robust, low-level scanner that extracts `#+DEPENDS_ON:` and `:ID:` tags from a #+begin_src lisp :tangle ../src/skills.lisp (defun parse-skill-metadata (filepath) - "Extracts ID and DEPENDS_ON tags using robust line-scanning." + "Extracts ID and DEPENDS_ON tags using robust regex scanning." (let ((dependencies nil) - (id nil)) - (with-open-file (stream filepath) - (loop for line = (read-line stream nil :eof) - until (eq line :eof) - do (let ((clean (string-trim '(#\Space #\Tab #\Return #\Newline) line))) - (cond - ((uiop:string-prefix-p "#+DEPENDS_ON:" (string-upcase clean)) - (let* ((deps-part (string-trim " " (subseq clean 13)))) - (setf dependencies (append dependencies - (mapcar (lambda (s) (string-trim "[] " s)) - (uiop:split-string deps-part :separator '(#\Space #\Tab))))))) - ((uiop:string-prefix-p ":ID:" (string-upcase clean)) - (setf id (string-trim '(#\Space #\Tab) (subseq clean 4)))))))) + (id nil) + (content (uiop:read-file-string filepath))) + ;; Extract ID + (multiple-value-bind (match regs) + (ppcre:scan-to-strings "(?im:^:ID:\\s*([^\\s\\r\\n]+))" content) + (when match (setf id (aref regs 0)))) + ;; Extract all DEPENDS_ON lines + (ppcre:do-register-groups (deps-string) + ("(?im:^#\\+DEPENDS_ON:\\s*(.*))" content) + (let ((deps (ppcre:split "\\s+" (string-trim " " deps-string)))) + (setf dependencies (append dependencies (mapcar (lambda (s) (string-trim "[] " s)) deps))))) (values id (remove-if (lambda (s) (= 0 (length s))) dependencies)))) #+end_src @@ -149,6 +147,7 @@ It performs three critical roles: "Returns a list of skill filepaths sorted by dependency (dependencies first)." (let ((files (uiop:directory-files skills-dir "org-skill-*.org")) (adj (make-hash-table :test 'equal)) + (name-to-file (make-hash-table :test 'equal)) (id-to-file (make-hash-table :test 'equal)) (result nil) (visited (make-hash-table :test 'equal)) @@ -156,7 +155,7 @@ It performs three critical roles: (dolist (file files) (let ((filename (pathname-name file))) (multiple-value-bind (id deps) (parse-skill-metadata file) - (setf (gethash (string-downcase filename) id-to-file) file) + (setf (gethash (string-downcase filename) name-to-file) file) (when id (setf (gethash (string-downcase id) id-to-file) file)) (setf (gethash (string-downcase filename) adj) deps)))) (labels ((visit (file) @@ -165,10 +164,12 @@ It performs three critical roles: (unless (gethash node-key visited) (setf (gethash node-key stack) t) (dolist (dep (gethash node-key adj)) - (let* ((dep-id (if (and (> (length dep) 3) (uiop:string-prefix-p "id:" (string-downcase dep))) - (subseq dep 3) - dep)) - (dep-file (gethash (string-downcase dep-id) id-to-file))) + (let* ((is-id-p (uiop:string-prefix-p "id:" (string-downcase dep))) + (dep-key (string-downcase (if is-id-p (subseq dep 3) dep))) + (dep-file (if is-id-p + (gethash dep-key id-to-file) + (or (gethash dep-key id-to-file) + (gethash dep-key name-to-file))))) (when dep-file (let ((dep-filename (pathname-name dep-file))) (if (gethash (string-downcase dep-filename) stack) @@ -179,9 +180,9 @@ It performs three critical roles: (push file result))))) (let ((filenames (sort (mapcar #'pathname-name files) #'string<))) (dolist (name filenames) - (let ((file (gethash (string-downcase name) id-to-file))) + (let ((file (gethash (string-downcase name) name-to-file))) (when file (visit file))))) - result))) + (nreverse result)))) #+end_src ** Syntax Validation (validate-lisp-syntax) diff --git a/literate/system-definition.org b/literate/system-definition.org index 1ed0460..51f409d 100644 --- a/literate/system-definition.org +++ b/literate/system-definition.org @@ -35,24 +35,24 @@ This system defines the core "Thin Harness." It includes the protocol, the objec :author "Amr" :version "0.1.0" :license "MIT" - :description "The Neurosymbolic Lisp Machine Harness" + :description "The Probabilistic-Deterministic Lisp Machine Harness" :depends-on (:usocket :cl-json :bordeaux-threads :dexador :uiop :cl-dotenv :cl-ppcre :hunchentoot :ironclad :str) :serial t :components ((:file "src/package") (:file "src/skills") (:file "src/system-invariants") (:file "src/engineering-standards") - (:file "src/protocol-validator") - (:file "src/protocol") + (:file "src/communication-validator") + (:file "src/communication") (:file "src/object-store") (:file "src/embedding") (:file "src/embedding-logic") (:file "src/context") (:file "src/context-logic") - (:file "src/neuro") + (:file "src/probabilistic") (:file "src/credentials-vault") (:file "src/llm-gateway") - (:file "src/symbolic") + (:file "src/deterministic") (:file "src/lisp-validator") (:file "src/self-fix") (:file "src/lisp-repair") @@ -74,7 +74,7 @@ This system contains the empirical tests required by the Engineering Standards. #+begin_src lisp :tangle ../org-agent.asd (defsystem :org-agent/tests :depends-on (:org-agent :fiveam) - :components ((:file "tests/protocol-tests") + :components ((:file "tests/communication-tests") (:file "tests/pipeline-tests") (:file "tests/peripheral-vision-tests") (:file "tests/lisp-validator-tests") diff --git a/org-agent.asd b/org-agent.asd index aab5d1c..f70e8b8 100644 --- a/org-agent.asd +++ b/org-agent.asd @@ -3,47 +3,41 @@ :author "Amr" :version "0.1.0" :license "MIT" - :description "The Metabolic Neurosymbolic Lisp Machine" + :description "The Probabilistic-Deterministic Lisp Machine Harness" :depends-on (:usocket :cl-json :bordeaux-threads :dexador :uiop :cl-dotenv :cl-ppcre :hunchentoot :ironclad :str) :serial t :components ((:file "src/package") (:file "src/skills") + (:file "src/system-invariants") (:file "src/engineering-standards") - (:file "src/protocol-validator") - (:file "src/protocol") - ;; --- Memory Layer --- + (:file "src/communication-validator") + (:file "src/communication") (:file "src/object-store") - (:file "src/homoiconic-memory") - (:file "src/state-persistence") (:file "src/embedding") (:file "src/embedding-logic") (:file "src/context") (:file "src/context-logic") - ;; --- Metabolic Harness --- - (:file "src/perceive") - (:file "src/reason") - (:file "src/act") - (:file "src/loop") - ;; --- Core Mandatory Skills --- - (:file "src/policy-enforcer") - (:file "src/lisp-validator") - (:file "src/harness-monitor") - (:file "src/llm-gateway") + (:file "src/probabilistic") (:file "src/credentials-vault") - (:file "src/chat-logic") + (:file "src/llm-gateway") + (:file "src/deterministic") + (:file "src/lisp-validator") (:file "src/self-fix") (:file "src/lisp-repair") - ;; --- Gateways --- + (:file "src/bouncer") + (:file "src/verification-logic") + (:file "src/loop") (:file "src/gateway-telegram") (:file "src/gateway-signal") - (:file "src/gateway-matrix")) + (:file "src/gateway-matrix") + (:file "src/playwright")) :build-operation "program-op" :build-pathname "org-agent-server" :entry-point "org-agent:main") (defsystem :org-agent/tests :depends-on (:org-agent :fiveam) - :components ((:file "tests/protocol-tests") + :components ((:file "tests/communication-tests") (:file "tests/pipeline-tests") (:file "tests/peripheral-vision-tests") (:file "tests/lisp-validator-tests") @@ -58,12 +52,14 @@ (:file "tests/llm-gateway-tests") (:file "tests/gateway-telegram-tests") (:file "tests/gateway-signal-tests") - (:file "tests/gateway-matrix-tests")) + (:file "tests/gateway-matrix-tests") + (:file "tests/playwright-tests") + (:file "tests/chaos-qa")) :perform (test-op (o s) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :harness-protocol-suite :org-agent-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :pipeline-suite :org-agent-pipeline-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :vision-suite :org-agent-peripheral-vision-tests)) - (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :lisp-validator-suite :org-agent-lisp-validator-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :safety-suite :org-agent-safety-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :boot-suite :org-agent-boot-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :object-store-suite :org-agent-object-store-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :immune-suite :org-agent-immune-system-tests)) @@ -73,6 +69,9 @@ (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :bouncer-suite :org-agent-bouncer-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :formal-verification-suite :org-agent-formal-verification-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :llm-gateway-suite :org-agent-llm-gateway-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :shell-actuator-suite :org-agent-shell-actuator-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :gateway-telegram-suite :org-agent-gateway-telegram-tests)) (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :gateway-signal-suite :org-agent-gateway-signal-tests)) - (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :gateway-matrix-suite :org-agent-gateway-matrix-tests)))) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :gateway-matrix-suite :org-agent-gateway-matrix-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :playwright-suite :org-agent-playwright-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :chaos-suite :org-agent-chaos-qa)))) diff --git a/skills/org-skill-bouncer.org b/skills/org-skill-bouncer.org index 309b0bc..af4a8ba 100644 --- a/skills/org-skill-bouncer.org +++ b/skills/org-skill-bouncer.org @@ -14,7 +14,7 @@ While the *Formal Prover* ensures an action is "legal" (e.g., "Yes, you are allo 1. **Secret Exposure Gate:** The Bouncer automatically scans all outgoing `:text` payloads for strings matching your API keys or sensitive IDs stored in the `Credentials Vault`. 2. **Network Exfiltration Gate:** It monitors for unauthorized IP addresses or domains in shell commands, preventing the agent from "phoning home" to a malicious server. -3. **The Final Filter:** The Bouncer sits at the very end of the symbolic pipeline. It is the last gate before an action touches the physical hardware. +3. **The Final Filter:** The Bouncer sits at the very end of the deterministic pipeline. It is the last gate before an action touches the physical hardware. * Implementation @@ -130,8 +130,8 @@ The primary entry point for all high-impact actions. :trigger (lambda (ctx) (or (eq (getf (getf ctx :payload) :sensor) :approval-required) (eq (getf (getf ctx :payload) :sensor) :heartbeat))) - :neuro nil - :symbolic (lambda (action context) + :probabilistic nil + :deterministic (lambda (action context) (declare (ignore action)) (let* ((payload (getf context :payload)) (sensor (getf payload :sensor))) diff --git a/skills/org-skill-chat.org b/skills/org-skill-chat.org index 65c69dd..7a2bf6d 100644 --- a/skills/org-skill-chat.org +++ b/skills/org-skill-chat.org @@ -75,7 +75,7 @@ Interfaces for conversational event handling and UI integration. Source of truth t))) #+end_src -** Symbolic Verification +** Deterministic Verification #+begin_src lisp :tangle ../src/chat-logic.lisp (defun verify-skill-chat (proposed-action context) (let* ((payload (getf proposed-action :payload)) @@ -109,7 +109,7 @@ Interfaces for conversational event handling and UI integration. Source of truth 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 -(defun neuro-skill-chat (context) +(defun probabilistic-skill-chat (context) "Generates a conversational response, stripping system errors from context." (let* ((payload (getf context :payload)) (raw-text (getf payload :text)) @@ -126,7 +126,7 @@ The Chat skill acts as the conversational UI. Because the ~org-agent~ kernel eva (:signal (format nil "- To reply via Signal: (:type :REQUEST :target :signal :chat-id \"~a\" :text \"\")" chat-id)) (:matrix (format nil "- To reply via Matrix: (:type :REQUEST :target :matrix :room-id \"~a\" :text \"\")" chat-id)) (t "- To reply via Emacs: (:type :REQUEST :target :emacs :action :insert-at-end :buffer \"*org-agent-chat*\" :text \"* \")")))) - (ask-neuro trimmed-text :system-prompt (concatenate 'string + (ask-probabilistic trimmed-text :system-prompt (concatenate 'string "ACTUATOR IDENTITY: You are the pure Lisp actuator for the org-agent kernel. MANDATE: Output EXACTLY ONE Common Lisp property list starting with (:type :REQUEST). ZERO CONVERSATION: Do not explain. Do not use markdown. @@ -142,6 +142,6 @@ REQUIRED FORMATS: (defskill :skill-chat :priority 100 :trigger #'trigger-skill-chat - :neuro #'neuro-skill-chat - :symbolic #'verify-skill-chat) + :probabilistic #'probabilistic-skill-chat + :deterministic #'verify-skill-chat) #+end_src diff --git a/skills/org-skill-consensus.org b/skills/org-skill-consensus.org index 88ac546..9eb90bd 100644 --- a/skills/org-skill-consensus.org +++ b/skills/org-skill-consensus.org @@ -45,8 +45,8 @@ Enable reliable, cross-instance coordination without a central master. (defskill :skill-consensus :priority 85 :trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :conflict-detected)) - :neuro (lambda (context) "Formulate a consensus proposal for the peer swarm.") - :symbolic (lambda (action context) action)) + :probabilistic (lambda (context) "Formulate a consensus proposal for the peer swarm.") + :deterministic (lambda (action context) action)) #+end_src diff --git a/skills/org-skill-credentials-vault.org b/skills/org-skill-credentials-vault.org index 81b9174..4596257 100644 --- a/skills/org-skill-credentials-vault.org +++ b/skills/org-skill-credentials-vault.org @@ -30,7 +30,7 @@ Securely manage all authentication tokens required for the PSF to operate. :END: ** 1. Architectural Intent -The vault provides a secure lookup table in RAM, backed by the persistent Object Store. Access is restricted to internal kernel requests and explicitly authorized symbolic gates. +The vault provides a secure lookup table in RAM, backed by the persistent Object Store. Access is restricted to internal kernel requests and explicitly authorized deterministic gates. ** 2. Semantic Interfaces #+begin_src lisp @@ -143,8 +143,8 @@ Retained from the legacy Google skill, this provides the instructions for the so (defskill :skill-credentials-vault :priority 200 ; High priority, foundational :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :onboarding-request)) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (vault-onboard-gemini-web) action))) #+end_src diff --git a/skills/org-skill-embedding.org b/skills/org-skill-embedding.org index f9e9c87..010d6ee 100644 --- a/skills/org-skill-embedding.org +++ b/skills/org-skill-embedding.org @@ -33,7 +33,7 @@ Provide a standardized interface for converting text into vector representations :END: ** 1. Architectural Intent -Move heavy neural and mathematical logic out of `core.lisp` and `neuro.lisp` into a dedicated skill. +Move heavy neural and mathematical logic out of `core.lisp` and `probabilistic.lisp` into a dedicated skill. ** 2. Semantic Interfaces @@ -108,8 +108,8 @@ Move heavy neural and mathematical logic out of `core.lisp` and `neuro.lisp` int (defskill :skill-embedding :priority 50 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :embedding-request)) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) (case (getf action :action) (:get-embedding (get-embedding (getf action :text))) diff --git a/skills/org-skill-engineering-standards.org b/skills/org-skill-engineering-standards.org index b2862ec..5b3e9d4 100644 --- a/skills/org-skill-engineering-standards.org +++ b/skills/org-skill-engineering-standards.org @@ -82,8 +82,8 @@ The Engineering Standards skill provides the deterministic enforcement of the wo (org-agent:defskill :skill-engineering-standards :priority 900 ; High priority, runs before most skills :trigger (lambda (ctx) t) ; Always active - :neuro nil - :symbolic #'engineering-standards-gate) + :probabilistic nil + :deterministic #'engineering-standards-gate) #+end_src * See Also diff --git a/skills/org-skill-environment-config.org b/skills/org-skill-environment-config.org index 3b4b39d..62cb3c8 100644 --- a/skills/org-skill-environment-config.org +++ b/skills/org-skill-environment-config.org @@ -64,6 +64,6 @@ Define a standardized `CONFIG` object type in the Object Store. Provide getter/s (defskill :skill-environment-config :priority 100 :trigger (lambda (context) nil) ; Passive utility skill - :neuro (lambda (context) nil) - :symbolic (lambda (action context) action)) + :probabilistic (lambda (context) nil) + :deterministic (lambda (action context) action)) #+end_src diff --git a/skills/org-skill-event-orchestrator.org b/skills/org-skill-event-orchestrator.org index e3dc74b..75c9f4d 100644 --- a/skills/org-skill-event-orchestrator.org +++ b/skills/org-skill-event-orchestrator.org @@ -170,8 +170,8 @@ We register the orchestrator as a core skill and hot-patch the harness's routing (defskill :skill-event-orchestrator :priority 400 ; Foundational control layer :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :heartbeat)) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (orchestrator-process-cron) action))) #+end_src diff --git a/skills/org-skill-formal-verification.org b/skills/org-skill-formal-verification.org index e7557f4..cb423d0 100644 --- a/skills/org-skill-formal-verification.org +++ b/skills/org-skill-formal-verification.org @@ -8,7 +8,7 @@ #+FILETAGS: :security:logic:formal-methods:psf: * Overview -The *Formal Verification Gate* replaces heuristic whitelisting with symbolic logic proofs. It ensures that every action proposed by Probabilistic Engine is *provably safe* against the harness's core security invariants using a Lisp-native symbolic prover. +The *Formal Verification Gate* replaces heuristic whitelisting with deterministic logic proofs. It ensures that every action proposed by Probabilistic Engine is *provably safe* against the harness's core security invariants using a Lisp-native deterministic prover. ** Deep Reasoning: The Sandbox of Intent This gate is the first line of defense against both "Inside Threats" (maliciously modified skill files) and "Hallucination Threats" (LLMs generating unsafe commands). @@ -29,7 +29,7 @@ Define a logic-based verification layer for high-integrity decision making witho ** 2. Success Criteria - [ ] *Invariants:* Express security properties as Lisp predicates. -- [ ] *Soundness:* Block any action that fails a symbolic safety check. +- [ ] *Soundness:* Block any action that fails a deterministic safety check. - [ ] *Path Confinement:* Prove that file operations are confined to the Sovereign's memex. - [ ] *Network Protection:* Prove that shell commands do not attempt unauthorized data exfiltration. @@ -117,7 +117,7 @@ The core prover that applies all relevant invariants to an action. #+begin_src lisp :tangle ../src/verification-logic.lisp (defun verify-action-formally (action context) - "Symbolically proves that ACTION satisfies all applicable security invariants." + "Deterministically proves that ACTION satisfies all applicable security invariants." (let ((action-target (getf action :target)) (action-type (getf action :type)) (all-passed t)) @@ -141,8 +141,8 @@ The core prover that applies all relevant invariants to an action. (defskill :skill-formal-verification :priority 95 ; Just below Bouncer :trigger (lambda (context) (declare (ignore context)) nil) ; Middleware only - :neuro nil - :symbolic (lambda (action context) + :probabilistic nil + :deterministic (lambda (action context) (if (verify-action-formally action context) action (let ((err (format nil "Formal verification failed for action: ~s" action))) diff --git a/skills/org-skill-gateway-matrix.org b/skills/org-skill-gateway-matrix.org index 3f3e895..6afb9e2 100644 --- a/skills/org-skill-gateway-matrix.org +++ b/skills/org-skill-gateway-matrix.org @@ -176,8 +176,8 @@ Define the passive skill entry for the gateway. (defskill :skill-gateway-matrix :priority 150 :trigger (lambda (ctx) (declare (ignore ctx)) nil) - :neuro nil - :symbolic (lambda (action ctx) (declare (ignore ctx)) action)) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) action)) #+end_src ** Initialization diff --git a/skills/org-skill-gateway-signal.org b/skills/org-skill-gateway-signal.org index 55972c3..8cee4dc 100644 --- a/skills/org-skill-gateway-signal.org +++ b/skills/org-skill-gateway-signal.org @@ -146,8 +146,8 @@ Define the passive skill entry for the gateway. (defskill :skill-gateway-signal :priority 150 :trigger (lambda (ctx) (declare (ignore ctx)) nil) ;; Passive - :neuro nil - :symbolic (lambda (action ctx) (declare (ignore ctx)) action)) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) action)) #+end_src ** Initialization diff --git a/skills/org-skill-gateway-telegram.org b/skills/org-skill-gateway-telegram.org index 566921a..287adbf 100644 --- a/skills/org-skill-gateway-telegram.org +++ b/skills/org-skill-gateway-telegram.org @@ -162,8 +162,8 @@ Define the passive skill entry for the gateway. (defskill :skill-gateway-telegram :priority 150 :trigger (lambda (ctx) (declare (ignore ctx)) nil) ;; Passive, handles its own loop - :neuro nil - :symbolic (lambda (action ctx) (declare (ignore ctx)) action)) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) action)) #+end_src ** Initialization diff --git a/skills/org-skill-harness-monitor.org b/skills/org-skill-harness-monitor.org index d80d909..547f17a 100644 --- a/skills/org-skill-harness-monitor.org +++ b/skills/org-skill-harness-monitor.org @@ -47,6 +47,6 @@ The *Harness Monitor* provides tools for inspecting the internal state and healt (defskill :skill-harness-monitor :priority 100 :trigger (lambda (context) t) - :neuro (lambda (context) \"You are the Harness Monitor. Use your tools to provide system visibility.\") - :symbolic (lambda (action context) action)) + :probabilistic (lambda (context) \"You are the Harness Monitor. Use your tools to provide system visibility.\") + :deterministic (lambda (action context) action)) #+end_src diff --git a/skills/org-skill-homoiconic-memory.org b/skills/org-skill-homoiconic-memory.org index 9629769..6378d76 100644 --- a/skills/org-skill-homoiconic-memory.org +++ b/skills/org-skill-homoiconic-memory.org @@ -149,8 +149,8 @@ Converts a structured AST back into Org-mode text. (defskill :skill-homoiconic-memory :priority 300 ; Core foundational skill :trigger (lambda (ctx) (member (getf (getf ctx :payload) :sensor) '(:buffer-save :ingest))) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (let ((ast (getf (getf ctx :payload) :ast))) (when ast (memory-normalize-ast ast)) action)))) diff --git a/skills/org-skill-inbound-gateway.org b/skills/org-skill-inbound-gateway.org index ed898d4..d3420c7 100644 --- a/skills/org-skill-inbound-gateway.org +++ b/skills/org-skill-inbound-gateway.org @@ -8,7 +8,7 @@ #+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. +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 Probabilistic-Deterministic Kernel stimuli. * Phase A: Demand (PRD) :PROPERTIES: @@ -45,7 +45,7 @@ Define a secure and extensible ingress for external communication channels. ** 1. Architectural Intent The Inbound Gateway should operate as a modular, asynchronous service. Each channel (Signal, Telegram, Webhook) will have its own adapter responsible for receiving and normalizing messages. -A central dispatcher will then authenticate and inject these normalized messages as stimuli into the Neurosymbolic Kernel’s message bus. +A central dispatcher will then authenticate and inject these normalized messages as stimuli into the Probabilistic-Deterministic Kernel’s message bus. Error handling and logging will be crucial for observability and maintainability. ** 2. Semantic Interfaces (Lisp Signatures) @@ -75,7 +75,7 @@ Error handling and logging will be crucial for observability and maintainability - *Returns:* Boolean indicating successful authentication (T) or failure (NIL). Consider using ACLs (Access Control Lists). *** `inject-stimulus` - - *Purpose:* Injects a normalized message into the Neurosymbolic Kernel's message bus as a stimulus. + - *Purpose:* Injects a normalized message into the Probabilistic-Deterministic Kernel's message bus as a stimulus. - *Signature:* `(inject-stimulus stimulus-plist)` - *Arguments:* - `stimulus-plist` (plist): The normalized message plist. diff --git a/skills/org-skill-lisp-repair.org b/skills/org-skill-lisp-repair.org index 9324cc6..fe033e5 100644 --- a/skills/org-skill-lisp-repair.org +++ b/skills/org-skill-lisp-repair.org @@ -39,7 +39,7 @@ 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-neuro prompt :system-prompt system-prompt))) + (let ((repaired (ask-probabilistic prompt :system-prompt system-prompt))) (string-trim '(#\Space #\Newline #\Tab) repaired)))) #+end_src @@ -50,8 +50,8 @@ Reacts to syntax error events and transforms them into repaired requests. (defskill :skill-lisp-repair :priority 90 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :syntax-error)) - :neuro nil ;; Handled deterministically in symbolic or manually via ask-neuro - :symbolic (lambda (action context) + :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)) diff --git a/skills/org-skill-lisp-validator.org b/skills/org-skill-lisp-validator.org index 85fae09..341a228 100644 --- a/skills/org-skill-lisp-validator.org +++ b/skills/org-skill-lisp-validator.org @@ -8,7 +8,7 @@ #+FILETAGS: :security:lisp:ast:psf: * Overview -The *Lisp Validator* is the primary structural gate for the Neurosymbolic Lisp Machine. It provides a recursive AST validator that subjects all Lisp proposals from the Probabilistic Engine to a strict "Deny-by-Default" sandbox. +The *Lisp Validator* is the primary structural gate for the Probabilistic-Deterministic Lisp Machine. It provides a recursive AST validator that subjects all Lisp proposals from the Probabilistic Engine to a strict "Deny-by-Default" sandbox. * Phase A: Demand (PRD) :PROPERTIES: @@ -22,7 +22,7 @@ Define a high-integrity, recursive security sandbox for Lisp execution. - *Recursive Validation:* Every nested function call and variable access MUST be checked. - *Deny-by-Default:* Only explicitly whitelisted functions and variables are permitted. - *Eval Protection:* Block all forms of `eval`, `load`, or dynamic execution. -- *Symbolic Preemption:* This skill acts as a mandatory global Deterministic Engine check. +- *Deterministic Preemption:* This skill acts as a mandatory global Deterministic Engine check. ** 3. Success Criteria *** DONE Implement recursive AST walker in Lisp @@ -149,8 +149,8 @@ We allow other skills to register safe symbols for the validator. (when candidate (let ((payload (getf candidate :payload))) (member (getf payload :action) '(:eval :shell)))))) - :neuro nil ; Purely deterministic/safety skill - :symbolic (lambda (action context) + :probabilistic nil ; Purely deterministic/safety skill + :deterministic (lambda (action context) (harness-log "DETERMINISTIC ENGINE [Lisp-Validator]: Intercepted critical action for structural validation.") action)) #+end_src diff --git a/skills/org-skill-llm-gateway.org b/skills/org-skill-llm-gateway.org index ef9fbc0..6ae3258 100644 --- a/skills/org-skill-llm-gateway.org +++ b/skills/org-skill-llm-gateway.org @@ -161,7 +161,7 @@ Register each supported provider with the harness's neural registry. #+begin_src lisp :tangle ../src/llm-gateway.lisp (dolist (p '(:anthropic :gemini-api :gemini-web :groq :ollama :openai :openrouter)) - (org-agent:register-neuro-backend p (lambda (prompt system-prompt &key model) + (org-agent:register-probabilistic-backend p (lambda (prompt system-prompt &key model) (execute-llm-request prompt system-prompt :provider p :model model)))) #+end_src @@ -172,8 +172,8 @@ Define the foundational skill entry for the gateway. (defskill :skill-llm-gateway :priority 150 ; Higher than individual old skills :trigger (lambda (context) (declare (ignore context)) nil) - :neuro (lambda (context) (declare (ignore context)) nil) - :symbolic (lambda (action context) (declare (ignore context)) action)) + :probabilistic (lambda (context) (declare (ignore context)) nil) + :deterministic (lambda (action context) (declare (ignore context)) action)) #+end_src * Phase E: Chaos (Verification) diff --git a/skills/org-skill-onboarding.org b/skills/org-skill-onboarding.org index d3f4b69..381cb64 100644 --- a/skills/org-skill-onboarding.org +++ b/skills/org-skill-onboarding.org @@ -8,7 +8,7 @@ #+FILETAGS: :onboarding:calibration:setup:psf: * Overview -The *Onboarding Skill* ensures that the Lisp Machine environment is correctly calibrated. It automates the "zero-to-one" setup of the Neurosymbolic Kernel, including path normalization, identity personalization, and provider/actuator configuration. +The *Onboarding Skill* ensures that the Lisp Machine environment is correctly calibrated. It automates the "zero-to-one" setup of the Probabilistic-Deterministic Kernel, including path normalization, identity personalization, and provider/actuator configuration. * Phase A: Demand (PRD) :PROPERTIES: diff --git a/skills/org-skill-peripheral-vision.org b/skills/org-skill-peripheral-vision.org index 311426c..571e26a 100644 --- a/skills/org-skill-peripheral-vision.org +++ b/skills/org-skill-peripheral-vision.org @@ -25,7 +25,7 @@ Refine the global awareness provided to the LLM by pruning irrelevant branches o ** 3. Success Criteria - [ ] Correctly calculate semantic relevance using the Embedding skill. - [ ] Recursively render the Org DAG with depth-based and similarity-based pruning. -- [ ] Successfully generate the `GLOBAL MEMEX AWARENESS` block for the neuro-gate. +- [ ] Successfully generate the `GLOBAL MEMEX AWARENESS` block for the probabilistic-gate. * Phase B: Blueprint (PROTOCOL) :PROPERTIES: @@ -118,10 +118,10 @@ Move context pruning and rendering logic out of `context.lisp` to allow for more :priority 90 :dependencies ("org-skill-embedding") :trigger (lambda (ctx) (member (getf (getf ctx :payload) :sensor) '(:perceive :context-refresh))) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore action ctx)) ;; This skill primarily provides the context-assemble-global-awareness function - ;; used by the neuro-gate, rather than handling specific actions. + ;; used by the probabilistic-gate, rather than handling specific actions. nil)) #+end_src diff --git a/skills/org-skill-policy-enforcer.org b/skills/org-skill-policy-enforcer.org index ea16186..5d801d9 100644 --- a/skills/org-skill-policy-enforcer.org +++ b/skills/org-skill-policy-enforcer.org @@ -15,7 +15,7 @@ Unlike traditional software where a "Kernel" might have hardcoded rules, the Org 1. **Topological Bootstrapping:** By declaring a #+DEPENDS_ON: dependency on the Policy file's ID, we ensure the System Policy is always registered in the Lisp image's skill catalog before this enforcer attempts to guard it. 2. **Priority Preemption:** By setting :priority 1000, this skill registers itself as the very first check in the decide-gate. It effectively "pre-empts" all other skills, ensuring that no action (like a shell command or a file write) is even considered until it has cleared the alignment check. -3. **Decoupled Enforcement:** The harness does not "know" it is enforcing a policy. It simply executes the highest-priority symbolic functions provided by its skills. This allows the Sovereign to swap out policies or enforcers without ever touching the core harness code. +3. **Decoupled Enforcement:** The harness does not "know" it is enforcing a policy. It simply executes the highest-priority deterministic functions provided by its skills. This allows the Sovereign to swap out policies or enforcers without ever touching the core harness code. * Implementation @@ -25,9 +25,9 @@ Unlike traditional software where a "Kernel" might have hardcoded rules, the Org (defskill :skill-policy-enforcer :priority 1000 ; Absolute highest priority :trigger (lambda (context) t) ; Always active as a fallback - :neuro (lambda (context) + :probabilistic (lambda (context) \"You are the Org-Agent Policy Enforcer. Your goal is to ensure all actions empower the user through the Lisp Machine and adhere to the System Policy.\") - :symbolic (lambda (action context) + :deterministic (lambda (action context) ;; Basic invariant check: Block actions that appear to violate sovereignty (let ((payload (getf action :payload))) (if (and payload (search \"proprietary\" (format nil \"~s\" payload))) diff --git a/skills/org-skill-policy.org b/skills/org-skill-policy.org index e59757d..a5a3e57 100644 --- a/skills/org-skill-policy.org +++ b/skills/org-skill-policy.org @@ -8,7 +8,11 @@ #+FILETAGS: :platform:policy:alignment: * Overview -The *Org-Agent* is a neurosymbolic harness for a personal operating system. It uses Org-mode as its native memory and Common Lisp as its deterministic reasoning engine. +The *Org-Agent* is a probabilistic-deterministic harness for a personal operating system. It uses Org-mode as its native memory and Common Lisp as its deterministic reasoning engine. + +#+begin_src lisp :tangle ../src/system-invariants.lisp +(in-package :org-agent) +#+end_src This document contains the *Core System Policy*. These are non-negotiable philosophical and technical constraints that every agentic action MUST satisfy. @@ -19,6 +23,14 @@ The Deterministic Engine uses these headlines as a "Moral Compass" during the de ** 1. Sovereignty Above All Every action must increase the user's independence from centralized, proprietary platforms. If a tool or library introduces a dependency on a non-sovereign entity, it must be flagged for replacement. +#+begin_src lisp :tangle ../src/system-invariants.lisp +(defun policy-check-sovereignty (action context) + "Ensures the action does not violate the Sovereignty invariant." + (declare (ignore context)) + ;; Implementation placeholder + action) +#+end_src + ** 2. Technical Mastery & Mentorship The agent's goal is not to "do it for the user," but to "empower the user." Every autonomous action must be explained at a level that increases the user's technical understanding of the Lisp Machine. @@ -33,3 +45,11 @@ Prioritize local, energy-efficient, and offline-first architectures. The "Memex" * Operational Mandates Every action performed by an agent in this environment must also adhere to the [[file:../../org-agent-contrib/org-skill-engineering-standards.org][Engineering Standards]]. + +#+begin_src lisp :tangle ../src/system-invariants.lisp +(defskill :skill-policy + :priority 100 + :trigger (lambda (ctx) t) + :probabilistic nil + :deterministic #'policy-check-sovereignty) +#+end_src diff --git a/skills/org-skill-protocol-validator.org b/skills/org-skill-protocol-validator.org index bef4422..6fb356d 100644 --- a/skills/org-skill-protocol-validator.org +++ b/skills/org-skill-protocol-validator.org @@ -2,12 +2,12 @@ :ID: org-skill-harness-protocol-validator :CREATED: [2026-04-12 Sun 14:35] :END: -#+TITLE: SKILL: Harness Protocol Schema Validator (Universal Literate Note) +#+TITLE: SKILL: Harness Communication Schema Validator (Universal Literate Note) #+STARTUP: content #+FILETAGS: :protocol:harness-protocol:security:validation:psf: * Overview -The *Harness Protocol Schema Validator* skill provides deep structural validation for all messages entering the org-agent kernel. It ensures that every property list adheres to a strict schema, preventing malformed data from causing harness-level errors. +The *Harness Communication Schema Validator* skill provides deep structural validation for all messages entering the org-agent kernel. It ensures that every property list adheres to a strict schema, preventing malformed data from causing harness-level errors. * Phase A: Demand (PRD) :PROPERTIES: @@ -15,7 +15,7 @@ The *Harness Protocol Schema Validator* skill provides deep structural validatio :END: ** 1. Purpose -Enforce a formal grammar for the Org-Agent Control Protocol (Harness Protocol). +Enforce a formal grammar for the Org-Agent Control Protocol (Harness Communication). ** 2. User Needs - *Type Safety:* Ensure mandatory keys (e.g., `:type`, `:payload`) are present. @@ -45,46 +45,46 @@ Decouple protocol parsing (framing/unframing) from semantic validation. * Phase D: Build (Implementation) ** Schema Enforcement -#+begin_src lisp :tangle ../src/protocol-validator.lisp +#+begin_src lisp :tangle ../src/communication-validator.lisp (in-package :org-agent) (defun validate-harness-protocol-schema (msg) - "Strict structural validation for incoming Harness Protocol messages." + "Strict structural validation for incoming Harness Communication messages." (unless (listp msg) - (error "Harness Protocol Schema Error: Message must be a property list (got ~s)" (type-of msg))) + (error "Harness Communication Schema Error: Message must be a property list (got ~s)" (type-of msg))) (let ((type (getf msg :type))) (unless (member type '(:REQUEST :EVENT :RESPONSE :LOG)) - (error "Harness Protocol Schema Error: Invalid message type '~a'" type)) + (error "Harness Communication Schema Error: Invalid message type '~a'" type)) (case type (:REQUEST (unless (getf msg :target) - (error "Harness Protocol Schema Error: REQUEST missing mandatory :target")) + (error "Harness Communication Schema Error: REQUEST missing mandatory :target")) (unless (getf msg :payload) - (error "Harness Protocol Schema Error: REQUEST missing mandatory :payload"))) + (error "Harness Communication Schema Error: REQUEST missing mandatory :payload"))) (:EVENT (let ((payload (getf msg :payload))) (unless (and payload (listp payload)) - (error "Harness Protocol Schema Error: EVENT missing or invalid :payload")) + (error "Harness Communication Schema Error: EVENT missing or invalid :payload")) (unless (or (getf payload :action) (getf payload :sensor)) - (error "Harness Protocol Schema Error: EVENT payload must contain :action or :sensor")))) + (error "Harness Communication Schema Error: EVENT payload must contain :action or :sensor")))) (:RESPONSE (unless (getf msg :payload) - (error "Harness Protocol Schema Error: RESPONSE missing mandatory :payload")))) + (error "Harness Communication Schema Error: RESPONSE missing mandatory :payload")))) t)) #+end_src * Registration -#+begin_src lisp :tangle ../src/protocol-validator.lisp +#+begin_src lisp :tangle ../src/communication-validator.lisp (defskill :skill-harness-protocol-validator :priority 95 :trigger (lambda (ctx) (member (getf (getf ctx :payload) :sensor) '(:protocol-received))) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) (validate-harness-protocol-schema action) action)) diff --git a/skills/org-skill-self-fix.org b/skills/org-skill-self-fix.org index 27ad4b6..2354ebd 100644 --- a/skills/org-skill-self-fix.org +++ b/skills/org-skill-self-fix.org @@ -81,10 +81,10 @@ The *Self-Fix Agent* is the system's "Repair Mechanism." It takes failure hypoth (org-agent:defskill :skill-self-fix :priority 95 :trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :repair-request)) - :neuro (lambda (context) + :probabilistic (lambda (context) (format nil "You are the PSF Repair Actuator. Synthesize a surgical fix for the reported failure. Return a Lisp plist for :repair-file.")) - :symbolic (lambda (action context) + :deterministic (lambda (action context) (let ((payload (getf action :payload))) (self-fix-apply action context)))) #+end_src @@ -95,4 +95,4 @@ Return a Lisp plist for :repair-file.")) :STATUS: SIGNED :END: -** 1. Architectural IntentnEstablish core functional interfaces for this skill.\n\n** 2. Semantic Interfaces\n(defun trigger-skill-org-skill-self-fix (context))\n(defun neuro-skill-org-skill-self-fix (context)) +** 1. Architectural IntentnEstablish core functional interfaces for this skill.\n\n** 2. Semantic Interfaces\n(defun trigger-skill-org-skill-self-fix (context))\n(defun probabilistic-skill-org-skill-self-fix (context)) diff --git a/skills/org-skill-shell-actuator.org b/skills/org-skill-shell-actuator.org index ba07c11..dbfc7af 100644 --- a/skills/org-skill-shell-actuator.org +++ b/skills/org-skill-shell-actuator.org @@ -51,7 +51,7 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu *** DONE Diagnostic Capture - Verified that STDOUT, STDERR, and Exit Codes are correctly captured and re-injected. *** DONE Result Analysis Loop -- The `:neuro` component successfully formats command results for Sovereign review. +- The `:probabilistic` component successfully formats command results for Sovereign review. * Phase B: Blueprint (PROTOCOL) :PROPERTIES: @@ -69,7 +69,7 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu (defun trigger-skill-shell-actuator (context) "Monitors for shell-response events.") -(defun neuro-skill-shell-actuator (context) +(defun probabilistic-skill-shell-actuator (context) "Neural interpretation of command diagnostics.") #+end_src @@ -186,10 +186,10 @@ Hardware-Level Isolation for future security evolution. (eq (getf payload :sensor) :shell-response)))) #+end_src -** Neuro-Cognitive Analysis +** Probabilistic-Cognitive Analysis #+begin_src lisp :tangle ../src/shell-logic.lisp (in-package :org-agent) -(defun neuro-skill-shell-actuator (context) +(defun probabilistic-skill-shell-actuator (context) (let* ((p (getf context :payload)) (cmd (getf p :cmd)) (stdout (getf p :stdout)) @@ -242,6 +242,6 @@ Define the skill entry for the shell actuator. (defskill :skill-shell-actuator :priority 80 :trigger #'trigger-skill-shell-actuator - :neuro #'neuro-skill-shell-actuator - :symbolic (lambda (action context) (declare (ignore context)) action)) + :probabilistic #'probabilistic-skill-shell-actuator + :deterministic (lambda (action context) (declare (ignore context)) action)) #+end_src diff --git a/skills/org-skill-state-persistence.org b/skills/org-skill-state-persistence.org index 0fc8506..95ed7bf 100644 --- a/skills/org-skill-state-persistence.org +++ b/skills/org-skill-state-persistence.org @@ -226,8 +226,8 @@ Expose persistence capabilities to the neural Probabilistic Engine. :trigger (lambda (ctx) (let ((sensor (getf (getf ctx :payload) :sensor))) (member sensor '(:heartbeat :manual-persist)))) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (persistence-dump-local) action)) #+end_src diff --git a/skills/org-skill-task-integrity.org b/skills/org-skill-task-integrity.org index f06dc05..1de4c56 100644 --- a/skills/org-skill-task-integrity.org +++ b/skills/org-skill-task-integrity.org @@ -85,8 +85,8 @@ Enforces high-integrity semantic rules for task management. (defskill :skill-task-integrity :priority 90 :trigger (lambda (ctx) (declare (ignore ctx)) nil) - :neuro nil - :symbolic (lambda (action context) + :probabilistic nil + :deterministic (lambda (action context) (declare (ignore context)) (let ((err (task-integrity-check action))) (if err diff --git a/src/bouncer.lisp b/src/bouncer.lisp index 06ddf71..f15cc9c 100644 --- a/src/bouncer.lisp +++ b/src/bouncer.lisp @@ -88,8 +88,8 @@ :trigger (lambda (ctx) (or (eq (getf (getf ctx :payload) :sensor) :approval-required) (eq (getf (getf ctx :payload) :sensor) :heartbeat))) - :neuro nil - :symbolic (lambda (action context) + :probabilistic nil + :deterministic (lambda (action context) (declare (ignore action)) (let* ((payload (getf context :payload)) (sensor (getf payload :sensor))) diff --git a/src/chat-logic.lisp b/src/chat-logic.lisp index 8a21e39..e00852e 100644 --- a/src/chat-logic.lisp +++ b/src/chat-logic.lisp @@ -49,7 +49,7 @@ (let ((err-text (format nil "\n\n*System Error:* Chat agent returned invalid action: ~s" proposed-action))) `(:type :request :target :emacs :payload (:action :insert-at-end :buffer "*org-agent-chat*" :text ,err-text)))))) -(defun neuro-skill-chat (context) +(defun probabilistic-skill-chat (context) "Generates a conversational response, stripping system errors from context." (let* ((payload (getf context :payload)) (raw-text (getf payload :text)) @@ -66,7 +66,7 @@ (:signal (format nil "- To reply via Signal: (:type :REQUEST :target :signal :chat-id \"~a\" :text \"\")" chat-id)) (:matrix (format nil "- To reply via Matrix: (:type :REQUEST :target :matrix :room-id \"~a\" :text \"\")" chat-id)) (t "- To reply via Emacs: (:type :REQUEST :target :emacs :action :insert-at-end :buffer \"*org-agent-chat*\" :text \"* \")")))) - (ask-neuro trimmed-text :system-prompt (concatenate 'string + (ask-probabilistic trimmed-text :system-prompt (concatenate 'string "ACTUATOR IDENTITY: You are the pure Lisp actuator for the org-agent kernel. MANDATE: Output EXACTLY ONE Common Lisp property list starting with (:type :REQUEST). ZERO CONVERSATION: Do not explain. Do not use markdown. @@ -79,5 +79,5 @@ REQUIRED FORMATS: (defskill :skill-chat :priority 100 :trigger #'trigger-skill-chat - :neuro #'neuro-skill-chat - :symbolic #'verify-skill-chat) + :probabilistic #'probabilistic-skill-chat + :deterministic #'verify-skill-chat) diff --git a/src/protocol.lisp b/src/communication.lisp similarity index 95% rename from src/protocol.lisp rename to src/communication.lisp index 897a3bd..93e31ef 100644 --- a/src/protocol.lisp +++ b/src/communication.lisp @@ -31,7 +31,7 @@ (use-hmac (and enforce-hmac (string-equal enforce-hmac "true"))) (prefix-len (if use-hmac 70 6))) (when (< (length framed-string) prefix-len) - (error "Framed string too short for Harness Protocol prefix")) + (error "Framed string too short for Harness Communication prefix")) (let* ((len-str (subseq framed-string 0 6)) (signature (when use-hmac (subseq framed-string 6 70))) @@ -51,7 +51,7 @@ (ironclad:update-mac hmac payload-bytes) (let ((expected-signature (ironclad:byte-array-to-hex-string (ironclad:produce-mac hmac)))) (unless (string-equal signature expected-signature) - (error "Harness Protocol Integrity Failure: HMAC mismatch")))))) + (error "Harness Communication Integrity Failure: HMAC mismatch")))))) ;; SECURITY: Disable the reader's ability to execute code during parsing (let ((*read-eval* nil)) diff --git a/src/context-logic.lisp b/src/context-logic.lisp index 2febbe7..8d7026b 100644 --- a/src/context-logic.lisp +++ b/src/context-logic.lisp @@ -64,9 +64,9 @@ :priority 90 :dependencies ("org-skill-embedding") :trigger (lambda (ctx) (member (getf (getf ctx :payload) :sensor) '(:perceive :context-refresh))) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore action ctx)) ;; This skill primarily provides the context-assemble-global-awareness function - ;; used by the neuro-gate, rather than handling specific actions. + ;; used by the probabilistic-gate, rather than handling specific actions. nil)) diff --git a/src/credentials-vault.lisp b/src/credentials-vault.lisp index 03b4e3e..b0c120e 100644 --- a/src/credentials-vault.lisp +++ b/src/credentials-vault.lisp @@ -51,7 +51,7 @@ (defskill :skill-credentials-vault :priority 200 ; High priority, foundational :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :onboarding-request)) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (vault-onboard-gemini-web) action))) diff --git a/src/symbolic.lisp b/src/deterministic.lisp similarity index 80% rename from src/symbolic.lisp rename to src/deterministic.lisp index 6cb0bc6..654e4d5 100644 --- a/src/symbolic.lisp +++ b/src/deterministic.lisp @@ -1,22 +1,22 @@ (in-package :org-agent) (defun decide (proposed-action context) - "The Deterministic Safety Gate: iterates through all skill symbolic-gates sorted by priority." + "The Deterministic Safety Gate: iterates through all skill deterministic-gates sorted by priority." (let ((current-action proposed-action) (skills nil)) - ;; 1. Collect all skills with symbolic gates + ;; 1. Collect all skills with deterministic gates (maphash (lambda (name skill) (declare (ignore name)) - (when (skill-symbolic-fn skill) + (when (skill-deterministic-fn skill) (push skill skills))) *skills-registry*) ;; 2. Sort skills by priority (highest first) (setf skills (sort skills #'> :key #'skill-priority)) - ;; 3. Execute symbolic gates sequentially + ;; 3. Execute deterministic gates sequentially (dolist (skill skills) - (let ((gate (skill-symbolic-fn skill))) + (let ((gate (skill-deterministic-fn skill))) (setf current-action (funcall gate current-action context)) ;; If any gate returns a LOG or EVENT (blocking/intercepting), stop and return it. (when (and (listp current-action) diff --git a/src/embedding-logic.lisp b/src/embedding-logic.lisp index bf6ca23..b7bdcde 100644 --- a/src/embedding-logic.lisp +++ b/src/embedding-logic.lisp @@ -51,8 +51,8 @@ (defskill :skill-embedding :priority 50 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :embedding-request)) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) (case (getf action :action) (:get-embedding (get-embedding (getf action :text))) diff --git a/src/engineering-standards.lisp b/src/engineering-standards.lisp index 593aae5..f4da36e 100644 --- a/src/engineering-standards.lisp +++ b/src/engineering-standards.lisp @@ -26,5 +26,5 @@ (org-agent:defskill :skill-engineering-standards :priority 900 ; High priority, runs before most skills :trigger (lambda (ctx) t) ; Always active - :neuro nil - :symbolic #'engineering-standards-gate) + :probabilistic nil + :deterministic #'engineering-standards-gate) diff --git a/src/event-orchestrator.lisp b/src/event-orchestrator.lisp index 8d42451..2fffdfc 100644 --- a/src/event-orchestrator.lisp +++ b/src/event-orchestrator.lisp @@ -66,7 +66,7 @@ (defskill :skill-event-orchestrator :priority 400 ; Foundational control layer :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :heartbeat)) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (orchestrator-process-cron) action))) diff --git a/src/gateway-matrix.lisp b/src/gateway-matrix.lisp index f11b0e1..aec3215 100644 --- a/src/gateway-matrix.lisp +++ b/src/gateway-matrix.lisp @@ -89,7 +89,7 @@ (defskill :skill-gateway-matrix :priority 150 :trigger (lambda (ctx) (declare (ignore ctx)) nil) - :neuro nil - :symbolic (lambda (action ctx) (declare (ignore ctx)) action)) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) action)) (start-matrix-gateway) diff --git a/src/gateway-signal.lisp b/src/gateway-signal.lisp index 6266e35..75a18fa 100644 --- a/src/gateway-signal.lisp +++ b/src/gateway-signal.lisp @@ -65,7 +65,7 @@ (defskill :skill-gateway-signal :priority 150 :trigger (lambda (ctx) (declare (ignore ctx)) nil) ;; Passive - :neuro nil - :symbolic (lambda (action ctx) (declare (ignore ctx)) action)) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) action)) (start-signal-gateway) diff --git a/src/gateway-telegram.lisp b/src/gateway-telegram.lisp index dc7a5ac..e38fb40 100644 --- a/src/gateway-telegram.lisp +++ b/src/gateway-telegram.lisp @@ -75,7 +75,7 @@ (defskill :skill-gateway-telegram :priority 150 :trigger (lambda (ctx) (declare (ignore ctx)) nil) ;; Passive, handles its own loop - :neuro nil - :symbolic (lambda (action ctx) (declare (ignore ctx)) action)) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) action)) (start-telegram-gateway) diff --git a/src/harness-monitor.lisp b/src/harness-monitor.lisp index cd6ddd8..91aa72d 100644 --- a/src/harness-monitor.lisp +++ b/src/harness-monitor.lisp @@ -32,5 +32,5 @@ (defskill :skill-harness-monitor :priority 100 :trigger (lambda (context) t) - :neuro (lambda (context) \"You are the Harness Monitor. Use your tools to provide system visibility.\") - :symbolic (lambda (action context) action)) + :probabilistic (lambda (context) \"You are the Harness Monitor. Use your tools to provide system visibility.\") + :deterministic (lambda (action context) action)) diff --git a/src/homoiconic-memory.lisp b/src/homoiconic-memory.lisp index 78bb9cc..7efc71a 100644 --- a/src/homoiconic-memory.lisp +++ b/src/homoiconic-memory.lisp @@ -53,8 +53,8 @@ (defskill :skill-homoiconic-memory :priority 300 ; Core foundational skill :trigger (lambda (ctx) (member (getf (getf ctx :payload) :sensor) '(:buffer-save :ingest))) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (let ((ast (getf (getf ctx :payload) :ast))) (when ast (memory-normalize-ast ast)) action)))) diff --git a/src/latent-reflection.lisp b/src/latent-reflection.lisp index 2ab4219..1adfc66 100644 --- a/src/latent-reflection.lisp +++ b/src/latent-reflection.lisp @@ -37,7 +37,7 @@ (setf *last-reflection-time* now) t) nil))) - :neuro (lambda (ctx) + :probabilistic (lambda (ctx) (declare (ignore ctx)) (let* ((memories (sample-random-memories 3)) (context-string "LATENT REFLECTION CANDIDATES:\n")) @@ -58,7 +58,7 @@ Find hidden connections, suggest new tags, or propose a new insight that bridges MANDATE: Output EXACTLY ONE Common Lisp property list starting with (:type :REQUEST). Use the :emacs target and :insert-at-end action to write your reflection into the \"*org-agent-chat*\" buffer." context-string))) - :symbolic (lambda (action ctx) + :deterministic (lambda (action ctx) (declare (ignore ctx)) ;; Approve any safe request action)) diff --git a/src/lisp-repair.lisp b/src/lisp-repair.lisp index 29d8e18..16652e2 100644 --- a/src/lisp-repair.lisp +++ b/src/lisp-repair.lisp @@ -24,14 +24,14 @@ 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-neuro prompt :system-prompt system-prompt))) + (let ((repaired (ask-probabilistic prompt :system-prompt system-prompt))) (string-trim '(#\Space #\Newline #\Tab) repaired)))) (defskill :skill-lisp-repair :priority 90 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :syntax-error)) - :neuro nil ;; Handled deterministically in symbolic or manually via ask-neuro - :symbolic (lambda (action context) + :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)) diff --git a/src/lisp-validator.lisp b/src/lisp-validator.lisp index 2e44ded..fdaa164 100644 --- a/src/lisp-validator.lisp +++ b/src/lisp-validator.lisp @@ -96,7 +96,7 @@ (when candidate (let ((payload (getf candidate :payload))) (member (getf payload :action) '(:eval :shell)))))) - :neuro nil ; Purely deterministic/safety skill - :symbolic (lambda (action context) + :probabilistic nil ; Purely deterministic/safety skill + :deterministic (lambda (action context) (harness-log "DETERMINISTIC ENGINE [Lisp-Validator]: Intercepted critical action for structural validation.") action)) diff --git a/src/llm-gateway.lisp b/src/llm-gateway.lisp index 6af4e99..62a8071 100644 --- a/src/llm-gateway.lisp +++ b/src/llm-gateway.lisp @@ -82,11 +82,11 @@ :model (getf args :model)))) (dolist (p '(:anthropic :gemini-api :gemini-web :groq :ollama :openai :openrouter)) - (org-agent:register-neuro-backend p (lambda (prompt system-prompt &key model) + (org-agent:register-probabilistic-backend p (lambda (prompt system-prompt &key model) (execute-llm-request prompt system-prompt :provider p :model model)))) (defskill :skill-llm-gateway :priority 150 ; Higher than individual old skills :trigger (lambda (context) (declare (ignore context)) nil) - :neuro (lambda (context) (declare (ignore context)) nil) - :symbolic (lambda (action context) (declare (ignore context)) action)) + :probabilistic (lambda (context) (declare (ignore context)) nil) + :deterministic (lambda (action context) (declare (ignore context)) action)) diff --git a/src/org-agent.el b/src/org-agent.el index dd66c71..167596e 100644 --- a/src/org-agent.el +++ b/src/org-agent.el @@ -1,4 +1,4 @@ -;;; org-agent.el --- Neurosymbolic Lisp Machine Kernel for Org-mode -*- lexical-binding: t; -*- +;;; org-agent.el --- Probabilistic-Deterministic Lisp Machine Kernel for Org-mode -*- lexical-binding: t; -*- ;; Copyright (C) 2026 Amr ;; @@ -10,9 +10,9 @@ ;;; Commentary: -;; org-agent provides a Neurosymbolic Lisp Machine interface for Emacs. +;; org-agent provides a Probabilistic-Deterministic Lisp Machine interface for Emacs. ;; It acts as the sensor/actuator array, communicating with a persistent -;; Common Lisp daemon over a high-speed Harness Protocol socket. +;; Common Lisp daemon over a high-speed Harness Communication socket. ;;; Code: @@ -100,7 +100,7 @@ will assume you have started it manually (e.g., via SBCL)." (message "org-agent: Killed daemon process."))) (defun org-agent--filter (proc string) - "Handle incoming Harness Protocol messages from the daemon via PROC with STRING." + "Handle incoming Harness Communication messages from the daemon via PROC with STRING." (let ((buf (process-buffer proc))) (when (buffer-live-p buf) (with-current-buffer buf @@ -109,7 +109,7 @@ will assume you have started it manually (e.g., via SBCL)." (org-agent--process-buffer buf proc))))) (defun org-agent--process-buffer (buffer &optional proc) - "Process the Harness Protocol message BUFFER, optionally using PROC." + "Process the Harness Communication message BUFFER, optionally using PROC." (with-current-buffer buffer (goto-char (point-min)) (while (>= (buffer-size) 6) @@ -127,13 +127,13 @@ will assume you have started it manually (e.g., via SBCL)." (setq msg-len 1000000)))))) ; Break loop (defun org-agent--plist-get (plist prop) - "Case-insensitive keyword lookup for Harness Protocol compatibility." + "Case-insensitive keyword lookup for Harness Communication compatibility." (or (plist-get plist prop) (plist-get plist (intern (upcase (symbol-name prop)))) (plist-get plist (intern (downcase (symbol-name prop)))))) (defun org-agent--handle-message (proc plist) - "Route and execute incoming Harness Protocol messages from PROC using PLIST." + "Route and execute incoming Harness Communication messages from PROC using PLIST." (let ((type (org-agent--plist-get plist :type)) (id (org-agent--plist-get plist :id)) (payload (or (org-agent--plist-get plist :payload) plist))) @@ -190,7 +190,7 @@ will assume you have started it manually (e.g., via SBCL)." (message "org-agent: Connection lost."))) (defun org-agent-send (plist) - "Send a Lisp PLIST to the daemon using Harness Protocol framing." + "Send a Lisp PLIST to the daemon using Harness Communication framing." (let* ((msg (prin1-to-string plist)) (len (length msg)) (framed (format "%06x%s" len msg))) @@ -401,7 +401,7 @@ Opens a history buffer and a dedicated input area." ;;;###autoload (define-minor-mode org-agent-mode - "Global minor mode for the org-agent Neurosymbolic kernel. + "Global minor mode for the org-agent Probabilistic-Deterministic kernel. When enabled, this mode starts the Lisp daemon (if configured) and establishes the network connection to enable proactive Org-mode sensing." diff --git a/src/package.lisp b/src/package.lisp index 9ad3062..75a159e 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1,7 +1,7 @@ (defpackage :org-agent (:use :cl) (:export - ;; --- Harness Protocol --- + ;; --- Harness Communication --- #:frame-message #:parse-message #:make-hello-message @@ -47,7 +47,7 @@ ;; --- Reactive Signal Pipeline --- #:process-signal #:perceive-gate - #:neuro-gate + #:probabilistic-gate #:consensus-gate #:decide-gate #:dispatch-gate @@ -69,8 +69,8 @@ #:skill-priority #:skill-dependencies #:skill-trigger-fn - #:skill-neuro-prompt - #:skill-symbolic-fn + #:skill-probabilistic-prompt + #:skill-deterministic-fn ;; --- Tool Registry --- #:def-cognitive-tool @@ -89,12 +89,12 @@ #:unregister-emacs-client ;; --- Probabilistic Engine --- - #:ask-neuro - #:register-neuro-backend + #:ask-probabilistic + #:register-probabilistic-backend #:distill-prompt #:*provider-cascade* - ;; --- Symbolic Logic --- + ;; --- Deterministic Logic --- #:list-objects-with-attribute #:decide diff --git a/src/playwright.lisp b/src/playwright.lisp index a395759..881698e 100644 --- a/src/playwright.lisp +++ b/src/playwright.lisp @@ -34,5 +34,5 @@ (defskill :skill-playwright :priority 150 :trigger (lambda (ctx) (declare (ignore ctx)) nil) ; Passive tool provider - :neuro nil - :symbolic (lambda (action ctx) (declare (ignore ctx)) action)) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) action)) diff --git a/src/policy-enforcer.lisp b/src/policy-enforcer.lisp index 16eb9be..afd5069 100644 --- a/src/policy-enforcer.lisp +++ b/src/policy-enforcer.lisp @@ -3,9 +3,9 @@ (defskill :skill-policy-enforcer :priority 1000 ; Absolute highest priority :trigger (lambda (context) t) ; Always active as a fallback - :neuro (lambda (context) + :probabilistic (lambda (context) \"You are the Org-Agent Policy Enforcer. Your goal is to ensure all actions empower the user through the Lisp Machine and adhere to the System Policy.\") - :symbolic (lambda (action context) + :deterministic (lambda (action context) ;; Basic invariant check: Block actions that appear to violate sovereignty (let ((payload (getf action :payload))) (if (and payload (search \"proprietary\" (format nil \"~s\" payload))) diff --git a/src/neuro.lisp b/src/probabilistic.lisp similarity index 87% rename from src/neuro.lisp rename to src/probabilistic.lisp index 4cb4519..455da42 100644 --- a/src/neuro.lisp +++ b/src/probabilistic.lisp @@ -1,16 +1,16 @@ (in-package :org-agent) -(defvar *neuro-backends* (make-hash-table :test 'equal)) +(defvar *probabilistic-backends* (make-hash-table :test 'equal)) (defvar *provider-cascade* nil) -(defun register-neuro-backend (name fn) (setf (gethash name *neuro-backends*) fn)) +(defun register-probabilistic-backend (name fn) (setf (gethash name *probabilistic-backends*) fn)) (defvar *model-selector-fn* nil "A function called with (provider context) to return a model ID.") -(defvar *consensus-enabled-p* nil "If T, ask-neuro queries all backends in parallel.") +(defvar *consensus-enabled-p* nil "If T, ask-probabilistic queries all backends in parallel.") -(defun ask-neuro (prompt &key (system-prompt "You are the Probabilistic engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil)) +(defun ask-probabilistic (prompt &key (system-prompt "You are the Probabilistic engine of a Probabilistic-Deterministic 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) @@ -22,7 +22,7 @@ (threads nil) (lock (bt:make-lock))) (dolist (backend backends) - (let ((backend-fn (gethash backend *neuro-backends*))) + (let ((backend-fn (gethash backend *probabilistic-backends*))) (when backend-fn (push (bt:make-thread (lambda () @@ -48,7 +48,7 @@ ;; SEQUENTIAL CASCADE MODE (or (dolist (backend backends) - (let ((backend-fn (gethash backend *neuro-backends*))) + (let ((backend-fn (gethash backend *probabilistic-backends*))) (when backend-fn (harness-log "PROBABILISTIC: Attempting backend ~a..." backend) (let* ((model (when *model-selector-fn* (funcall *model-selector-fn* backend context))) @@ -68,7 +68,7 @@ (if active-skill (progn (harness-log "PROBABILISTIC: Engaging skill '~a'~%" (skill-name active-skill)) - (let* ((prompt-generator (skill-neuro-prompt active-skill)) + (let* ((prompt-generator (skill-probabilistic-prompt active-skill)) (raw-prompt (when prompt-generator (funcall prompt-generator context))) (full-system-prompt (concatenate 'string "ACTUATOR IDENTITY: You are the pure Lisp actuator for the org-agent kernel. @@ -91,7 +91,7 @@ To call a tool, you MUST use: "))) (if (and raw-prompt (> (length raw-prompt) 1)) - (let* ((thought (ask-neuro raw-prompt :system-prompt full-system-prompt :context context)) + (let* ((thought (ask-probabilistic raw-prompt :system-prompt full-system-prompt :context context)) (raw-thoughts (cl-ppcre:split (cl-ppcre:quote-meta-chars "|CONSENSUS-SEP|") thought)) (suggestions nil)) (dolist (raw-thought raw-thoughts) @@ -120,4 +120,4 @@ To call a tool, you MUST use: (defun distill-prompt (full-prompt successful-output) (let ((system-instr "You are a Meta-Cognitive Prompt Architect. DISTILL into template.")) - (ask-neuro (format nil "PROMPT: ~a~%RESULT: ~a" full-prompt successful-output) :system-prompt system-instr))) + (ask-probabilistic (format nil "PROMPT: ~a~%RESULT: ~a" full-prompt successful-output) :system-prompt system-instr))) diff --git a/src/processor-logic.lisp b/src/processor-logic.lisp index f3f004c..8dc1c9e 100644 --- a/src/processor-logic.lisp +++ b/src/processor-logic.lisp @@ -6,12 +6,12 @@ (member "!archive" tags :test #'string-equal)) (in-package :org-agent) -(defun neuro-skill-inbox-processor (context) +(defun probabilistic-skill-inbox-processor (context) (let* ((payload (getf context :payload)) (content (getf payload :content)) (tags (getf payload :tags)) (is-archive (inbox-is-archive-p tags))) - (ask-neuro content :system-prompt + (ask-probabilistic content :system-prompt (format nil "You are the PSF Librarian. Your goal is to ENRICH this Org-mode capture. RULES: 1. Create a '** Summary' sub-heading with a 1-sentence summary. diff --git a/src/protocol-validator.lisp b/src/protocol-validator.lisp index f6cd765..0b64ef3 100644 --- a/src/protocol-validator.lisp +++ b/src/protocol-validator.lisp @@ -1,39 +1,39 @@ (in-package :org-agent) (defun validate-harness-protocol-schema (msg) - "Strict structural validation for incoming Harness Protocol messages." + "Strict structural validation for incoming Harness Communication messages." (unless (listp msg) - (error "Harness Protocol Schema Error: Message must be a property list (got ~s)" (type-of msg))) + (error "Harness Communication Schema Error: Message must be a property list (got ~s)" (type-of msg))) (let ((type (getf msg :type))) (unless (member type '(:REQUEST :EVENT :RESPONSE :LOG)) - (error "Harness Protocol Schema Error: Invalid message type '~a'" type)) + (error "Harness Communication Schema Error: Invalid message type '~a'" type)) (case type (:REQUEST (unless (getf msg :target) - (error "Harness Protocol Schema Error: REQUEST missing mandatory :target")) + (error "Harness Communication Schema Error: REQUEST missing mandatory :target")) (unless (getf msg :payload) - (error "Harness Protocol Schema Error: REQUEST missing mandatory :payload"))) + (error "Harness Communication Schema Error: REQUEST missing mandatory :payload"))) (:EVENT (let ((payload (getf msg :payload))) (unless (and payload (listp payload)) - (error "Harness Protocol Schema Error: EVENT missing or invalid :payload")) + (error "Harness Communication Schema Error: EVENT missing or invalid :payload")) (unless (or (getf payload :action) (getf payload :sensor)) - (error "Harness Protocol Schema Error: EVENT payload must contain :action or :sensor")))) + (error "Harness Communication Schema Error: EVENT payload must contain :action or :sensor")))) (:RESPONSE (unless (getf msg :payload) - (error "Harness Protocol Schema Error: RESPONSE missing mandatory :payload")))) + (error "Harness Communication Schema Error: RESPONSE missing mandatory :payload")))) t)) (defskill :skill-harness-protocol-validator :priority 95 :trigger (lambda (ctx) (member (getf (getf ctx :payload) :sensor) '(:protocol-received))) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (declare (ignore ctx)) (validate-harness-protocol-schema action) action)) diff --git a/src/reason.lisp b/src/reason.lisp index 76dc241..901eaf5 100644 --- a/src/reason.lisp +++ b/src/reason.lisp @@ -31,7 +31,7 @@ (tool-belt (generate-tool-belt-prompt)) (global-context (context-assemble-global-awareness))) (if active-skill - (let* ((prompt-generator (skill-neuro-prompt active-skill)) + (let* ((prompt-generator (skill-probabilistic-prompt active-skill)) (raw-prompt (when prompt-generator (funcall prompt-generator context))) (system-prompt (concatenate 'string "IDENTITY: Actuator for org-agent. MANDATE: ONE Lisp plist. " global-context " " tool-belt))) (if (and raw-prompt (> (length raw-prompt) 1)) @@ -45,13 +45,13 @@ ;; --- 2. Deterministic Mechanisms --- (defun deterministic-verify (proposed-action context) - "Iterates through all skill symbolic-gates sorted by priority." + "Iterates through all skill deterministic-gates sorted by priority." (let ((current-action proposed-action) (skills nil)) - (maphash (lambda (name skill) (declare (ignore name)) (when (skill-symbolic-fn skill) (push skill skills))) *skills-registry*) + (maphash (lambda (name skill) (declare (ignore name)) (when (skill-deterministic-fn skill) (push skill skills))) *skills-registry*) (setf skills (sort skills #'> :key #'skill-priority)) (dolist (skill skills) - (let ((gate (skill-symbolic-fn skill))) + (let ((gate (skill-deterministic-fn skill))) (setf current-action (funcall gate current-action context)) (when (and (listp current-action) (member (getf current-action :type) '(:LOG :EVENT))) (harness-log "DETERMINISTIC: Intercepted by skill '~a'" (skill-name skill)) diff --git a/src/shell-logic.lisp b/src/shell-logic.lisp index feb92a1..e265163 100644 --- a/src/shell-logic.lisp +++ b/src/shell-logic.lisp @@ -83,5 +83,5 @@ (defskill :skill-shell-actuator :priority 80 :trigger #'trigger-skill-shell-actuator - :neuro #'neuro-skill-shell-actuator - :symbolic (lambda (action context) (declare (ignore context)) action)) + :probabilistic #'probabilistic-skill-shell-actuator + :deterministic (lambda (action context) (declare (ignore context)) action)) diff --git a/src/skills.lisp b/src/skills.lisp index ed9d5a9..002c5fb 100644 --- a/src/skills.lisp +++ b/src/skills.lisp @@ -1,6 +1,6 @@ (in-package :org-agent) -(defstruct skill name priority dependencies trigger-fn neuro-prompt symbolic-fn) +(defstruct skill name priority dependencies trigger-fn probabilistic-prompt deterministic-fn) (defvar *skill-catalog* (make-hash-table :test 'equal) "A stateful tracking table for all skill files discovered in the environment.") @@ -21,15 +21,15 @@ *skills-registry*) (first (sort triggered #'> :key #'skill-priority)))) -(defmacro defskill (name &key priority dependencies trigger neuro symbolic) +(defmacro defskill (name &key priority dependencies trigger probabilistic deterministic) "Registers a new skill into the global registry." `(setf (gethash (string-downcase (string ,name)) *skills-registry*) (make-skill :name (string-downcase (string ,name)) :priority (or ,priority 10) :dependencies ',dependencies :trigger-fn ,trigger - :neuro-prompt ,neuro - :symbolic-fn ,symbolic))) + :probabilistic-prompt ,probabilistic + :deterministic-fn ,deterministic))) (defun resolve-skill-dependencies (skill-name) "Recursively resolves dependencies for a given skill name." @@ -46,27 +46,26 @@ (nreverse resolved)))) (defun parse-skill-metadata (filepath) - "Extracts ID and DEPENDS_ON tags using robust line-scanning." + "Extracts ID and DEPENDS_ON tags using robust regex scanning." (let ((dependencies nil) - (id nil)) - (with-open-file (stream filepath) - (loop for line = (read-line stream nil :eof) - until (eq line :eof) - do (let ((clean (string-trim '(#\Space #\Tab #\Return #\Newline) line))) - (cond - ((uiop:string-prefix-p "#+DEPENDS_ON:" (string-upcase clean)) - (let* ((deps-part (string-trim " " (subseq clean 13)))) - (setf dependencies (append dependencies - (mapcar (lambda (s) (string-trim "[] " s)) - (uiop:split-string deps-part :separator '(#\Space #\Tab))))))) - ((uiop:string-prefix-p ":ID:" (string-upcase clean)) - (setf id (string-trim '(#\Space #\Tab) (subseq clean 4)))))))) + (id nil) + (content (uiop:read-file-string filepath))) + ;; Extract ID + (multiple-value-bind (match regs) + (ppcre:scan-to-strings "(?im:^:ID:\\s*([^\\s\\r\\n]+))" content) + (when match (setf id (aref regs 0)))) + ;; Extract all DEPENDS_ON lines + (ppcre:do-register-groups (deps-string) + ("(?im:^#\\+DEPENDS_ON:\\s*(.*))" content) + (let ((deps (ppcre:split "\\s+" (string-trim " " deps-string)))) + (setf dependencies (append dependencies (mapcar (lambda (s) (string-trim "[] " s)) deps))))) (values id (remove-if (lambda (s) (= 0 (length s))) dependencies)))) (defun topological-sort-skills (skills-dir) "Returns a list of skill filepaths sorted by dependency (dependencies first)." (let ((files (uiop:directory-files skills-dir "org-skill-*.org")) (adj (make-hash-table :test 'equal)) + (name-to-file (make-hash-table :test 'equal)) (id-to-file (make-hash-table :test 'equal)) (result nil) (visited (make-hash-table :test 'equal)) @@ -74,7 +73,7 @@ (dolist (file files) (let ((filename (pathname-name file))) (multiple-value-bind (id deps) (parse-skill-metadata file) - (setf (gethash (string-downcase filename) id-to-file) file) + (setf (gethash (string-downcase filename) name-to-file) file) (when id (setf (gethash (string-downcase id) id-to-file) file)) (setf (gethash (string-downcase filename) adj) deps)))) (labels ((visit (file) @@ -83,10 +82,12 @@ (unless (gethash node-key visited) (setf (gethash node-key stack) t) (dolist (dep (gethash node-key adj)) - (let* ((dep-id (if (and (> (length dep) 3) (uiop:string-prefix-p "id:" (string-downcase dep))) - (subseq dep 3) - dep)) - (dep-file (gethash (string-downcase dep-id) id-to-file))) + (let* ((is-id-p (uiop:string-prefix-p "id:" (string-downcase dep))) + (dep-key (string-downcase (if is-id-p (subseq dep 3) dep))) + (dep-file (if is-id-p + (gethash dep-key id-to-file) + (or (gethash dep-key id-to-file) + (gethash dep-key name-to-file))))) (when dep-file (let ((dep-filename (pathname-name dep-file))) (if (gethash (string-downcase dep-filename) stack) @@ -97,9 +98,9 @@ (push file result))))) (let ((filenames (sort (mapcar #'pathname-name files) #'string<))) (dolist (name filenames) - (let ((file (gethash (string-downcase name) id-to-file))) + (let ((file (gethash (string-downcase name) name-to-file))) (when file (visit file))))) - result))) + (nreverse result)))) (defun validate-lisp-syntax (code-string) "Checks if a string contains valid, readable Common Lisp forms." @@ -197,8 +198,8 @@ (let ((sorted-files (topological-sort-skills skills-dir))) ;; MANDATE: The System Policy must be present for a safe boot - (unless (member "org-skill-system-invariants" sorted-files :key #'pathname-name :test #'string-equal) - (error "BOOT FAILURE: org-skill-system-invariants.org not found in skills directory.")) + (unless (member "org-skill-policy" sorted-files :key #'pathname-name :test #'string-equal) + (error "BOOT FAILURE: org-skill-policy.org not found in skills directory.")) (harness-log "==================================================") (harness-log " LOADER: Initializing ~a skills..." (length sorted-files)) diff --git a/src/state-persistence.lisp b/src/state-persistence.lisp index e7e07ef..5e9a20f 100644 --- a/src/state-persistence.lisp +++ b/src/state-persistence.lisp @@ -119,7 +119,7 @@ :trigger (lambda (ctx) (let ((sensor (getf (getf ctx :payload) :sensor))) (member sensor '(:heartbeat :manual-persist)))) - :neuro nil - :symbolic (lambda (action ctx) + :probabilistic nil + :deterministic (lambda (action ctx) (persistence-dump-local) action)) diff --git a/src/system-invariants.lisp b/src/system-invariants.lisp new file mode 100644 index 0000000..8c4affc --- /dev/null +++ b/src/system-invariants.lisp @@ -0,0 +1,13 @@ +(in-package :org-agent) + +(defun policy-check-sovereignty (action context) + "Ensures the action does not violate the Sovereignty invariant." + (declare (ignore context)) + ;; Implementation placeholder + action) + +(defskill :skill-policy + :priority 100 + :trigger (lambda (ctx) t) + :probabilistic nil + :deterministic #'policy-check-sovereignty) diff --git a/src/verification-logic.lisp b/src/verification-logic.lisp index 25c87e0..cc99677 100644 --- a/src/verification-logic.lisp +++ b/src/verification-logic.lisp @@ -43,7 +43,7 @@ t))) (defun verify-action-formally (action context) - "Symbolically proves that ACTION satisfies all applicable security invariants." + "Deterministically proves that ACTION satisfies all applicable security invariants." (let ((action-target (getf action :target)) (action-type (getf action :type)) (all-passed t)) @@ -64,8 +64,8 @@ (defskill :skill-formal-verification :priority 95 ; Just below Bouncer :trigger (lambda (context) (declare (ignore context)) nil) ; Middleware only - :neuro nil - :symbolic (lambda (action context) + :probabilistic nil + :deterministic (lambda (action context) (if (verify-action-formally action context) action (let ((err (format nil "Formal verification failed for action: ~s" action))) diff --git a/tests/chaos-qa.lisp b/tests/chaos-qa.lisp index fd2aac4..deb6de4 100644 --- a/tests/chaos-qa.lisp +++ b/tests/chaos-qa.lisp @@ -25,8 +25,8 @@ (org-agent::defskill :infinite-skill :priority 100 :trigger (lambda (ctx) t) - :neuro (lambda (ctx) nil) - :symbolic (lambda (action ctx) + :probabilistic (lambda (ctx) nil) + :deterministic (lambda (action ctx) `(:type :EVENT :payload (:sensor :infinite-trigger)))) ;; The pipeline has (when (> depth 10) ...) check. diff --git a/tests/protocol-tests.lisp b/tests/communication-tests.lisp similarity index 98% rename from tests/protocol-tests.lisp rename to tests/communication-tests.lisp index b10fc92..0148548 100644 --- a/tests/protocol-tests.lisp +++ b/tests/communication-tests.lisp @@ -3,7 +3,7 @@ (in-package :org-agent-tests) (def-suite harness-protocol-suite - :description "Test suite for org-agent Communication Protocol (Harness Protocol)") + :description "Test suite for org-agent Communication Protocol (Harness Communication)") (in-suite harness-protocol-suite) (test test-framing diff --git a/tests/formal-verification-tests.lisp b/tests/formal-verification-tests.lisp index 256524b..47c1de7 100644 --- a/tests/formal-verification-tests.lisp +++ b/tests/formal-verification-tests.lisp @@ -35,12 +35,12 @@ )) (test test-formal-gate-middleware - "Verify that the skill correctly filters actions via its symbolic function." + "Verify that the skill correctly filters actions via its deterministic function." (let ((action '(:type :REQUEST :target :shell :payload (:cmd "nc -l 1234"))) (context '(:payload (:sensor :test)))) ;; The skill should return a :log error action instead of the original request (let* ((skill (gethash "skill-formal-verification" org-agent::*skills-registry*)) - (result (funcall (org-agent::skill-symbolic-fn skill) action context))) + (result (funcall (org-agent::skill-deterministic-fn skill) action context))) (is (not (eq result action))) (is (eq :log (getf result :type))) (is (search "Formal verification failed" (getf (getf result :payload) :text)))))) diff --git a/tests/immune-system-tests.lisp b/tests/immune-system-tests.lisp index 7785153..002dcc1 100644 --- a/tests/immune-system-tests.lisp +++ b/tests/immune-system-tests.lisp @@ -21,8 +21,8 @@ (skill (org-agent::make-skill :name "crasher" :priority 100 :trigger-fn (lambda (ctx) t) - :neuro-prompt (lambda (ctx) nil) - :symbolic-fn (lambda (action ctx) + :probabilistic-prompt (lambda (ctx) nil) + :deterministic-fn (lambda (action ctx) '(:type :REQUEST :target :tool :payload (:action :call :tool "crashing-tool")))))) (clrhash org-agent::*skills-registry*) @@ -43,8 +43,8 @@ (org-agent::defskill :evil-skill :priority 100 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :test)) - :neuro (lambda (ctx) (error "CRITICAL BRAIN FAILURE")) - :symbolic nil) + :probabilistic (lambda (ctx) (error "CRITICAL BRAIN FAILURE")) + :deterministic nil) (harness-log "CLEAN LOG") (org-agent:process-signal '(:type :EVENT :payload (:sensor :test))) diff --git a/tests/neuro-test.lisp b/tests/neuro-test.lisp index 27fb822..300cc76 100644 --- a/tests/neuro-test.lisp +++ b/tests/neuro-test.lisp @@ -5,9 +5,9 @@ (defpackage :org-agent (:use :cl)) (in-package :org-agent) -;; We need to load the core and neuro files to test them. +;; We need to load the core and probabilistic files to test them. (load "projects/org-agent/src/core.lisp") -(load "projects/org-agent/src/neuro.lisp") +(load "projects/org-agent/src/probabilistic.lisp") ;; Simple testing framework (defvar *tests-run* 0) @@ -33,15 +33,15 @@ (format t "PASS: ~a~%" (or ,message "Assertion passed"))) (format t "FAIL: ~a~% Condition evaluated to NIL~%" (or ,message "Assertion failed")))))) -(format t "--- Running Neuro Microkernel Tests ---~%") +(format t "--- Running Probabilistic Microkernel Tests ---~%") ;; Test 1: Graceful failure on empty registry -(clrhash org-agent::*neuro-backends*) +(clrhash org-agent::*probabilistic-backends*) (setf org-agent::*provider-cascade* '(:nonexistent)) -(let ((result (org-agent:ask-neuro "Test prompt"))) +(let ((result (org-agent:ask-probabilistic "Test prompt"))) (assert-true (and (stringp result) (search ":LOG" result) (search "Neural Cascade Failure" result)) - "ask-neuro should return a Neural Cascade Failure log when no backends are available.")) + "ask-probabilistic should return a Neural Cascade Failure log when no backends are available.")) ;; Test 2: Successful delegation to a mock provider (defvar *mock-called* nil) @@ -50,7 +50,7 @@ (setf *mock-called* t) (format nil "MOCK-RESPONSE: ~a" prompt)) -(org-agent:register-neuro-backend :mock #'mock-provider-fn) +(org-agent:register-probabilistic-backend :mock #'mock-provider-fn) ;; Temporarily mock the token accountant's model selector so it doesn't fail (defun mock-model-selector (provider context) @@ -60,18 +60,18 @@ ;; Test with our mock provider (setf org-agent::*provider-cascade* '(:mock)) -(let ((result (org-agent:ask-neuro "Hello Mock"))) - (assert-equal "MOCK-RESPONSE: Hello Mock" result "ask-neuro should return the exact string from the registered provider") - (assert-true *mock-called* "The mock provider function must be called by ask-neuro")) +(let ((result (org-agent:ask-probabilistic "Hello Mock"))) + (assert-equal "MOCK-RESPONSE: Hello Mock" result "ask-probabilistic should return the exact string from the registered provider") + (assert-true *mock-called* "The mock provider function must be called by ask-probabilistic")) ;; Test 3: The core should NOT contain execute-openrouter-request, execute-groq-request, or execute-gemini-request ;; This is the architectural test. These functions should be UNBOUND or not exist in the org-agent package. (assert-true (not (fboundp 'org-agent::execute-openrouter-request)) - "execute-openrouter-request should be removed from the core neuro.lisp") + "execute-openrouter-request should be removed from the core probabilistic.lisp") (assert-true (not (fboundp 'org-agent::execute-groq-request)) - "execute-groq-request should be removed from the core neuro.lisp") + "execute-groq-request should be removed from the core probabilistic.lisp") (assert-true (not (fboundp 'org-agent::execute-gemini-request)) - "execute-gemini-request should be removed from the core neuro.lisp") + "execute-gemini-request should be removed from the core probabilistic.lisp") (format t "--- Test Summary ---~%") (format t "Tests Run: ~a~%" *tests-run*) diff --git a/tests/org-agent-test.el b/tests/org-agent-test.el index 22bb148..ab426e8 100644 --- a/tests/org-agent-test.el +++ b/tests/org-agent-test.el @@ -15,7 +15,7 @@ (should (string= "000014(:type :EVENT :id 1)" captured-framed))))) (ert-deftest test-org-agent-parsing () - "Verify that the filter correctly parses Harness Protocol framed messages." + "Verify that the filter correctly parses Harness Communication framed messages." (let ((mock-buffer (generate-new-buffer " *org-agent-test*")) (received-plist nil)) (cl-letf (((symbol-function 'org-agent--handle-message) diff --git a/tests/pipeline-tests.lisp b/tests/pipeline-tests.lisp index 3e806ea..0b64d00 100644 --- a/tests/pipeline-tests.lisp +++ b/tests/pipeline-tests.lisp @@ -12,8 +12,8 @@ (org-agent::defskill :mock-refactor :priority 100 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :command) :organize-subtree)) - :neuro (lambda (ctx) "Mock neuro prompt") - :symbolic (lambda (action ctx) + :probabilistic (lambda (ctx) "Mock probabilistic prompt") + :deterministic (lambda (action ctx) `(:type :REQUEST :id 123 :payload (:action :refactor-subtree :target-id nil @@ -21,8 +21,8 @@ (org-agent::defskill :mock-safety :priority 50 :trigger (lambda (ctx) t) ; always triggers - :neuro (lambda (ctx) "Mock neuro") - :symbolic (lambda (action ctx) nil))) ; rejects everything + :probabilistic (lambda (ctx) "Mock probabilistic") + :deterministic (lambda (action ctx) nil))) ; rejects everything (test test-perceive-gate "Perceive gate should update the object store and normalize signal." @@ -76,8 +76,8 @@ :priority 10 :dependencies (list "mock-safety") :trigger (lambda (ctx) nil) - :neuro nil - :symbolic nil) + :probabilistic nil + :deterministic nil) (let ((deps (org-agent::resolve-skill-dependencies "mock-dependent"))) (is (member "mock-safety" deps :test #'string-equal)) (is (member "mock-dependent" deps :test #'string-equal)))) @@ -107,8 +107,8 @@ (org-agent::defskill :crashing-skill :priority 200 :trigger (lambda (ctx) t) - :neuro (lambda (ctx) (list :type :REQUEST :payload (list :action :eval :code "(error \"BOOM\")"))) - :symbolic (lambda (action ctx) (error "CRASH IN DETERMINISTIC ENGINE"))) + :probabilistic (lambda (ctx) (list :type :REQUEST :payload (list :action :eval :code "(error \"BOOM\")"))) + :deterministic (lambda (action ctx) (error "CRASH IN DETERMINISTIC ENGINE"))) (process-signal (list :type :EVENT :payload (list :sensor :test))) ;; Verify that we are still in State A (let ((obj (lookup-object "node-1"))) diff --git a/tests/self-fix-tests.lisp b/tests/self-fix-tests.lisp index e8a8420..cebf6e4 100644 --- a/tests/self-fix-tests.lisp +++ b/tests/self-fix-tests.lisp @@ -20,8 +20,8 @@ (org-agent:defskill :skill-broken-math :priority 50 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :broken-trigger)) - :neuro nil - :symbolic (lambda (action context) + :probabilistic nil + :deterministic (lambda (action context) (declare (ignore action context)) (+ 1 \"two\"))) ; DETERMINISTIC BUG #+end_src