diff --git a/.dockerignore b/.dockerignore index a9e5378..eb73930 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ -org-agent-server +opencortex-server .git .env tests/ diff --git a/.env.example b/.env.example index 6b8a609..1270a80 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -# org-agent: Neural Engine Configuration +# opencortex: Neural Engine Configuration # Core LLM Providers GEMINI_API_KEY="your_gemini_key_here" ANTHROPIC_API_KEY="your_anthropic_key_here" diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index f391761..81132ac 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -22,23 +22,23 @@ jobs: echo "Piping local compose file to host Docker daemon..." # We read the compose file from the checked-out code in the runner, - # but we tell the host Docker daemon that the "project directory" is /memex/projects/org-agent. + # but we tell the host Docker daemon that the "project directory" is /memex/projects/opencortex. # The host daemon will use its own /memex files to build the image. cat deploy/docker/docker-compose.yml | docker-compose \ - -p org-agent \ - --project-directory /memex/projects/org-agent \ + -p opencortex \ + --project-directory /memex/projects/opencortex \ -f - \ down cat deploy/docker/docker-compose.yml | docker-compose \ - -p org-agent \ - --project-directory /memex/projects/org-agent \ + -p opencortex \ + --project-directory /memex/projects/opencortex \ -f - \ - build --no-cache org-agent + build --no-cache opencortex cat deploy/docker/docker-compose.yml | docker-compose \ - -p org-agent \ - --project-directory /memex/projects/org-agent \ + -p opencortex \ + --project-directory /memex/projects/opencortex \ -f - \ - up -d --force-recreate org-agent + up -d --force-recreate opencortex diff --git a/.gitignore b/.gitignore index da39115..c7e006f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .env -org-agent-server +opencortex-server \$MEMEX_DIR/ *.log *~ diff --git a/CHANGELOG.org b/CHANGELOG.org index b4f0c42..a1fbcfe 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -2,7 +2,7 @@ #+STARTUP: content * v0.1.0 - The Autonomous Foundation (2026-04-13) -This is the initial MVP release of the ~org-agent~. It establishes a secure, auditable Lisp kernel for a personal operating system. +This is the initial MVP release of the ~opencortex~. It establishes a secure, auditable Lisp kernel for a personal operating system. ** Features - **Metabolic Pipeline:** Robust Perceive-Reason-Act loop with selective memory rollbacks and graceful shutdown handling. @@ -10,7 +10,7 @@ This is the initial MVP release of the ~org-agent~. It establishes a secure, aud - **Foveal-Peripheral Context:** High-resolution focus on active tasks with low-resolution skeletal awareness of the rest of the Memex. - **The Bouncer:** Last-mile deterministic security gate with Deep Packet Inspection for secrets and network exfiltration. - **Autonomous Scribe:** Background distillation worker that turns daily journal entries into evergreen Zettelkasten notes. -- **Unified Onboarding:** Single-command installation (~org-agent.sh~) with Docker-first deployment and OS detection. +- **Unified Onboarding:** Single-command installation (~opencortex.sh~) with Docker-first deployment and OS detection. - **CLI Gateway:** Local TCP socket server and interactive chat client for frictionless first contact. ** Architectural Shift diff --git a/Dockerfile b/Dockerfile index 933f510..5216c5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# ORG-AGENT v1.0 Production Environment +# OPENCORTEX v1.0 Production Environment FROM debian:bookworm-slim # Prevent interactive prompts during build @@ -49,12 +49,12 @@ RUN echo '(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-ho # 6. Setup Application Directory WORKDIR /app -COPY . /app/projects/org-agent +COPY . /app/projects/opencortex # 7. Pre-cache Lisp Dependencies RUN sbcl --non-interactive \ - --eval '(push #p"/app/projects/org-agent/" asdf:*central-registry*)' \ - --eval '(ql:quickload :org-agent)' + --eval '(push #p"/app/projects/opencortex/" asdf:*central-registry*)' \ + --eval '(ql:quickload :opencortex)' # 8. Environment & Volumes # The host's memex root should be mounted to /memex @@ -66,6 +66,6 @@ EXPOSE 9105 8080 # Entrypoint CMD ["sbcl", "--non-interactive", \ - "--eval", "(push #p\"/app/projects/org-agent/\" asdf:*central-registry*)", \ - "--eval", "(ql:quickload :org-agent)", \ - "--eval", "(org-agent:main)"] + "--eval", "(push #p\"/app/projects/opencortex/\" asdf:*central-registry*)", \ + "--eval", "(ql:quickload :opencortex)", \ + "--eval", "(opencortex:main)"] diff --git a/README.org b/README.org index 2e6b87b..371d740 100644 --- a/README.org +++ b/README.org @@ -1,6 +1,6 @@ #+TITLE: OpenCortex: The Conductor of your Life Stack -*org-agent* is a minimalist, extensible AI agent framework designed to manage and continuously organize your personal knowledge base. It transforms a static collection of plaintext notes into a live, programmable [[https://en.wikipedia.org/wiki/Memex][Memex]]—an automated, personalized memory system where humans and AI collaborate in the exact same workspace. +*opencortex* is a minimalist, extensible AI agent framework designed to manage and continuously organize your personal knowledge base. It transforms a static collection of plaintext notes into a live, programmable [[https://en.wikipedia.org/wiki/Memex][Memex]]—an automated, personalized memory system where humans and AI collaborate in the exact same workspace. * The Problem with Current AI Agents @@ -12,22 +12,22 @@ The current ecosystem of AI agents (typically built in Python or TypeScript) is * The Vision: A Modern, Homoiconic Memex -org-agent abandons these fragile paradigms by returning to first principles and embracing two historically powerful technologies: *Org-mode* and *Common Lisp*. +opencortex abandons these fragile paradigms by returning to first principles and embracing two historically powerful technologies: *Org-mode* and *Common Lisp*. ** 1. Org-mode: The Universal Language -Instead of wrestling with Markdown parsers or hiding data in opaque databases, org-agent mandates that *Org-mode is the native AST for both humans and machines.* +Instead of wrestling with Markdown parsers or hiding data in opaque databases, opencortex mandates that *Org-mode is the native AST for both humans and machines.* Org-mode is unique because it seamlessly brings together human-readable prose, structured metadata (properties and tags), lifecycle states (TODO/DONE), and executable code blocks into a single plain-text file. The code is the data, and the data is the interface. When the agent "remembers" a fact or schedules a task, it writes an Org headline. You read exactly what the agent reads. -*The Token Advantage:* Because Org-mode is a strict outline, org-agent never needs to send an entire document to an AI model. It uses *Sparse Trees* to send a high-level table of contents, zooming in only on the specific headline relevant to the task. This drastically reduces token consumption and eliminates context window overflow. +*The Token Advantage:* Because Org-mode is a strict outline, opencortex never needs to send an entire document to an AI model. It uses *Sparse Trees* to send a high-level table of contents, zooming in only on the specific headline relevant to the task. This drastically reduces token consumption and eliminates context window overflow. ** 2. Common Lisp: The Engine of Self-Modification -There is a beautiful irony to org-agent: Lisp was invented in 1958 specifically to achieve Artificial Intelligence, and it has been waiting nearly 70 years for /this exact moment/ in computing history. +There is a beautiful irony to opencortex: Lisp was invented in 1958 specifically to achieve Artificial Intelligence, and it has been waiting nearly 70 years for /this exact moment/ in computing history. 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 Probabilistic-Protodeterministic Loop -org-agent does not let AI models touch your system directly. Instead, it splits cognition into two distinct engines: +opencortex 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. @@ -35,12 +35,12 @@ Crucially, the Deterministic engine is *continuously progressive*. Right now, it * Architecture: Thin Harness, Fat Skills -To guarantee long-term stability, org-agent enforces a strict architectural boundary inspired by the "thin harness, fat skills" philosophy. +To guarantee long-term stability, opencortex enforces a strict architectural boundary inspired by the "thin harness, fat skills" philosophy. ** The Minimalist Harness The Lisp microkernel does almost no actual "work." It is a thin, unbreakable harness strictly responsible for three things: 1. *The Memory:* Maintaining the live graph of your Memex in RAM. -2. *The Communication Protocol:* Managing the secure bridge between the agent and the outside world. While power users can connect natively via Emacs or Vim, the vast majority of users will interact with org-agent exclusively through chat clients (like Telegram, Signal, or Matrix), web dashboards, or a Terminal UI (TUI). The harness doesn't care; it just securely routes the messages. +2. *The Communication Protocol:* Managing the secure bridge between the agent and the outside world. While power users can connect natively via Emacs or Vim, the vast majority of users will interact with opencortex exclusively through chat clients (like Telegram, Signal, or Matrix), web dashboards, or a Terminal UI (TUI). The harness doesn't care; it just securely routes the messages. 3. *The Cognitive Loop:* Moving signals through the Perceive -> Probabilistic -> Deterministic -> Dispatch pipeline. Everything else—AI routing, vector embeddings, shell execution, or web browsing—is pushed entirely out of the harness and into *Fat Skills*. @@ -48,7 +48,7 @@ Everything else—AI routing, vector embeddings, shell execution, or web browsin ** Literate, Single-File Skills In standard agent frameworks, adding a new capability (like "Search the Web") requires creating a sprawling folder with a Python script, a JSON configuration file, and a separate text file for the AI prompt. This creates massive structural bloat. -In org-agent, a Skill is simply a *single .org file*. +In opencortex, a Skill is simply a *single .org file*. Using *Literate Programming*, this single file contains everything: - The human-readable documentation and architectural intent. @@ -81,7 +81,7 @@ The agent operates on a matrix that balances cognitive speed with cognitive stat * The Ecosystem: Core Skill Groups -Because the harness is deliberately thin, every capability of org-agent is implemented as a single-file Literate Skill. This allows you to hot-reload, modify, or completely remove features on the fly without restarting the core environment. +Because the harness is deliberately thin, every capability of opencortex is implemented as a single-file Literate Skill. This allows you to hot-reload, modify, or completely remove features on the fly without restarting the core environment. The ecosystem is divided into five primary skill groups: @@ -109,13 +109,13 @@ The agent meets you where you are. While it natively integrates with text editor * Quick Start (The Zero-to-One Experience) -org-agent can be installed and booted with a single command. The unified entrypoint script will detect your OS, offer to install Docker if missing, interactively gather your API keys, and launch the autonomous kernel in the background. +opencortex can be installed and booted with a single command. The unified entrypoint script will detect your OS, offer to install Docker if missing, interactively gather your API keys, and launch the autonomous kernel in the background. #+begin_src bash -curl -fsSL https://raw.githubusercontent.com/gharbeia/org-agent/main/org-agent.sh | bash +curl -fsSL https://raw.githubusercontent.com/gharbeia/opencortex/main/opencortex.sh | bash #+end_src -After installation, simply type `org-agent` in your terminal to start chatting with your autonomous brain. +After installation, simply type `opencortex` in your terminal to start chatting with your autonomous brain. For power users who wish to run the agent natively (Baremetal), please refer to the [[file:literate/setup.org][setup.org]] literate documentation. @@ -125,7 +125,7 @@ For power users who wish to run the agent natively (Baremetal), please refer to The initial MVP that establishes a secure, auditable Lisp kernel for a personal operating system. It features a robust metabolic pipeline, mandatory skill enforcement, and background distillation. ** v1.0.0 (Phase 2.5): The Verified Wrapper (Current Target) -At this stage, org-agent achieves feature parity with State-of-the-Art autonomous agents (like Devin or SWE-agent) but with Lisp-grade mathematical security. +At this stage, opencortex achieves feature parity with State-of-the-Art autonomous agents (like Devin or SWE-agent) but with Lisp-grade mathematical security. - *The Tools are External:* The agent uses a standard bash shell, a headless browser (via Playwright), and standard file I/O. - *The Safety is Internal:* The Bouncer and Formal Verification gates mathematically prove actions are safe before piping them to external tools. - *The Result:* An autonomous agent capable of end-to-end software engineering, web research, and system administration, running securely and locally. diff --git a/deploy/bare-metal/install.sh b/deploy/bare-metal/install.sh index 1ec0a0c..1825bed 100644 --- a/deploy/bare-metal/install.sh +++ b/deploy/bare-metal/install.sh @@ -1,10 +1,10 @@ #!/bin/bash -# org-agent: Bare Metal Installation Script -# This script sets up the org-agent daemon on a Linux host (Debian/Fedora). +# opencortex: Bare Metal Installation Script +# This script sets up the opencortex daemon on a Linux host (Debian/Fedora). set -e -echo "--- org-agent: Bare Metal Installation ---" +echo "--- opencortex: Bare Metal Installation ---" # 1. Check Dependencies echo "[1/4] Checking dependencies..." @@ -31,16 +31,16 @@ echo "[3/4] Building standalone binary..." PROJECT_ROOT=$(pwd)/../.. sbcl --non-interactive \ --eval "(push \"$PROJECT_ROOT/\" asdf:*central-registry*)" \ - --eval "(ql:quickload :org-agent)" \ - --eval "(asdf:make :org-agent)" + --eval "(ql:quickload :opencortex)" \ + --eval "(asdf:make :opencortex)" -echo "Binary built: $PROJECT_ROOT/org-agent-server" +echo "Binary built: $PROJECT_ROOT/opencortex-server" # 4. Instructions for Systemd echo "[4/4] Installation complete." echo "" echo "To run as a systemd service:" -echo "1. Edit org-agent.service to set correct paths." -echo "2. sudo cp org-agent.service /etc/systemd/system/" +echo "1. Edit opencortex.service to set correct paths." +echo "2. sudo cp opencortex.service /etc/systemd/system/" echo "3. sudo systemctl daemon-reload" -echo "4. sudo systemctl enable --now org-agent" +echo "4. sudo systemctl enable --now opencortex" diff --git a/deploy/bare-metal/org-agent.service b/deploy/bare-metal/org-agent.service index 085f11e..bf75c18 100644 --- a/deploy/bare-metal/org-agent.service +++ b/deploy/bare-metal/org-agent.service @@ -1,18 +1,18 @@ [Unit] -Description=org-agent: Probabilistic-Deterministic Lisp Machine Kernel +Description=opencortex: Probabilistic-Deterministic Lisp Machine Kernel After=network.target [Service] Type=simple # Update User and WorkingDirectory to match your local setup User=amr -WorkingDirectory=/home/amr/.openclaw/workspace/memex/5_projects/org-agent -ExecStart=/home/amr/.openclaw/workspace/memex/5_projects/org-agent/org-agent-server +WorkingDirectory=/home/amr/.openclaw/workspace/memex/5_projects/opencortex +ExecStart=/home/amr/.openclaw/workspace/memex/5_projects/opencortex/opencortex-server Restart=always RestartSec=10 # Environment variables can be loaded from the .env file -EnvironmentFile=/home/amr/.openclaw/workspace/memex/5_projects/org-agent/.env +EnvironmentFile=/home/amr/.openclaw/workspace/memex/5_projects/opencortex/.env [Install] WantedBy=multi-user.target diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile index 832677d..6e35d6b 100644 --- a/deploy/docker/Dockerfile +++ b/deploy/docker/Dockerfile @@ -18,21 +18,21 @@ RUN curl -O https://beta.quicklisp.org/quicklisp.lisp && \ WORKDIR /app # Copy source code and system definition -COPY org-agent.asd /app/ +COPY opencortex.asd /app/ COPY src/ /app/src/ # Ensure we aren't using a stale binary from the host -RUN rm -f /app/org-agent-server +RUN rm -f /app/opencortex-server # Build the standalone binary natively inside the container # This ensures GLIBC compatibility with the runtime environment. RUN sbcl --non-interactive \ --eval '(push "/app/" asdf:*central-registry*)' \ - --eval '(ql:quickload :org-agent)' \ - --eval '(asdf:make :org-agent)' + --eval '(ql:quickload :opencortex)' \ + --eval '(asdf:make :opencortex)' # Ensure the binary is executable -RUN chmod +x /app/org-agent-server +RUN chmod +x /app/opencortex-server # Expose the communication protocol and Web Dashboard ports EXPOSE 9105 8080 @@ -41,4 +41,4 @@ EXPOSE 9105 8080 VOLUME /memex # Run the natively compiled standalone daemon -CMD ["./org-agent-server"] +CMD ["./opencortex-server"] diff --git a/deploy/docker/docker-compose.yml b/deploy/docker/docker-compose.yml index 8fc4609..9211e04 100644 --- a/deploy/docker/docker-compose.yml +++ b/deploy/docker/docker-compose.yml @@ -1,11 +1,11 @@ version: '3.8' services: - org-agent: + opencortex: build: context: ../.. dockerfile: deploy/docker/Dockerfile - container_name: org-agent + container_name: opencortex restart: unless-stopped ports: - "${ORG_AGENT_DAEMON_PORT:-9105}:${ORG_AGENT_DAEMON_PORT:-9105}" diff --git a/deploy/guix/manifest.scm b/deploy/guix/manifest.scm index bf5dfb1..a4e8528 100644 --- a/deploy/guix/manifest.scm +++ b/deploy/guix/manifest.scm @@ -1,4 +1,4 @@ -;; org-agent: Guix Environment Manifest +;; opencortex: Guix Environment Manifest ;; Usage: guix shell -m manifest.scm -- sbcl --eval ... (specifications->manifest diff --git a/deploy/lxc/setup.org b/deploy/lxc/setup.org index 8f51b8f..e4b4a1e 100644 --- a/deploy/lxc/setup.org +++ b/deploy/lxc/setup.org @@ -1,19 +1,19 @@ #+TITLE: LXC / Systemd-nspawn Deployment Guide -#+AUTHOR: org-agent +#+AUTHOR: opencortex * Overview -For users who prefer containerization without the overhead or dependency on the Docker daemon, `org-agent` can be run within a standard Linux Container (LXC) or a systemd-nspawn container. +For users who prefer containerization without the overhead or dependency on the Docker daemon, `opencortex` can be run within a standard Linux Container (LXC) or a systemd-nspawn container. * Systemd-nspawn Setup (Fastest for Linux users) 1. **Create the container root:** #+begin_src bash - sudo debootstrap --arch=amd64 bookworm /var/lib/machines/org-agent + sudo debootstrap --arch=amd64 bookworm /var/lib/machines/opencortex #+end_src 2. **Start and enter the container:** #+begin_src bash - sudo systemd-nspawn -D /var/lib/machines/org-agent + sudo systemd-nspawn -D /var/lib/machines/opencortex #+end_src 3. **Install dependencies (inside container):** @@ -24,7 +24,7 @@ For users who prefer containerization without the overhead or dependency on the 4. **Bind mount the Memex directory:** Add this to your container startup or use the `--bind` flag: #+begin_src bash - sudo systemd-nspawn -D /var/lib/machines/org-agent --bind /home/amr/.openclaw/workspace/memex + sudo systemd-nspawn -D /var/lib/machines/opencortex --bind /home/amr/.openclaw/workspace/memex #+end_src * Proxmox LXC Setup diff --git a/deploy/vms/debian/Vagrantfile b/deploy/vms/debian/Vagrantfile index c72f9f2..102d3e4 100644 --- a/deploy/vms/debian/Vagrantfile +++ b/deploy/vms/debian/Vagrantfile @@ -11,12 +11,12 @@ Vagrant.configure("2") do |config| apt-get update apt-get install -y sbcl curl git ripgrep libsqlite3-dev build-essential - # Setup for org-agent - mkdir -p /home/vagrant/org-agent - cp -r /vagrant/* /home/vagrant/org-agent/ - chown -R vagrant:vagrant /home/vagrant/org-agent + # Setup for opencortex + mkdir -p /home/vagrant/opencortex + cp -r /vagrant/* /home/vagrant/opencortex/ + chown -R vagrant:vagrant /home/vagrant/opencortex # Build binary natively - sudo -u vagrant bash -c "cd /home/vagrant/org-agent && ./deploy/bare-metal/install.sh" + sudo -u vagrant bash -c "cd /home/vagrant/opencortex && ./deploy/bare-metal/install.sh" SHELL end diff --git a/deploy/vms/fedora/Vagrantfile b/deploy/vms/fedora/Vagrantfile index 5df95fb..f0f5a70 100644 --- a/deploy/vms/fedora/Vagrantfile +++ b/deploy/vms/fedora/Vagrantfile @@ -10,12 +10,12 @@ Vagrant.configure("2") do |config| config.vm.provision "shell", inline: <<-SHELL dnf install -y sbcl curl git ripgrep sqlite-devel make gcc - # Setup for org-agent - mkdir -p /home/vagrant/org-agent - cp -r /vagrant/* /home/vagrant/org-agent/ - chown -R vagrant:vagrant /home/vagrant/org-agent + # Setup for opencortex + mkdir -p /home/vagrant/opencortex + cp -r /vagrant/* /home/vagrant/opencortex/ + chown -R vagrant:vagrant /home/vagrant/opencortex # Build binary natively - sudo -u vagrant bash -c "cd /home/vagrant/org-agent && ./deploy/bare-metal/install.sh" + sudo -u vagrant bash -c "cd /home/vagrant/opencortex && ./deploy/bare-metal/install.sh" SHELL end diff --git a/docker-compose.yml b/docker-compose.yml index 8ffb6db..f52d92a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,12 @@ services: - org-agent: + opencortex: build: context: . dockerfile: Dockerfile - container_name: org-agent + container_name: opencortex env_file: .env volumes: - # Mount the entire memex directory (2 levels up from projects/org-agent) + # Mount the entire memex directory (2 levels up from projects/opencortex) - ../..:/memex # Ensure signal-cli state is preserved - signal-state:/root/.local/share/signal-cli diff --git a/docs/deployment.org b/docs/deployment.org index e3d284c..f2a3119 100644 --- a/docs/deployment.org +++ b/docs/deployment.org @@ -1,19 +1,19 @@ -#+TITLE: Deployment Guide: Containerized Org-Agent +#+TITLE: Deployment Guide: Containerized OpenCortex #+AUTHOR: Amr #+DATE: [2026-04-11 Sat] #+FILETAGS: :deployment:docker:infrastructure: * Overview -The ~org-agent~ is designed to run within a Docker container to ensure system dependencies (SBCL, Quicklisp, signal-cli) are perfectly matched across different host environments. +The ~opencortex~ is designed to run within a Docker container to ensure system dependencies (SBCL, Quicklisp, signal-cli) are perfectly matched across different host environments. * Prerequisites - Docker Engine - Docker Compose -- A valid ~.env~ file in the ~projects/org-agent/~ directory (refer to ~.env.example~). +- A valid ~.env~ file in the ~projects/opencortex/~ directory (refer to ~.env.example~). * Quick Start ** 1. Build and Start -From the ~projects/org-agent/~ directory: +From the ~projects/opencortex/~ directory: #+begin_src bash docker-compose up --build -d #+end_src diff --git a/docs/marketing-v0.1.0.org b/docs/marketing-v0.1.0.org index 63301f0..85466cc 100644 --- a/docs/marketing-v0.1.0.org +++ b/docs/marketing-v0.1.0.org @@ -34,10 +34,10 @@ The narrative: "An autonomous AI agent that doesn't just chat, but lives nativel - *Hook:* "Own your brain. An AI agent that runs locally on your Markdown/Org files with mathematical security gates." 3. **The AI / Autonomous Agent Hackers:** - *Channels:* Hacker News (Show HN), Twitter/X (AI tech Twitter). - - *Hook:* "Tired of fragile Python/Playwright agent wrappers? org-agent uses a deterministic Lisp microkernel to formally verify LLM actions before execution." + - *Hook:* "Tired of fragile Python/Playwright agent wrappers? opencortex uses a deterministic Lisp microkernel to formally verify LLM actions before execution." ** Launch Materials -- **Demo Video (2 minutes):** Show the one-liner install, the agent running the `Scribe` skill in the background, and the user querying it via `org-agent chat`. +- **Demo Video (2 minutes):** Show the one-liner install, the agent running the `Scribe` skill in the background, and the user querying it via `opencortex chat`. - **Blog Post / Essay:** "Why we built an Autonomous Agent in Common Lisp." Discuss the fragility of current SOTA (Devin/SWE-agent) and the necessity of the Bouncer/Policy gates. * 4. Post-Launch Community Engagement diff --git a/docs/quickstart.org b/docs/quickstart.org index 1f4191b..942bf2a 100644 --- a/docs/quickstart.org +++ b/docs/quickstart.org @@ -4,19 +4,19 @@ #+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 probabilistic-deterministic agent. +Welcome to ~opencortex~, 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: - **Docker & Docker Compose**: The primary enclosure for the Lisp Machine. - **LLM API Keys**: At least one key for Gemini, Anthropic, or OpenAI. -- **Emacs (Optional)**: For the full literate experience via ~org-agent.el~. +- **Emacs (Optional)**: For the full literate experience via ~opencortex.el~. * 3. Installation & Enclosure ** Step 1: Clone the Autonomousty #+begin_src bash -git clone https://github.com/amr/org-agent.git -cd org-agent +git clone https://github.com/amr/opencortex.git +cd opencortex #+end_src ** Step 2: Secret Configuration @@ -36,8 +36,8 @@ docker-compose up --build -d Once the harness is "Ready", you can interact with it via multiple sensors. ** Gateway A: Emacs (communication protocol) -If you have configured the ~org-agent~ package in Emacs: -1. Open a chat buffer: ~M-x org-agent-chat-open~. +If you have configured the ~opencortex~ package in Emacs: +1. Open a chat buffer: ~M-x opencortex-chat-open~. 2. Send: "Are you online, agent?" ** Gateway B: External Sensors @@ -46,7 +46,7 @@ If you enabled Signal or Telegram in ~.env~, send a message directly to your bot * 5. Verification (The Chaos Check) To ensure the harness is fully healthy, check the logs for the Micro-Loader summary: #+begin_src bash -docker-compose logs -f org-agent +docker-compose logs -f opencortex #+end_src Look for: ~LOADER: Boot Complete. [Ready: 34] [Failed: 0]~ diff --git a/docs/rca/rca-boot-sequence.org b/docs/rca/rca-boot-sequence.org index c0c6892..e18b217 100644 --- a/docs/rca/rca-boot-sequence.org +++ b/docs/rca/rca-boot-sequence.org @@ -19,9 +19,9 @@ Skills that depended on functions or variables from other skills would randomly ** Symptoms Variables or functions with the same name in different skills would silently overwrite each other, causing unpredictable behavior. ** Root Cause -All skills were being evaluated directly into the `org-agent` package. +All skills were being evaluated directly into the `opencortex` package. ** Resolution -**Package-Based Jailing:** Each skill is now evaluated within its own dedicated, shadowed package (e.g., `ORG-AGENT.SKILLS.ORG-SKILL-CHAT`). This ensures logical isolation while still allowing access to kernel exports. +**Package-Based Jailing:** Each skill is now evaluated within its own dedicated, shadowed package (e.g., `OPENCORTEX.SKILLS.ORG-SKILL-CHAT`). This ensures logical isolation while still allowing access to kernel exports. * 3. Issue: Boot Stall (The Hanging Skill) ** Symptoms @@ -31,7 +31,7 @@ Skill loading was strictly synchronous and blocking on the main thread. ** Resolution **Execution Timeouts:** Implemented `load-skill-with-timeout`, which wraps the loader in a monitored thread. If a skill takes longer than 5 seconds to initialize, the loader terminates the thread, jails the failure, and continues with the rest of the boot sequence. -* 4. org-agent Mandate Alignment +* 4. opencortex Mandate Alignment ** Evolutionary Kernel The boot sequence is now a verifiable, mathematical process rather than a side-effect of filesystem organization. ** Literate Granularity diff --git a/docs/rca/rca-formal-verification.org b/docs/rca/rca-formal-verification.org index 3689b44..919250f 100644 --- a/docs/rca/rca-formal-verification.org +++ b/docs/rca/rca-formal-verification.org @@ -17,7 +17,7 @@ System failed to load with `Package STR does not exist`. ** Root Cause Incorrect assumption about the Quicklisp system name vs. the package name. The library is `cl-str` but the Quicklisp system is `str` and the package is `str`. ** Resolution -1. Updated `org-agent.asd` to depend on `:str`. +1. Updated `opencortex.asd` to depend on `:str`. 2. Updated all source code and literate notes to use the `str:` prefix. 3. Verified via explicit `ql:quickload` in the test runner. @@ -25,7 +25,7 @@ Incorrect assumption about the Quicklisp system name vs. the package name. The l - **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. org-agent Mandate Alignment +* 4. opencortex Mandate Alignment ** Soundness over Heuristics By moving to formal invariants, we have moved from "blacklisting bad things" to "proving safety." Any action that cannot be proven to satisfy all invariants is denied by default. ** Literate Granularity diff --git a/docs/rca/rca-gateway-matrix.org b/docs/rca/rca-gateway-matrix.org index 4a56c97..ccdb7bd 100644 --- a/docs/rca/rca-gateway-matrix.org +++ b/docs/rca/rca-gateway-matrix.org @@ -3,7 +3,7 @@ #+FILETAGS: :rca:gateway:matrix:chat:autonomy: * Executive Summary -Successfully implemented the third and final external communication channel (Matrix) for Org-agent v1.0. Resolved integration issues related to case-sensitivity in JSON keys and strict header requirements in `dexador`. +Successfully implemented the third and final external communication channel (Matrix) for OpenCortex v1.0. Resolved integration issues related to case-sensitivity in JSON keys and strict header requirements in `dexador`. * 1. Issue: Symbol Casing in JSON Keys ** Symptoms @@ -30,7 +30,7 @@ I was passing a single string or an incorrectly nested list where `dexador` expe Standardized all gateway HTTP calls to use proper alist nesting for headers. * 4. Completion: Communication Track -With Telegram, Signal, and Matrix gateways now verified and passing tests, the Org-agent has achieved full multi-channel parity. +With Telegram, Signal, and Matrix gateways now verified and passing tests, the OpenCortex has achieved full multi-channel parity. - **Telegram:** Polling via Bot API. - **Signal:** Wrapping `signal-cli`. - **Matrix:** Polling via `/sync` Client API. diff --git a/docs/rca/rca-gateway-signal.org b/docs/rca/rca-gateway-signal.org index cd68809..5de7db7 100644 --- a/docs/rca/rca-gateway-signal.org +++ b/docs/rca/rca-gateway-signal.org @@ -22,7 +22,7 @@ Unlike Telegram's HTTP API, Signal requires a local binary (`signal-cli`). ** Security The system uses the pre-configured Signal account `+13322690326` discovered in the user's memex. -* 3. Alignment with org-agent Mandates +* 3. Alignment with opencortex Mandates ** Literate Granularity Strictly adhered to the "one definition per block" mandate throughout the new `org-skill-gateway-signal.org` file. ** Verification diff --git a/docs/rca/rca-gateway-telegram.org b/docs/rca/rca-gateway-telegram.org index efe3a27..6de12ed 100644 --- a/docs/rca/rca-gateway-telegram.org +++ b/docs/rca/rca-gateway-telegram.org @@ -9,10 +9,10 @@ Successfully implemented the first external communication channel (Telegram) and ** Symptoms During compilation, `gateway-telegram.lisp` failed with `UNDEFINED-FUNCTION` for `register-actuator` and `harness-log`. ** 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. +Poorly scoped foundational functions. These were defined in `core.lisp` (the loop orchestrator), which was loaded *after* the gateways in `opencortex.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 `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. **Reordering:** Adjusted `opencortex.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 @@ -32,7 +32,7 @@ Misinterpretation of the `UIOP` API. `setenv` is not a standard export; the port ** Resolution Updated all test environment setup to use the `setf` accessor. -* 4. org-agent Mandate Alignment +* 4. opencortex Mandate Alignment ** Autonomous Boundary By moving the Telegram API logic to a user-space skill and communicating with the core via standard stimuli, we have respected the microkernel boundary. ** Homoiconic Memory diff --git a/docs/rca/rca-infrastructure-docker.org b/docs/rca/rca-infrastructure-docker.org index 1f98eca..82bcdbf 100644 --- a/docs/rca/rca-infrastructure-docker.org +++ b/docs/rca/rca-infrastructure-docker.org @@ -3,14 +3,14 @@ #+FILETAGS: :rca:docker:deployment:infrastructure:autonomy: * Executive Summary -Standardized the `org-agent` execution environment by creating a production-grade Docker infrastructure. This ensures that all system dependencies, including the Lisp runtime and external binaries like `signal-cli`, are locked down and portable. +Standardized the `opencortex` execution environment by creating a production-grade Docker infrastructure. This ensures that all system dependencies, including the Lisp runtime and external binaries like `signal-cli`, are locked down and portable. * 1. Architectural Intent: The "Clean Room" Model ** Problem -The `org-agent` was relying on host-local binaries (`sbcl`, `signal-cli`) and manually configured Quicklisp dists. This made deployment to other environments (e.g., a VPS or a Autonomous Home Server) fragile and prone to version drift. +The `opencortex` was relying on host-local binaries (`sbcl`, `signal-cli`) and manually configured Quicklisp dists. This made deployment to other environments (e.g., a VPS or a Autonomous Home Server) fragile and prone to version drift. ** Solution 1. **Dockerfile:** Created a multi-step build process that installs Debian Bookworm, SBCL, Java, and `signal-cli 0.14.0`. -2. **Pre-Caching:** The build process triggers a `ql:quickload` of the `:org-agent` system, ensuring all Lisp dependencies are pre-downloaded and stored in the image layer, drastically reducing startup time. +2. **Pre-Caching:** The build process triggers a `ql:quickload` of the `:opencortex` system, ensuring all Lisp dependencies are pre-downloaded and stored in the image layer, drastically reducing startup time. 3. **Compose Orchestration:** Standardized the runtime via `docker-compose.yml`, which handles volume mounting of the user's `memex` directory and injection of `.env` secrets. * 2. Volume Mapping & Persistence @@ -19,7 +19,7 @@ To maintain the "Autonomous" mandate, the agent's code is isolated, but its memo - **Mapping:** `../..` (host) -> `/memex` (container). - **State:** Created a named Docker volume `signal-state` to ensure that `signal-cli` identities and cryptographic keys survive container restarts and image updates. -* 3. Alignment with org-agent Mandates +* 3. Alignment with opencortex Mandates ** Evolutionary Completion By moving to Docker, we have achieved "Evolutionary Completion" for the deployment track. The system is no longer a collection of scripts; it is a deployable appliance. ** Documentation @@ -27,4 +27,4 @@ A new `Deployment Guide` was added to `docs/deployment.org` to ensure standard o * 4. Permanent Learnings - **Lisp Build Layers:** Always push the system to the ASDF registry and quickload during Docker build to bake dependencies into the image. -- **Compose Locality:** Placing the `docker-compose.yml` inside the `projects/org-agent/` folder keeps infrastructure code close to the implementation logic. +- **Compose Locality:** Placing the `docker-compose.yml` inside the `projects/opencortex/` folder keeps infrastructure code close to the implementation logic. diff --git a/docs/rca/rca-lisp-repair-async.org b/docs/rca/rca-lisp-repair-async.org index 6a7d7bc..8a919f9 100644 --- a/docs/rca/rca-lisp-repair-async.org +++ b/docs/rca/rca-lisp-repair-async.org @@ -22,7 +22,7 @@ Mismatched expectations of signal nesting. The skill expected the code at `(getf ** Resolution Updated the deterministic logic to correctly traverse the nested signal structure: `(getf (getf context :candidate) :payload)`. -* 3. org-agent Mandate Alignment +* 3. opencortex Mandate Alignment ** Autonomous Boundary The core is now strictly a parser. Repair is an optional, user-space service. ** Reactive Signal Pipeline diff --git a/docs/rca/rca-playwright-bridge.org b/docs/rca/rca-playwright-bridge.org index 9caaa13..e36811b 100644 --- a/docs/rca/rca-playwright-bridge.org +++ b/docs/rca/rca-playwright-bridge.org @@ -3,7 +3,7 @@ #+FILETAGS: :rca:intelligence:browsing:automation:autonomy: * Executive Summary -Successfully implemented a high-fidelity browsing bridge using Playwright and Python. This allows the `org-agent` to interact with modern, JavaScript-rendered web applications that were previously inaccessible via simple HTTP clients. +Successfully implemented a high-fidelity browsing bridge using Playwright and Python. This allows the `opencortex` to interact with modern, JavaScript-rendered web applications that were previously inaccessible via simple HTTP clients. * 1. Architectural Strategy: The I/O Bridge ** Problem @@ -28,7 +28,7 @@ Created the `:browser` cognitive tool, which exposes three primary capabilities - **Extraction:** Targeted text retrieval via CSS selectors. - **Vision:** Base64-encoded screenshot capture for future multimodal processing. -* 4. org-agent Mandate Alignment +* 4. opencortex Mandate Alignment ** Zero-Bloat (Managed) While adding Playwright increases the image size, it is a "Complexity Earned" trade-off that dramatically expands the agent's capability frontier. ** Literate Granularity diff --git a/docs/rca/rca-provider-verification.org b/docs/rca/rca-provider-verification.org index 24a8fda..f1d8e77 100644 --- a/docs/rca/rca-provider-verification.org +++ b/docs/rca/rca-provider-verification.org @@ -17,9 +17,9 @@ 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-probabilistic-backend`. +The `credentials-vault.lisp` and `llm-gateway.lisp` files (consolidated in a previous session) were never added to the `opencortex.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`. +1. Added both files to `opencortex.asd`. 2. Enforced strict loading order: `probabilistic` (defines registry) -> `credentials-vault` -> `llm-gateway` (uses registry). * 3. Issue: Credential Key Mismatch @@ -30,7 +30,7 @@ Gemini requests failed with "API Key missing" even when environment variables we ** Resolution Updated `vault-get-secret` to map both `:gemini` and `:gemini-api` to the same `GEMINI_API_KEY` environment variable. -* 4. org-agent Mandate Alignment +* 4. opencortex Mandate Alignment ** Invariant Check - *High-Integrity Memory:* All individual provider tracks are now backed by automated unit tests (`llm-gateway-tests.lisp`). - *Literate Programming:* Updated `org-skill-llm-gateway.org` to reflect the improved `get-nested` utility. diff --git a/docs/rca/rca-self-fix-loop.org b/docs/rca/rca-self-fix-loop.org index 1a1918f..3d61865 100644 --- a/docs/rca/rca-self-fix-loop.org +++ b/docs/rca/rca-self-fix-loop.org @@ -22,14 +22,14 @@ Created `self-fix-tests.lisp` which: ** Symptoms Repeated `LOAD-SYSTEM-DEFINITION-ERROR` and "unmatched close parenthesis" errors during test integration. ** Root Cause -Complexity in the `:components` nesting of `org-agent.asd` led to repeated syntax errors when using automated editing tools. The deep nesting made manual paren counting prone to "off-by-one" errors. +Complexity in the `:components` nesting of `opencortex.asd` led to repeated syntax errors when using automated editing tools. The deep nesting made manual paren counting prone to "off-by-one" errors. ** Resolution -Refactored `org-agent.asd` to use a **Flat Component Structure**. +Refactored `opencortex.asd` to use a **Flat Component Structure**. - *Before:* `:components ((:module "src" :components (...)))` - *After:* `:components ((:file "src/package") ...)` This eliminates unnecessary nesting levels and drastically reduces the surface area for syntax errors. -* 3. org-agent Mandate Alignment +* 3. opencortex Mandate Alignment ** Invariant Check - *Lisp Machine Autonomousty:* Verification utilized hot-reloading (`load-skill-from-org`) without restarting the SBCL image. - *Literate Programming:* Updated `org-skill-self-fix.org` to match the finalized `self-fix.lisp` logic. diff --git a/docs/rca/rca-shell-hardening.org b/docs/rca/rca-shell-hardening.org index 76ba22d..b3dba70 100644 --- a/docs/rca/rca-shell-hardening.org +++ b/docs/rca/rca-shell-hardening.org @@ -19,11 +19,11 @@ The `execute-shell-safely` function only checked the first space-delimited word ** Symptoms `UNDEFINED-FUNCTION EXECUTE-SHELL-SAFELY` during unit tests. ** Root Cause -`src/shell-logic.lisp` was missing an `(in-package :org-agent)` declaration, causing symbols to be defined in the default `COMMON-LISP-USER` package instead of the harness package. +`src/shell-logic.lisp` was missing an `(in-package :opencortex)` declaration, causing symbols to be defined in the default `COMMON-LISP-USER` package instead of the harness package. ** Resolution Added the `in-package` header to `shell-logic.lisp`. -* 3. org-agent Mandate Alignment +* 3. opencortex Mandate Alignment ** Invariant Check - *High-Integrity Memory:* The shell actuator is now formally verified with 4 new unit tests covering whitelist enforcement and injection blocking. - *Literate Programming:* Updated `org-skill-shell-actuator.org` Phase A and Build sections to reflect the hardened logic. diff --git a/docs/rca/rca-task-orchestrator.org b/docs/rca/rca-task-orchestrator.org index 6715cce..7334a3b 100644 --- a/docs/rca/rca-task-orchestrator.org +++ b/docs/rca/rca-task-orchestrator.org @@ -23,7 +23,7 @@ Selected "Majority Rules" over "First-to-Finish". - *Pros:* Higher accuracy, mathematically consistent. - *Cons:* Slower (latency limited by the slowest provider). ** Invariant Alignment -Aligns with org-agent Mandate 4 (Radical Transparency) and Invariant 2 (Technical Mastery) by ensuring decisions are auditable and consistent across multiple brains. +Aligns with opencortex Mandate 4 (Radical Transparency) and Invariant 2 (Technical Mastery) by ensuring decisions are auditable and consistent across multiple brains. * 3. Design Decision: Task Integrity Gate ** Requirement @@ -33,7 +33,7 @@ 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). -* 4. org-agent Mandate Violations during Session (Corrected) +* 4. opencortex Mandate Violations during Session (Corrected) ** Violations 1. Editing without prior commit. 2. Direct `.lisp` edits vs Literate Org tangling. @@ -45,4 +45,4 @@ Enforces the "High-Integrity Memory" mandate by ensuring the Org-mode AST remain * 5. Permanent Learnings - *Check Exports:* Always verify that symbols exported in `package.lisp` have a corresponding definition in the literate source. -- *Strict org-agent Mode:* Enable a pre-save hook or agent check to ensure all edits are performed within `#+begin_src` blocks in Literate Org files to avoid synchronization debt. +- *Strict opencortex Mode:* Enable a pre-save hook or agent check to ensure all edits are performed within `#+begin_src` blocks in Literate Org files to avoid synchronization debt. diff --git a/docs/ux.org b/docs/ux.org index a21f702..eb64c02 100644 --- a/docs/ux.org +++ b/docs/ux.org @@ -4,7 +4,7 @@ #+STARTUP: content * Overview -This document traces the intended User Experience (UX) journey for the ~org-agent~. It serves as a living design document to ensure that architectural decisions align with a frictionless, autonomous, and intuitive user interaction model. +This document traces the intended User Experience (UX) journey for the ~opencortex~. It serves as a living design document to ensure that architectural decisions align with a frictionless, autonomous, and intuitive user interaction model. * 1. The Zero-to-One Experience (Onboarding) ** Goal @@ -13,7 +13,7 @@ A user should be able to go from discovering the project to having a running, ca ** The Appliance Paradigm (Primary Path) The user runs a single command in their terminal: #+begin_src bash -curl -fsSL https://raw.githubusercontent.com/gharbeia/org-agent/main/scripts/install.sh | bash +curl -fsSL https://raw.githubusercontent.com/gharbeia/opencortex/main/scripts/install.sh | bash #+end_src ** The Interactive Wizard @@ -32,7 +32,7 @@ Immediately after boot, the user needs a way to verify the agent is alive and ca ** The Interaction The user types a local client command to connect to the background daemon: #+begin_src bash -org-agent chat +opencortex chat #+end_src This opens a slick, colorful interactive terminal session: @@ -40,13 +40,13 @@ This opens a slick, colorful interactive terminal session: > User: Hello, what are my active projects? > Agent: [Thinking...] > Agent: You currently have 3 active projects: -> 1. Org-agent v1.0 +> 1. OpenCortex v1.0 > 2. Home Renovation > 3. Read 'The Autonomous Individual' #+end_example ** Behind the Scenes -1. The ~org-agent chat~ client connects to the daemon's local port (e.g., 9105). +1. The ~opencortex chat~ client connects to the daemon's local port (e.g., 9105). 2. It sends a ~:chat-message~ signal. 3. The core harness routes this to the Probabilistic Engine. 4. The Context Manager retrieves active projects from the Memex AST. diff --git a/literate/act.org b/literate/act.org index c814b44..837a5c9 100644 --- a/literate/act.org +++ b/literate/act.org @@ -11,7 +11,7 @@ The Act stage performs the final side-effects of the reasoning engine. It routes The core harness can be configured via environment variables to operate silently or target different default outputs. #+begin_src lisp :tangle ../src/act.lisp -(in-package :org-agent) +(in-package :opencortex) (defvar *default-actuator* :cli) (defvar *silent-actuators* '(:cli :system-message :emacs)) @@ -59,7 +59,7 @@ The `:system` actuator handles internal harness commands like code evaluation an (:eval (let ((code (getf payload :code))) (eval (read-from-string code)))) (:create-skill (let* ((filename (getf payload :filename)) (content (getf payload :content)) - (skills-dir (merge-pathnames "skills/" (asdf:system-source-directory :org-agent))) + (skills-dir (merge-pathnames "skills/" (asdf:system-source-directory :opencortex))) (full-path (merge-pathnames filename skills-dir))) (with-open-file (out full-path :direction :output :if-exists :supersede) (write-string content out)) (load-skill-from-org full-path))) diff --git a/literate/communication.org b/literate/communication.org index 75842fb..1d5607f 100644 --- a/literate/communication.org +++ b/literate/communication.org @@ -43,7 +43,7 @@ flowchart LR We ensure all protocol logic resides within the isolated system namespace. #+begin_src lisp :tangle ../src/communication.lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src ** Actuator Registry diff --git a/literate/context.org b/literate/context.org index a5465a0..1a07d9b 100644 --- a/literate/context.org +++ b/literate/context.org @@ -8,7 +8,7 @@ A common failure mode for Large Language Models (LLMs) is the "Lost in the Middle" phenomenon, where the model's reasoning accuracy degrades as its context window becomes saturated with irrelevant data. Naive approaches to context management—such as simple character-count truncation or sliding windows—often sever the structural relationships that define an Org-mode Memex. -The ~org-agent~ harness implements a deterministic, tree-aware solution: the **Foveal-Peripheral Hybrid Model**. +The ~opencortex~ harness implements a deterministic, tree-aware solution: the **Foveal-Peripheral Hybrid Model**. *** 1. The Foveal Focus (High Resolution) When the harness prepares a prompt for the Probabilistic Engine, it identifies a "Foveal Focus"—typically the specific Org headline or task the user is currently interacting with. This node, along with its immediate children and semantically relevant neighbors, is rendered at "High Resolution," meaning its full body text, properties, and metadata are included in the prompt. @@ -38,7 +38,7 @@ The ~context.lisp~ module provides the deterministic functional layer for queryi We begin by ensuring we are executing within the correct isolated package namespace. #+begin_src lisp :tangle ../src/context.lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src ** Querying the Store (context-query-store) @@ -214,10 +214,10 @@ Following the Engineering Standards, the peripheral vision extraction and render ** Test Suite Context #+begin_src lisp :tangle ../tests/peripheral-vision-tests.lisp -(defpackage :org-agent-peripheral-vision-tests - (:use :cl :fiveam :org-agent) +(defpackage :opencortex-peripheral-vision-tests + (:use :cl :fiveam :opencortex) (:export #:vision-suite)) -(in-package :org-agent-peripheral-vision-tests) +(in-package :opencortex-peripheral-vision-tests) (def-suite vision-suite :description "Verification of Foveal-Peripheral context model.") @@ -230,7 +230,7 @@ Verify that the foveal target is rendered with content, while siblings are skele #+begin_src lisp :tangle ../tests/peripheral-vision-tests.lisp (test test-foveal-rendering "Verify that the foveal target is rendered with content, while siblings are skeletal." - (clrhash org-agent::*memory*) + (clrhash opencortex::*memory*) (let* ((ast '(:type :HEADLINE :properties (:ID "proj-root" :TITLE "Project" :TAGS "project") :contents ((:type :HEADLINE :properties (:ID "node-foveal" :TITLE "Foveal Node") :raw-content "FOVEAL CONTENT" :contents nil) @@ -250,7 +250,7 @@ Verify that context-assemble-global-awareness handles multiple projects correctl #+begin_src lisp :tangle ../tests/peripheral-vision-tests.lisp (test test-awareness-budget "Verify that context-assemble-global-awareness handles multiple projects." - (clrhash org-agent::*memory*) + (clrhash opencortex::*memory*) (ingest-ast '(:type :HEADLINE :properties (:ID "p1" :TITLE "Project 1" :TAGS "project") :contents nil)) (ingest-ast '(:type :HEADLINE :properties (:ID "p2" :TITLE "Project 2" :TAGS "project") :contents nil)) (let ((output (context-assemble-global-awareness))) diff --git a/literate/loop.org b/literate/loop.org index 37aaa2b..d67402a 100644 --- a/literate/loop.org +++ b/literate/loop.org @@ -5,7 +5,7 @@ * The Metabolic Loop (loop.lisp) ** Architectural Intent: The Heartbeat -The Metabolic Loop is the high-level coordinator of the Org-Agent. It orchestrates the flow of energy (information) through the system by calling the three metabolic stages in sequence: +The Metabolic Loop is the high-level coordinator of the OpenCortex. It orchestrates the flow of energy (information) through the system by calling the three metabolic stages in sequence: 1. **Perceive:** Sensory intake. 2. **Reason:** Cognitive processing. 3. **Act:** Physical side-effects. @@ -14,7 +14,7 @@ The Metabolic Loop is the high-level coordinator of the Org-Agent. It orchestrat The loop requires thread-safe interrupt handling to ensure that the agent can be stopped gracefully without leaving the Lisp image in an inconsistent state. #+begin_src lisp :tangle ../src/loop.lisp -(in-package :org-agent) +(in-package :opencortex) (defvar *interrupt-flag* nil) (defvar *interrupt-lock* (bt:make-lock "harness-interrupt-lock")) @@ -67,7 +67,7 @@ The heartbeat ensures the agent remains "alive" even in the absence of external (sleep interval) ;; inject-stimulus is synchronous for heartbeats, preventing accumulation. (inject-stimulus (list :type :EVENT :payload (list :sensor :heartbeat :unix-time (get-universal-time)))))) - :name "org-agent-heartbeat")))) + :name "opencortex-heartbeat")))) #+end_src ** Main Entry Point @@ -77,7 +77,7 @@ The `main` function initializes the environment, loads skills, and starts the he (defun main () "Entry point for the Skeleton MVP. Handles initialization and graceful shutdown." (let* ((home (uiop:getenv "HOME")) - (env-file (uiop:merge-pathnames* ".local/share/org-agent/.env" (uiop:ensure-directory-pathname home)))) + (env-file (uiop:merge-pathnames* ".local/share/opencortex/.env" (uiop:ensure-directory-pathname home)))) (when (uiop:file-exists-p env-file) (cl-dotenv:load-env env-file))) (initialize-actuators) diff --git a/literate/manifest.org b/literate/manifest.org index 4e1aeb2..0f31e7b 100644 --- a/literate/manifest.org +++ b/literate/manifest.org @@ -1,20 +1,20 @@ -#+TITLE: Manifest (org-agent.asd) +#+TITLE: Manifest (opencortex.asd) #+AUTHOR: Amr #+FILETAGS: :harness:system: #+STARTUP: content -* Manifest (org-agent.asd) +* Manifest (opencortex.asd) ** Architectural Intent: The ASDF Skeleton -The ~org-agent.asd~ file is the physical blueprint of the Lisp Machine. It uses **Another System Definition Facility (ASDF)** to orchestrate the compilation and loading of all harness modules. +The ~opencortex.asd~ file is the physical blueprint of the Lisp Machine. It uses **Another System Definition Facility (ASDF)** to orchestrate the compilation and loading of all harness modules. -Traditional Lisp systems often use complex, non-linear dependency graphs. However, the ~org-agent~ harness mandates a strict, linear bootstrap sequence. +Traditional Lisp systems often use complex, non-linear dependency graphs. However, the ~opencortex~ harness mandates a strict, linear bootstrap sequence. *** 1. Strict Serial Loading (:serial t) The harness uses the ~:serial t~ flag. This is a critical design choice that ensures every file is compiled and loaded in the exact order it appears in the ~:components~ list. This eliminates "macro-not-found" errors by guaranteeing that the ~package.lisp~ and ~skills.lisp~ (where the core macros are defined) are always established before any behavioral logic or skills are loaded. *** 2. Isolation of the Verification Suite -To maintain a "Zero-Overhead" production environment, the testing logic is isolated into a secondary system: ~:org-agent/tests~. This allows the harness to boot in production without loading the ~FiveAM~ framework or the voluminous test data, keeping the memory footprint minimal and the attack surface small. +To maintain a "Zero-Overhead" production environment, the testing logic is isolated into a secondary system: ~:opencortex/tests~. This allows the harness to boot in production without loading the ~FiveAM~ framework or the voluminous test data, keeping the memory footprint minimal and the attack surface small. ** The Build Pipeline #+begin_src mermaid @@ -29,9 +29,9 @@ flowchart TD ** Harness System Definition This system defines the core "Thin Harness." It includes the protocol, the object store, and the functional loop. -#+begin_src lisp :tangle ../org-agent.asd -(defsystem :org-agent - :name "org-agent" +#+begin_src lisp :tangle ../opencortex.asd +(defsystem :opencortex + :name "opencortex" :author "Amr" :version "0.1.0" :license "AGPLv3" @@ -49,26 +49,26 @@ This system defines the core "Thin Harness." It includes the protocol, the objec (:file "src/deterministic") (:file "src/loop")) :build-operation "program-op" - :build-pathname "org-agent-server" - :entry-point "org-agent:main") + :build-pathname "opencortex-server" + :entry-point "opencortex:main") #+end_src ** Verification Suite Definition -This system contains the empirical tests required by the Engineering Standards. It depends on ~:org-agent~ and the ~FiveAM~ testing framework. +This system contains the empirical tests required by the Engineering Standards. It depends on ~:opencortex~ and the ~FiveAM~ testing framework. -#+begin_src lisp :tangle ../org-agent.asd -(defsystem :org-agent/tests - :depends-on (:org-agent :fiveam) +#+begin_src lisp :tangle ../opencortex.asd +(defsystem :opencortex/tests + :depends-on (:opencortex :fiveam) :components ((:file "tests/communication-tests") (:file "tests/pipeline-tests") (:file "tests/boot-sequence-tests") (:file "tests/memory-tests") (:file "tests/immune-system-tests")) :perform (test-op (o s) - (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :communication-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* :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* :memory-suite :org-agent-memory-tests)) - (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :immune-suite :org-agent-immune-system-tests)))) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :communication-protocol-suite :opencortex-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :pipeline-suite :opencortex-pipeline-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :safety-suite :opencortex-safety-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :boot-suite :opencortex-boot-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :memory-suite :opencortex-memory-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :immune-suite :opencortex-immune-system-tests)))) #+end_src diff --git a/literate/memory.org b/literate/memory.org index 40504b7..240db08 100644 --- a/literate/memory.org +++ b/literate/memory.org @@ -6,9 +6,9 @@ * The System Memory (memory.lisp) ** Architectural Intent: The Single Address Space (Live Memory) -Yes, the Memory module is the cognitive bedrock of the org-agent. It is not a database; it is the agent's live, active "brain" state. +Yes, the Memory module is the cognitive bedrock of the opencortex. It is not a database; it is the agent's live, active "brain" state. -Traditional architectures rely on external databases (SQLite, Vector DBs) which introduce I/O latency and structural impedance. The org-agent architecture chooses a different path: the **Single Address Space**. By treating the entire knowledge base as a graph of Lisp pointers, we achieve microsecond recollection and total structural transparency. +Traditional architectures rely on external databases (SQLite, Vector DBs) which introduce I/O latency and structural impedance. The opencortex architecture chooses a different path: the **Single Address Space**. By treating the entire knowledge base as a graph of Lisp pointers, we achieve microsecond recollection and total structural transparency. - **Pointer-Based Reasoning:** By loading the entire knowledge graph into a live Common Lisp hash table, we achieve microsecond recollection. The harness doesn't "search a file"; it traverses a memory pointer. - **Memory Imaging:** The ability to snapshot the Lisp image allows the agent to resume its entire cognitive state instantly, solving the "Cold Start" problem. @@ -32,7 +32,7 @@ flowchart TD ** Package Context #+begin_src lisp :tangle ../src/memory.lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src ** The Object Repository @@ -179,11 +179,11 @@ Utility functions for AST traversal and path resolution. Following the Engineering Standards, the Memory must be empirically verified through automated testing. The following test suite ensures the mathematical integrity of the Merkle hashes and the behavioral correctness of the immutable versioning and rollback systems. #+begin_src lisp :tangle ../tests/memory-tests.lisp -(defpackage :org-agent-memory-tests - (:use :cl :fiveam :org-agent) +(defpackage :opencortex-memory-tests + (:use :cl :fiveam :opencortex) (:export #:memory-suite)) -(in-package :org-agent-memory-tests) +(in-package :opencortex-memory-tests) (def-suite memory-suite :description "Tests for the Merkle-Tree Memory.") diff --git a/literate/package.org b/literate/package.org index 9960a07..e8d2560 100644 --- a/literate/package.org +++ b/literate/package.org @@ -4,7 +4,7 @@ #+STARTUP: content * System Interface (package.lisp) -The ~package.lisp~ file defines the public API of the ~org-agent~ harness. It serves as the primary membrane between the deterministic core modules and the dynamic world of skills and actuators. +The ~package.lisp~ file defines the public API of the ~opencortex~ harness. It serves as the primary membrane between the deterministic core modules and the dynamic world of skills and actuators. ** Architectural Intent: The Package Membrane By strictly defining the public interface, we ensure that skills remain decoupled from the harness implementation details. This allows for autonomous replacement of any component (e.g., swapping the Memory or the Probabilistic Engine) without breaking existing skills. @@ -19,7 +19,7 @@ flowchart TD ** Public API Export #+begin_src lisp :tangle ../src/package.lisp -(defpackage :org-agent +(defpackage :opencortex (:use :cl) (:export ;; --- communication protocol --- @@ -127,7 +127,7 @@ flowchart TD ** Package Implementation #+begin_src lisp :tangle ../src/package.lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src ** Harness Logging State diff --git a/literate/perceive.org b/literate/perceive.org index cae49f3..4b5a135 100644 --- a/literate/perceive.org +++ b/literate/perceive.org @@ -5,13 +5,13 @@ * Stage 1: Perceive (perceive.lisp) ** Architectural Intent: Sensory Ingestion -The Perceive stage is the "sensory cortex" of the Org-Agent. It takes raw stimuli from the outside world (keyboard events, chat messages, heartbeats, or system interrupts) and normalizes them into internal **Signals**. +The Perceive stage is the "sensory cortex" of the OpenCortex. It takes raw stimuli from the outside world (keyboard events, chat messages, heartbeats, or system interrupts) and normalizes them into internal **Signals**. ** Async Sensor Routing To prevent blocking the main pipeline, certain sensors (like user commands or chat messages) are processed asynchronously in their own threads. #+begin_src lisp :tangle ../src/perceive.lisp -(in-package :org-agent) +(in-package :opencortex) (defvar *async-sensors* '(:chat-message :delegation :user-command) "List of sensors that should be processed asynchronously to avoid blocking gateways.") @@ -41,7 +41,7 @@ The entry point for raw messages. It determines if the signal should be processe (restart-case (handler-bind ((error (lambda (c) (harness-log "ASYNC ERROR: ~a" c) (invoke-restart 'skip-event)))) (process-signal raw-message)) (skip-event () nil))) - :name "org-agent-async-task") + :name "opencortex-async-task") (restart-case (handler-bind ((error (lambda (c) (harness-log "SYSTEM ERROR: ~a" c) (invoke-restart 'skip-event)))) (process-signal raw-message)) (skip-event () (harness-log "SYSTEM RECOVERY: Stimulus dropped.~%")))))) diff --git a/literate/reason.org b/literate/reason.org index 7e7b311..b4ece78 100644 --- a/literate/reason.org +++ b/literate/reason.org @@ -5,7 +5,7 @@ * Stage 2: Reason (reason.lisp) ** Architectural Intent: Unified Cognition -The Reason stage is the cognitive engine of the Org-Agent. It unifies two distinct reasoning modes: +The Reason stage is the cognitive engine of the OpenCortex. It unifies two distinct reasoning modes: 1. **Probabilistic Reasoning:** Consulting neural models (LLMs) to generate action proposals based on current context. 2. **Deterministic Reasoning:** Running those proposals through a series of deterministic safety gates (Policy, Invariants, and Skill-specific validation) to ensure alignment and security. @@ -13,7 +13,7 @@ The Reason stage is the cognitive engine of the Org-Agent. It unifies two distin We initialize the probabilistic backends and the provider cascade which determines the order in which models are consulted. #+begin_src lisp :tangle ../src/reason.lisp -(in-package :org-agent) +(in-package :opencortex) (defvar *probabilistic-backends* (make-hash-table :test 'equal)) (defvar *provider-cascade* nil) diff --git a/literate/setup.org b/literate/setup.org index c508a0c..de2f3cd 100644 --- a/literate/setup.org +++ b/literate/setup.org @@ -4,9 +4,9 @@ #+STARTUP: content * Overview: The Zero-to-One Experience -The *Setup & Onboarding* process ensures that users can boot the ~org-agent~ Lisp Machine with zero friction. We follow the *Appliance Paradigm* for standard users (Docker-first) and provide a *Power User Path* (Baremetal) for those wanting deep native integration. +The *Setup & Onboarding* process ensures that users can boot the ~opencortex~ Lisp Machine with zero friction. We follow the *Appliance Paradigm* for standard users (Docker-first) and provide a *Power User Path* (Baremetal) for those wanting deep native integration. -This file is a Literate Devops document. Tangling it generates the Docker configuration and the unified entrypoint script (~org-agent.sh~). +This file is a Literate Devops document. Tangling it generates the Docker configuration and the unified entrypoint script (~opencortex.sh~). * 1. The Appliance Paradigm (Docker First) The easiest way to run the agent is via Docker. This prevents the user from having to manually manage SBCL, Quicklisp, Python virtual environments, Playwright binaries, and Java (for Signal). @@ -15,7 +15,7 @@ The easiest way to run the agent is via Docker. This prevents the user from havi The container wraps all messy OS dependencies and pre-caches the Lisp environment for rapid booting. #+begin_src dockerfile :tangle ../Dockerfile -# ORG-AGENT v1.0 Production Environment +# OPENCORTEX v1.0 Production Environment FROM debian:bookworm-slim # Prevent interactive prompts during build @@ -66,12 +66,12 @@ RUN echo '(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-ho # 6. Setup Application Directory WORKDIR /app -COPY . /app/projects/org-agent +COPY . /app/projects/opencortex # 7. Pre-cache Lisp Dependencies RUN sbcl --non-interactive \ - --eval '(push #p"/app/projects/org-agent/" asdf:*central-registry*)' \ - --eval '(ql:quickload :org-agent)' + --eval '(push #p"/app/projects/opencortex/" asdf:*central-registry*)' \ + --eval '(ql:quickload :opencortex)' # 8. Environment & Volumes # The host's memex root should be mounted to /memex @@ -83,22 +83,22 @@ EXPOSE 9105 8080 # Entrypoint CMD ["sbcl", "--non-interactive", \ - "--eval", "(push #p\"/app/projects/org-agent/\" asdf:*central-registry*)", \ - "--eval", "(ql:quickload :org-agent)", \ - "--eval", "(org-agent:main)"] + "--eval", "(push #p\"/app/projects/opencortex/\" asdf:*central-registry*)", \ + "--eval", "(ql:quickload :opencortex)", \ + "--eval", "(opencortex:main)"] #+end_src ** Docker Compose #+begin_src yaml :tangle ../docker-compose.yml services: - org-agent: + opencortex: build: context: . dockerfile: Dockerfile - container_name: org-agent + container_name: opencortex env_file: .env volumes: - # Mount the entire memex directory (2 levels up from projects/org-agent) + # Mount the entire memex directory (2 levels up from projects/opencortex) - ../..:/memex # Ensure signal-cli state is preserved - signal-state:/root/.local/share/signal-cli @@ -111,12 +111,12 @@ volumes: signal-state: #+end_src -* 2. The Unified Entrypoint (org-agent.sh) +* 2. The Unified Entrypoint (opencortex.sh) We combine the installation script, the daemon launcher, and the CLI chat client into a single, elegant bash script. If the agent is running, it connects to the chat. If it's installed but offline, it boots the daemon. If it's not installed at all, it walks the user through the onboarding wizard. -#+begin_src bash :tangle ../org-agent.sh :shebang "#!/bin/bash" +#+begin_src bash :tangle ../opencortex.sh :shebang "#!/bin/bash" set -e PORT=9105 @@ -149,8 +149,8 @@ elif command_exists nc && nc -z $HOST $PORT 2>/dev/null; then fi # 2. Check if we have an existing installation we can boot -if [ -f "$HOME/.org-agent-path" ]; then - INSTALL_DIR=$(cat "$HOME/.org-agent-path") +if [ -f "$HOME/.opencortex-path" ]; then + INSTALL_DIR=$(cat "$HOME/.opencortex-path") if [ -d "$INSTALL_DIR" ] && [ -f "$INSTALL_DIR/docker-compose.yml" ]; then echo -e "${YELLOW}Daemon is offline. Booting from $INSTALL_DIR...${NC}" cd "$INSTALL_DIR" @@ -166,7 +166,7 @@ fi if [ -f "docker-compose.yml" ] && [ -d "literate" ]; then echo -e "${YELLOW}Local repository detected. Ensuring configuration...${NC}" INSTALL_DIR=$(pwd) - echo "$INSTALL_DIR" > "$HOME/.org-agent-path" + echo "$INSTALL_DIR" > "$HOME/.opencortex-path" if [ ! -f .env ]; then cp .env.example .env @@ -209,14 +209,14 @@ fi # 4. Zero-to-One Onboarding (No installation found) echo -e "${BLUE}==================================================${NC}" -echo -e "${BLUE} org-agent: Autonomous Intelligence Onboarding ${NC}" +echo -e "${BLUE} opencortex: Autonomous Intelligence Onboarding ${NC}" echo -e "${BLUE}==================================================${NC}" # --- OS & Docker Detection --- echo -e "\n${BLUE}[1/2] Verifying Environment...${NC}" install_docker() { - echo -e "${YELLOW}Docker is required to run org-agent natively without messy dependencies.${NC}" + echo -e "${YELLOW}Docker is required to run opencortex natively without messy dependencies.${NC}" read -p "Would you like me to attempt to install Docker? [Y/n]: " install_choice install_choice=${install_choice:-Y} if [[ "$install_choice" =~ ^[Yy]$ ]]; then @@ -269,27 +269,27 @@ MEMEX_TARGET=${MEMEX_TARGET:-$MEMEX_DEFAULT} mkdir -p "$MEMEX_TARGET/projects" cd "$MEMEX_TARGET/projects" -if [ ! -d "org-agent" ]; then - echo "Cloning org-agent..." - git clone https://github.com/gharbeia/org-agent.git - cd org-agent +if [ ! -d "opencortex" ]; then + echo "Cloning opencortex..." + git clone https://github.com/gharbeia/opencortex.git + cd opencortex else echo -e "${GREEN}✓ Repository already exists.${NC}" - cd org-agent + cd opencortex git pull origin main fi mkdir -p "$HOME/.local/bin" -ln -sf "$(pwd)/org-agent.sh" "$HOME/.local/bin/org-agent" -echo -e "${GREEN}✓ Installed 'org-agent' command to ~/.local/bin${NC}" +ln -sf "$(pwd)/opencortex.sh" "$HOME/.local/bin/opencortex" +echo -e "${GREEN}✓ Installed 'opencortex' command to ~/.local/bin${NC}" # Ensure proper ownership if sudo was used for apt if [ -n "$SUDO_USER" ]; then - chown -R "$SUDO_USER" "$MEMEX_TARGET/projects/org-agent" + chown -R "$SUDO_USER" "$MEMEX_TARGET/projects/opencortex" fi # Execute the newly cloned script to run configuration (Step 3) -exec ./org-agent.sh +exec ./opencortex.sh #+end_src * 3. The Power-User Path (Baremetal Onboarding) @@ -299,7 +299,7 @@ For users who want to run the Lisp Machine natively on their host OS (typically set -e RED='\033[0;31m'; GREEN='\033[0;32m'; BLUE='\033[0;34m'; NC='\033[0m' -echo -e "${BLUE}=== org-agent: Baremetal Power-User Setup ===${NC}" +echo -e "${BLUE}=== opencortex: Baremetal Power-User Setup ===${NC}" if ! command -v sbcl >/dev/null 2>&1; then echo -e "${RED}✗ SBCL not found. Please install it first.${NC}" diff --git a/literate/skills.org b/literate/skills.org index 8b05dab..baea6bb 100644 --- a/literate/skills.org +++ b/literate/skills.org @@ -11,10 +11,10 @@ A static, hardcoded architecture is inherently fragile. To build a autonomous ag Skills unify the **"Why"** (Literate Org documentation) and the **"How"** (Functional Lisp implementation). This allows the harness to "learn" new behaviors without a full system restart, enabling a continuous evolutionary loop where the agent can eventually inspect and improve its own code. *** The True Microkernel (Decoupled Core Skills) -Historically, "core" skills (like State Persistence or Gateways) were statically compiled into the harness for performance. We have fundamentally decoupled this. Now, *all* behavioral skills are pure user-space dynamic modules. They do not tangle to `src/` and are not listed in `org-agent.asd`. The harness simply boots, scans the `skills/` directory, and evaluates the code inside a jailed package. If a user wishes to swap the IPFS persistence skill for an AWS S3 one, they simply swap the `.org` file; no kernel recompilation is required. +Historically, "core" skills (like State Persistence or Gateways) were statically compiled into the harness for performance. We have fundamentally decoupled this. Now, *all* behavioral skills are pure user-space dynamic modules. They do not tangle to `src/` and are not listed in `opencortex.asd`. The harness simply boots, scans the `skills/` directory, and evaluates the code inside a jailed package. If a user wishes to swap the IPFS persistence skill for an AWS S3 one, they simply swap the `.org` file; no kernel recompilation is required. *** Dormant Verification (Tests) -Because skills are no longer statically compiled into the core `org-agent` ASDF system, their associated `FiveAM` test blocks are currently dormant during a standard static build. The tests still exist within the literate `.org` files as verifiable documentation, but executing them requires either dynamic evaluation at runtime or a dedicated test-loader skill. +Because skills are no longer statically compiled into the core `opencortex` ASDF system, their associated `FiveAM` test blocks are currently dormant during a standard static build. The tests still exist within the literate `.org` files as verifiable documentation, but executing them requires either dynamic evaluation at runtime or a dedicated test-loader skill. *** 1. The Package Jailing Principle Every skill is evaluated within its own dedicated Common Lisp package (namespace). This "Jailing" prevents symbol collisions between disparate skills and ensures that a bug in one module cannot easily corrupt the internal state of another. @@ -32,9 +32,9 @@ flowchart TD S3 -- Depends On --> S2 subgraph Jailing[Package Jailing] - P1[Package: ORG-AGENT.SKILLS.S1] - P2[Package: ORG-AGENT.SKILLS.S2] - P3[Package: ORG-AGENT.SKILLS.S3] + P1[Package: OPENCORTEX.SKILLS.S1] + P2[Package: OPENCORTEX.SKILLS.S2] + P3[Package: OPENCORTEX.SKILLS.S3] end S1 --> P1 @@ -46,7 +46,7 @@ flowchart TD We begin by ensuring we are in the correct isolated harness namespace. #+begin_src lisp :tangle ../src/skills.lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src ** Skill Metadata (defstruct skill) @@ -209,8 +209,8 @@ A pre-flight safety check. Before evaluating any code from an Org file, the harn The core "hot-loading" mechanism. It extracts Lisp blocks from an Org file and evaluates them within a "Jail" (an isolated package). *** The Jailing Algorithm: -1. **Isolation:** It generates a package name based on the filename (e.g., ~ORG-AGENT.SKILLS.CORE-LOGIC~). -2. **Namespace Protection:** It inherits external symbols from the ~ORG-AGENT~ package, allowing the skill to use the harness API, but keeps its internal helper functions local. +1. **Isolation:** It generates a package name based on the filename (e.g., ~OPENCORTEX.SKILLS.CORE-LOGIC~). +2. **Namespace Protection:** It inherits external symbols from the ~OPENCORTEX~ package, allowing the skill to use the harness API, but keeps its internal helper functions local. 3. **Block Filtering:** It explicitly ignores blocks that contain ~:tangle~, ensuring that harness-level code (which is already in ~src/~) is not accidentally re-evaluated as skill logic. #+begin_src lisp :tangle ../src/skills.lisp @@ -226,7 +226,7 @@ The core "hot-loading" mechanism. It extracts Lisp blocks from an Org file and e (lines (uiop:split-string content :separator '(#\Newline))) (in-lisp-block nil) (lisp-code "") - (pkg-name (intern (string-upcase (format nil "ORG-AGENT.SKILLS.~a" skill-base-name)) :keyword))) + (pkg-name (intern (string-upcase (format nil "OPENCORTEX.SKILLS.~a" skill-base-name)) :keyword))) (dolist (line lines) (let ((clean-line (string-trim '(#\Space #\Tab #\Return) line))) @@ -253,7 +253,7 @@ The core "hot-loading" mechanism. It extracts Lisp blocks from an Org file and e (harness-log "HARNESS: Jailing skill '~a' in package ~a" skill-base-name pkg-name) (unless (find-package pkg-name) (let ((new-pkg (make-package pkg-name :use '(:cl)))) - (do-external-symbols (sym (find-package :org-agent)) (shadowing-import sym new-pkg)))) + (do-external-symbols (sym (find-package :opencortex)) (shadowing-import sym new-pkg)))) (let ((*read-eval* nil) (*package* (find-package pkg-name))) (eval (read-from-string (format nil "(progn ~a)" lisp-code)))) @@ -398,9 +398,9 @@ The harness provides a baseline set of cognitive tools that enable core system i :guard (lambda (args context) (declare (ignore context)) (let ((code (getf args :code))) - (let ((harness-pkg (find-package :org-agent.skills.org-skill-lisp-validator))) + (let ((harness-pkg (find-package :opencortex.skills.org-skill-lisp-validator))) (if harness-pkg - (uiop:symbol-call :org-agent.skills.org-skill-lisp-validator :lisp-validator-validate code) + (uiop:symbol-call :opencortex.skills.org-skill-lisp-validator :lisp-validator-validate code) t)))) :body (lambda (args) (let ((code (getf args :code))) diff --git a/org-agent.asd b/opencortex.asd similarity index 75% rename from org-agent.asd rename to opencortex.asd index 9b683d3..620fbf4 100644 --- a/org-agent.asd +++ b/opencortex.asd @@ -1,5 +1,5 @@ -(defsystem :org-agent - :name "org-agent" +(defsystem :opencortex + :name "opencortex" :author "Amr" :version "0.1.0" :license "AGPLv3" @@ -17,20 +17,20 @@ (:file "src/deterministic") (:file "src/loop")) :build-operation "program-op" - :build-pathname "org-agent-server" - :entry-point "org-agent:main") + :build-pathname "opencortex-server" + :entry-point "opencortex:main") -(defsystem :org-agent/tests - :depends-on (:org-agent :fiveam) +(defsystem :opencortex/tests + :depends-on (:opencortex :fiveam) :components ((:file "tests/communication-tests") (:file "tests/pipeline-tests") (:file "tests/boot-sequence-tests") (:file "tests/memory-tests") (:file "tests/immune-system-tests")) :perform (test-op (o s) - (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :communication-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* :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* :memory-suite :org-agent-memory-tests)) - (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :immune-suite :org-agent-immune-system-tests)))) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :communication-protocol-suite :opencortex-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :pipeline-suite :opencortex-pipeline-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :safety-suite :opencortex-safety-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :boot-suite :opencortex-boot-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :memory-suite :opencortex-memory-tests)) + (uiop:symbol-call :fiveam :run! (uiop:find-symbol* :immune-suite :opencortex-immune-system-tests)))) diff --git a/org-agent.sh b/opencortex.sh similarity index 89% rename from org-agent.sh rename to opencortex.sh index 4432bdc..1bad761 100755 --- a/org-agent.sh +++ b/opencortex.sh @@ -31,8 +31,8 @@ elif command_exists nc && nc -z $HOST $PORT 2>/dev/null; then fi # 2. Check if we have an existing installation we can boot -if [ -f "$HOME/.org-agent-path" ]; then - INSTALL_DIR=$(cat "$HOME/.org-agent-path") +if [ -f "$HOME/.opencortex-path" ]; then + INSTALL_DIR=$(cat "$HOME/.opencortex-path") if [ -d "$INSTALL_DIR" ] && [ -f "$INSTALL_DIR/docker-compose.yml" ]; then echo -e "${YELLOW}Daemon is offline. Booting from $INSTALL_DIR...${NC}" cd "$INSTALL_DIR" @@ -48,7 +48,7 @@ fi if [ -f "docker-compose.yml" ] && [ -d "literate" ]; then echo -e "${YELLOW}Local repository detected. Ensuring configuration...${NC}" INSTALL_DIR=$(pwd) - echo "$INSTALL_DIR" > "$HOME/.org-agent-path" + echo "$INSTALL_DIR" > "$HOME/.opencortex-path" if [ ! -f .env ]; then cp .env.example .env @@ -91,14 +91,14 @@ fi # 4. Zero-to-One Onboarding (No installation found) echo -e "${BLUE}==================================================${NC}" -echo -e "${BLUE} org-agent: Autonomous Intelligence Onboarding ${NC}" +echo -e "${BLUE} opencortex: Autonomous Intelligence Onboarding ${NC}" echo -e "${BLUE}==================================================${NC}" # --- OS & Docker Detection --- echo -e "\n${BLUE}[1/2] Verifying Environment...${NC}" install_docker() { - echo -e "${YELLOW}Docker is required to run org-agent natively without messy dependencies.${NC}" + echo -e "${YELLOW}Docker is required to run opencortex natively without messy dependencies.${NC}" read -p "Would you like me to attempt to install Docker? [Y/n]: " install_choice install_choice=${install_choice:-Y} if [[ "$install_choice" =~ ^[Yy]$ ]]; then @@ -151,24 +151,24 @@ MEMEX_TARGET=${MEMEX_TARGET:-$MEMEX_DEFAULT} mkdir -p "$MEMEX_TARGET/projects" cd "$MEMEX_TARGET/projects" -if [ ! -d "org-agent" ]; then - echo "Cloning org-agent..." - git clone https://github.com/gharbeia/org-agent.git - cd org-agent +if [ ! -d "opencortex" ]; then + echo "Cloning opencortex..." + git clone https://github.com/gharbeia/opencortex.git + cd opencortex else echo -e "${GREEN}✓ Repository already exists.${NC}" - cd org-agent + cd opencortex git pull origin main fi mkdir -p "$HOME/.local/bin" -ln -sf "$(pwd)/org-agent.sh" "$HOME/.local/bin/org-agent" -echo -e "${GREEN}✓ Installed 'org-agent' command to ~/.local/bin${NC}" +ln -sf "$(pwd)/opencortex.sh" "$HOME/.local/bin/opencortex" +echo -e "${GREEN}✓ Installed 'opencortex' command to ~/.local/bin${NC}" # Ensure proper ownership if sudo was used for apt if [ -n "$SUDO_USER" ]; then - chown -R "$SUDO_USER" "$MEMEX_TARGET/projects/org-agent" + chown -R "$SUDO_USER" "$MEMEX_TARGET/projects/opencortex" fi # Execute the newly cloned script to run configuration (Step 3) -exec ./org-agent.sh +exec ./opencortex.sh diff --git a/org-agent-server b/org-agent-server new file mode 100755 index 0000000..1f2da2a Binary files /dev/null and b/org-agent-server differ diff --git a/scripts/onboard-baremetal.sh b/scripts/onboard-baremetal.sh index bd2b43e..0b27bf3 100755 --- a/scripts/onboard-baremetal.sh +++ b/scripts/onboard-baremetal.sh @@ -2,7 +2,7 @@ set -e RED='\033[0;31m'; GREEN='\033[0;32m'; BLUE='\033[0;34m'; NC='\033[0m' -echo -e "${BLUE}=== org-agent: Baremetal Power-User Setup ===${NC}" +echo -e "${BLUE}=== opencortex: Baremetal Power-User Setup ===${NC}" if ! command -v sbcl >/dev/null 2>&1; then echo -e "${RED}✗ SBCL not found. Please install it first.${NC}" diff --git a/scripts/opencortex-chat.sh b/scripts/opencortex-chat.sh new file mode 100755 index 0000000..eee422a --- /dev/null +++ b/scripts/opencortex-chat.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# opencortex-chat: The terminal mouthpiece for the Autonomous Brain. +PORT=9105 +HOST=${1:-localhost} + +# Check for socat (preferred) +if command -v socat >/dev/null 2>&1; then + # Use socat with READLINE for history and arrow-key support. + # It establishes a persistent bidirectional connection. + socat READLINE,history=$HOME/.org_agent_history TCP:$HOST:$PORT +else + # Fallback to nc (netcat) for a single-shot connection if socat is missing. + # Note: This is less robust for agents with long-thinking times. + echo "WARNING: socat not found. Falling back to nc (no line-editing support)." + while true; do + read -p "User: " MESSAGE + if [ -z "$MESSAGE" ]; then continue; fi + echo "$MESSAGE" | nc -N $HOST $PORT + done +fi diff --git a/scripts/org-agent-chat.sh b/scripts/org-agent-chat.sh index 7fe32ec..eee422a 100755 --- a/scripts/org-agent-chat.sh +++ b/scripts/org-agent-chat.sh @@ -1,5 +1,5 @@ #!/bin/bash -# org-agent-chat: The terminal mouthpiece for the Autonomous Brain. +# opencortex-chat: The terminal mouthpiece for the Autonomous Brain. PORT=9105 HOST=${1:-localhost} diff --git a/skills/org-skill-bouncer.org b/skills/org-skill-bouncer.org index 76ae4bc..6f7139f 100644 --- a/skills/org-skill-bouncer.org +++ b/skills/org-skill-bouncer.org @@ -12,7 +12,7 @@ The *Deterministic Engine Bouncer* is the authorization gate for high-risk actio * Package Context #+begin_src lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src * Deep Packet Inspection (DPI) diff --git a/skills/org-skill-chat.org b/skills/org-skill-chat.org index 6cbfe83..36c72a3 100644 --- a/skills/org-skill-chat.org +++ b/skills/org-skill-chat.org @@ -8,7 +8,7 @@ #+FILETAGS: :chat:conversational:ui:autonomy: * Overview -The *Chat Agent* provides a dedicated conversational interface within Emacs (`*org-agent-chat*`). It enables fluid dialogue while maintaining strict persona alignment and contextual awareness. +The *Chat Agent* provides a dedicated conversational interface within Emacs (`*opencortex-chat*`). It enables fluid dialogue while maintaining strict persona alignment and contextual awareness. * Phase A: Demand (PRD) :PROPERTIES: @@ -101,11 +101,11 @@ Interfaces for conversational event handling and UI integration. Source of truth (chat-archive-message (getf payload :text) :role :agent :channel target :chat-id (or (getf payload :chat-id) (getf payload :room-id)))) proposed-action) (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)))))) + `(:type :request :target :emacs :payload (:action :insert-at-end :buffer "*opencortex-chat*" :text ,err-text)))))) #+end_src ** Neural Response Generation -The Chat skill acts as the conversational UI. Because the ~org-agent~ kernel evaluates LLM output via ~read-from-string~ (expecting a valid s-expression) and the chat verifier strictly expects an Emacs ~:insert-at-end~ actuation, we must explicitly mandate that the LLM wraps its conversational output in a Common Lisp property list. +The Chat skill acts as the conversational UI. Because the ~opencortex~ 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 (defun probabilistic-skill-chat (context) @@ -125,9 +125,9 @@ 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)) (:cli (format nil "- To reply via CLI: (:type :REQUEST :target :cli :text \"\")")) - (t "- To reply via Emacs: (:type :REQUEST :target :emacs :action :insert-at-end :buffer \"*org-agent-chat*\" :text \"* \")")))) + (t "- To reply via Emacs: (:type :REQUEST :target :emacs :action :insert-at-end :buffer \"*opencortex-chat*\" :text \"* \")")))) (ask-probabilistic trimmed-text :system-prompt (concatenate 'string - "ACTUATOR IDENTITY: You are the pure Lisp actuator for the org-agent kernel. + "ACTUATOR IDENTITY: You are the pure Lisp actuator for the opencortex kernel. MANDATE: Output EXACTLY ONE Common Lisp property list starting with (:type :REQUEST). ZERO CONVERSATION: Do not explain. Do not use markdown. STRICT RULE: Never output the strings 'Unknown request' or 'System Error'. diff --git a/skills/org-skill-cli-gateway.org b/skills/org-skill-cli-gateway.org index 0c3e830..905db74 100644 --- a/skills/org-skill-cli-gateway.org +++ b/skills/org-skill-cli-gateway.org @@ -7,7 +7,7 @@ #+FILETAGS: :gateway:cli:io:autonomy: * Overview -The *CLI Gateway* is the primary interaction point for the Org-Agent MVP. It provides a lightweight TCP socket server that allows local terminal clients to communicate with the daemon. It ensures a frictionless "First Contact" experience immediately following installation. +The *CLI Gateway* is the primary interaction point for the OpenCortex MVP. It provides a lightweight TCP socket server that allows local terminal clients to communicate with the daemon. It ensures a frictionless "First Contact" experience immediately following installation. * Phase A: Demand (PRD) :PROPERTIES: @@ -15,7 +15,7 @@ The *CLI Gateway* is the primary interaction point for the Org-Agent MVP. It pro :END: ** 1. Purpose -Provide a secure, local, and low-latency terminal interface for the Org-Agent. +Provide a secure, local, and low-latency terminal interface for the OpenCortex. ** 2. Success Criteria - [X] *Ingress:* Accept plain-text messages over TCP port 9105. @@ -39,7 +39,7 @@ The gateway runs a multi-threaded TCP server. Each connection is handled in its ** Package Context #+begin_src lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src ** State: Server Control @@ -110,9 +110,9 @@ Listens for new TCP connections on the configured port. (bt:make-thread (lambda () (unwind-protect (handle-cli-client stream) (usocket:socket-close socket))) - :name "org-agent-cli-client-handler"))) + :name "opencortex-cli-client-handler"))) (usocket:socket-close *cli-server-socket*))) - :name "org-agent-cli-gateway")) + :name "opencortex-cli-gateway")) (harness-log "CLI: Gateway listening on port ~a" port)) #+end_src @@ -136,8 +136,8 @@ Listens for new TCP connections on the configured port. We tangle a lightweight client script that the user can run on their host machine. ** The Bash Client -#+begin_src bash :tangle ../scripts/org-agent-chat.sh :shebang "#!/bin/bash" -# org-agent-chat: The terminal mouthpiece for the Autonomous Brain. +#+begin_src bash :tangle ../scripts/opencortex-chat.sh :shebang "#!/bin/bash" +# opencortex-chat: The terminal mouthpiece for the Autonomous Brain. PORT=9105 HOST=${1:-localhost} diff --git a/skills/org-skill-consensus.org b/skills/org-skill-consensus.org index 6942fde..3fcfdca 100644 --- a/skills/org-skill-consensus.org +++ b/skills/org-skill-consensus.org @@ -9,7 +9,7 @@ #+DEPENDS_ON: skill-sub-agent-manager * Overview -The *Social Consensus Protocol* enables multi-agent negotiation. It provides a Lisp-native implementation of decentralized agreement, allowing federated `org-agent` instances to coordinate on shared resources and conflicting goals. +The *Social Consensus Protocol* enables multi-agent negotiation. It provides a Lisp-native implementation of decentralized agreement, allowing federated `opencortex` instances to coordinate on shared resources and conflicting goals. * Phase A: Demand (PRD) :PROPERTIES: @@ -30,10 +30,10 @@ Enable reliable, cross-instance coordination without a central master. #+begin_src lisp (defun consensus-propose-vote (proposal) "Broadcasts a proposal to the peer swarm and collects votes. - Implements org-agent Social Consensus Protocol." + Implements opencortex Social Consensus Protocol." (let* ((peers (get-swarm-peer-list)) (votes (loop for peer in peers - collect (org-agent:send-swarm-packet peer `(:type :REQUEST :action :vote :proposal ,proposal))))) + collect (opencortex:send-swarm-packet peer `(:type :REQUEST :action :vote :proposal ,proposal))))) (if (> (count :YES votes) (/ (length peers) 2)) t ; Consensus reached nil))) @@ -60,7 +60,7 @@ Enable reliable, cross-instance coordination without a central master. :END: ** 1. Architectural Intent - The consensus protocol should be implemented as a swarm behavior modeled after Raft, but simplified for the constraints of the `org-agent` ecosystem (i.e. eventual consistency, potentially unreliable messaging). The architecture should allow for future extensions, such as dynamically adjusting the voting threshold based on swarm size or node reputation. We use gossip protocols for state sharing. + The consensus protocol should be implemented as a swarm behavior modeled after Raft, but simplified for the constraints of the `opencortex` ecosystem (i.e. eventual consistency, potentially unreliable messaging). The architecture should allow for future extensions, such as dynamically adjusting the voting threshold based on swarm size or node reputation. We use gossip protocols for state sharing. ** 2. Semantic Interfaces diff --git a/skills/org-skill-credentials-vault.org b/skills/org-skill-credentials-vault.org index 5788771..da88a0d 100644 --- a/skills/org-skill-credentials-vault.org +++ b/skills/org-skill-credentials-vault.org @@ -8,7 +8,7 @@ #+DEPENDS_ON: id:state-persistence-skill * Overview -The *Credentials Vault* is the high-security enclave for the Org-Agent. It centralizes the management of LLM API keys, OAuth sessions, and browser cookies. By consolidating these into a single vault, we ensure that sensitive tokens are handled with uniform masking, validation, and Merkle-integrated persistence. +The *Credentials Vault* is the high-security enclave for the OpenCortex. It centralizes the management of LLM API keys, OAuth sessions, and browser cookies. By consolidating these into a single vault, we ensure that sensitive tokens are handled with uniform masking, validation, and Merkle-integrated persistence. * Phase A: Demand (PRD) :PROPERTIES: @@ -16,7 +16,7 @@ The *Credentials Vault* is the high-security enclave for the Org-Agent. It centr :END: ** 1. Purpose -Securely manage all authentication tokens required for the org-agent to operate. +Securely manage all authentication tokens required for the opencortex to operate. ** 2. User Needs - *Unified Storage:* Single interface for API keys and Session Cookies. @@ -152,22 +152,22 @@ Retained from the legacy Google skill, this provides the instructions for the au ** 1. Unit Tests (FiveAM) #+begin_src lisp -(defpackage :org-agent-vault-tests - (:use :cl :fiveam :org-agent)) -(in-package :org-agent-vault-tests) +(defpackage :opencortex-vault-tests + (:use :cl :fiveam :opencortex)) +(in-package :opencortex-vault-tests) (def-suite vault-suite :description "Tests for the Credentials Vault.") (in-suite vault-suite) (test test-masking - (is (equal "sk-t...-key" (org-agent::vault-mask-string "sk-test-key"))) - (is (equal "[REDACTED]" (org-agent::vault-mask-string "short")))) + (is (equal "sk-t...-key" (opencortex::vault-mask-string "sk-test-key"))) + (is (equal "[REDACTED]" (opencortex::vault-mask-string "short")))) (test test-vault-persistence "Verify that setting a secret triggers a snapshot (mock check)." - (let ((old-version (org-agent::org-object-version (gethash "root" *memory*)))) - (org-agent:vault-set-secret :test "secret-val") - (is (> (org-agent::org-object-version (gethash "root" *memory*)) old-version)))) + (let ((old-version (opencortex::org-object-version (gethash "root" *memory*)))) + (opencortex:vault-set-secret :test "secret-val") + (is (> (opencortex::org-object-version (gethash "root" *memory*)) old-version)))) #+end_src ** 2. Chaos Scenarios diff --git a/skills/org-skill-embedding.org b/skills/org-skill-embedding.org index 9719da7..e515f3c 100644 --- a/skills/org-skill-embedding.org +++ b/skills/org-skill-embedding.org @@ -7,7 +7,7 @@ #+FILETAGS: :embedding:vector-search:semantic:autonomy: * Overview -The *Vector Embedding* skill provides semantic search and vectorization capabilities to the org-agent. It decouples the specific embedding algorithms and provider-specific API calls from the core kernel. +The *Vector Embedding* skill provides semantic search and vectorization capabilities to the opencortex. It decouples the specific embedding algorithms and provider-specific API calls from the core kernel. * Phase A: Demand (PRD) :PROPERTIES: diff --git a/skills/org-skill-engineering-standards.org b/skills/org-skill-engineering-standards.org index 0ec6477..0e6b436 100644 --- a/skills/org-skill-engineering-standards.org +++ b/skills/org-skill-engineering-standards.org @@ -73,7 +73,7 @@ The Engineering Standards skill provides the deterministic enforcement of the wo ;; If the action involves modifying files, check git status (when (member act '(:modify-file :write-file :replace :rename-file :delete-file)) - (let ((proj-root (asdf:system-source-directory :org-agent))) + (let ((proj-root (asdf:system-source-directory :opencortex))) (unless (verify-git-clean-p proj-root) (harness-log "DETERMINISTIC [Standards]: BLOCKING ACTION. Working tree is dirty. Commit changes before modification.") (return-from engineering-standards-gate @@ -84,4 +84,4 @@ The Engineering Standards skill provides the deterministic enforcement of the wo * See Also - [[file:org-skill-system-invariants.org][System Policy]] -- [[file:../README.org][org-agent README]] +- [[file:../README.org][opencortex README]] diff --git a/skills/org-skill-event-orchestrator.org b/skills/org-skill-event-orchestrator.org index c4bf35d..a9a0ee3 100644 --- a/skills/org-skill-event-orchestrator.org +++ b/skills/org-skill-event-orchestrator.org @@ -8,7 +8,7 @@ #+DEPENDS_ON: id:state-persistence-skill * Overview -The *Event Orchestrator* is the central nervous system of the Org-Agent. It unifies three previously fragmented domains of system control: +The *Event Orchestrator* is the central nervous system of the OpenCortex. It unifies three previously fragmented domains of system control: 1. **Cron (Temporal Control):** Triggering tasks based on time and heartbeats. 2. **Hooks (Lifecycle Control):** Enabling event-driven extensibility at specific code points. 3. **Routing (Cognitive Control):** Classifying incoming stimuli into complexity tiers for optimal resource allocation. @@ -164,7 +164,7 @@ We register the orchestrator as a core skill and hot-patch the harness's routing #+begin_src lisp (progn ;; Hook into kernel routing - (setf org-agent::*model-selector-fn* #'orchestrator-classify-complexity) + (setf opencortex::*model-selector-fn* #'orchestrator-classify-complexity) (defskill :skill-event-orchestrator :priority 400 ; Foundational control layer @@ -179,22 +179,22 @@ We register the orchestrator as a core skill and hot-patch the harness's routing ** 1. Unit Tests (FiveAM) #+begin_src lisp -(defpackage :org-agent-orchestrator-tests - (:use :cl :fiveam :org-agent)) -(in-package :org-agent-orchestrator-tests) +(defpackage :opencortex-orchestrator-tests + (:use :cl :fiveam :opencortex)) +(in-package :opencortex-orchestrator-tests) (def-suite orchestrator-suite :description "Tests for Event Orchestrator.") (in-suite orchestrator-suite) (test test-hook-execution (let ((test-val 0)) - (org-agent:orchestrator-register-hook :test-hook (lambda () (setf test-val 1))) - (org-agent:orchestrator-trigger-hook :test-hook) + (opencortex:orchestrator-register-hook :test-hook (lambda () (setf test-val 1))) + (opencortex:orchestrator-trigger-hook :test-hook) (is (= 1 test-val)))) (test test-routing-reflex (let ((ctx '(:payload (:sensor :heartbeat)))) - (is (eq :REFLEX (org-agent:orchestrator-classify-complexity ctx))))) + (is (eq :REFLEX (opencortex:orchestrator-classify-complexity ctx))))) #+end_src ** 2. Chaos Scenarios diff --git a/skills/org-skill-gardener.org b/skills/org-skill-gardener.org index bc71d4c..c0d4edd 100644 --- a/skills/org-skill-gardener.org +++ b/skills/org-skill-gardener.org @@ -38,7 +38,7 @@ The Gardener runs on a low-priority heartbeat. It performs a "Deep Audit" of the ** Package Context #+begin_src lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src ** State: Maintenance Cycle diff --git a/skills/org-skill-gateway-matrix.org b/skills/org-skill-gateway-matrix.org index c6f72cb..12a5efe 100644 --- a/skills/org-skill-gateway-matrix.org +++ b/skills/org-skill-gateway-matrix.org @@ -16,7 +16,7 @@ The *Matrix Gateway* provides bi-directional communication via the Matrix Client :END: ** 1. Purpose -Integrate the Org-Agent into the Matrix federation for secure, distributed chat. +Integrate the OpenCortex into the Matrix federation for secure, distributed chat. ** 2. Success Criteria - [ ] *Inbound:* Messages from Matrix rooms are normalized and injected into the harness Bus. @@ -147,7 +147,7 @@ Initializes the Matrix background thread. (loop (matrix-process-sync) (sleep 2))) - :name "org-agent-matrix-gateway")) + :name "opencortex-matrix-gateway")) (harness-log "MATRIX: Gateway sync active."))) #+end_src diff --git a/skills/org-skill-gateway-signal.org b/skills/org-skill-gateway-signal.org index 1a48890..3e2e12c 100644 --- a/skills/org-skill-gateway-signal.org +++ b/skills/org-skill-gateway-signal.org @@ -8,7 +8,7 @@ #+DEPENDS_ON: id:credentials-vault-skill * Overview -The *Signal Gateway* provides bi-directional communication between the Autonomous and the Org-Agent via the `signal-cli` tool. It features a non-blocking polling sensor and a high-integrity actuator for outbound messaging. +The *Signal Gateway* provides bi-directional communication between the Autonomous and the OpenCortex via the `signal-cli` tool. It features a non-blocking polling sensor and a high-integrity actuator for outbound messaging. * Phase A: Demand (PRD) :PROPERTIES: @@ -16,7 +16,7 @@ The *Signal Gateway* provides bi-directional communication between the Autonomou :END: ** 1. Purpose -Enable secure Signal communication for the Org-Agent. +Enable secure Signal communication for the OpenCortex. ** 2. Success Criteria - [ ] *Inbound:* Messages received via `signal-cli receive` are injected into the harness Bus. @@ -117,7 +117,7 @@ Initializes the Signal background thread. (loop (signal-process-updates) (sleep 5))) - :name "org-agent-signal-gateway")) + :name "opencortex-signal-gateway")) (harness-log "SIGNAL: Gateway polling active."))) #+end_src diff --git a/skills/org-skill-gateway-telegram.org b/skills/org-skill-gateway-telegram.org index 18b5235..1ddb5f3 100644 --- a/skills/org-skill-gateway-telegram.org +++ b/skills/org-skill-gateway-telegram.org @@ -8,7 +8,7 @@ #+DEPENDS_ON: id:credentials-vault-skill * Overview -The *Telegram Gateway* provides bi-directional communication between the Autonomous and the Org-Agent via the Telegram Bot API. It features a non-blocking polling sensor and a high-integrity actuator for outbound messaging. +The *Telegram Gateway* provides bi-directional communication between the Autonomous and the OpenCortex via the Telegram Bot API. It features a non-blocking polling sensor and a high-integrity actuator for outbound messaging. * Phase A: Demand (PRD) :PROPERTIES: @@ -16,7 +16,7 @@ The *Telegram Gateway* provides bi-directional communication between the Autonom :END: ** 1. Purpose -Enable mobile/remote access to the Org-Agent via a secure Telegram bot. +Enable mobile/remote access to the OpenCortex via a secure Telegram bot. ** 2. Success Criteria - [ ] *Inbound:* Messages from authorized Telegram IDs are injected into the harness Bus. @@ -133,7 +133,7 @@ Initializes the Telegram background thread. (loop (telegram-process-updates) (sleep 3))) - :name "org-agent-telegram-gateway")) + :name "opencortex-telegram-gateway")) (harness-log "TELEGRAM: Gateway polling active."))) #+end_src diff --git a/skills/org-skill-harness-monitor.org b/skills/org-skill-harness-monitor.org index e8f6f2d..5df4395 100644 --- a/skills/org-skill-harness-monitor.org +++ b/skills/org-skill-harness-monitor.org @@ -8,13 +8,13 @@ #+DEPENDS_ON: id:47425a43-2be0-423c-8509-22592cfe9c9e * Overview -The *Harness Monitor* provides tools for inspecting the internal state and health of the Org-Agent Lisp Machine. +The *Harness Monitor* provides tools for inspecting the internal state and health of the OpenCortex Lisp Machine. * Implementation #+begin_src lisp -(org-agent:def-cognitive-tool :harness-status \"Returns the current operational status of the Org-Agent harness, including loaded skills and telemetry.\" +(opencortex:def-cognitive-tool :harness-status \"Returns the current operational status of the OpenCortex harness, including loaded skills and telemetry.\" nil :body (lambda (args) (declare (ignore args)) @@ -23,12 +23,12 @@ The *Harness Monitor* provides tools for inspecting the internal state and healt - Uptime: ~a seconds - Memory Usage: ~a - Providers: ~a\" - (hash-table-count org-agent:*skills-registry*) + (hash-table-count opencortex:*skills-registry*) (get-universal-time) \"Not implemented\" - org-agent:*provider-cascade*))) + opencortex:*provider-cascade*))) -(org-agent:def-cognitive-tool :list-skills \"Lists all currently loaded skills and their metadata.\" +(opencortex:def-cognitive-tool :list-skills \"Lists all currently loaded skills and their metadata.\" nil :body (lambda (args) (declare (ignore args)) @@ -38,9 +38,9 @@ The *Harness Monitor* provides tools for inspecting the internal state and healt (setf output (concatenate 'string output (format nil \"- ~a (Priority: ~a, Deps: ~s)~%\" name - (org-agent:skill-priority skill) - (org-agent:skill-dependencies skill))))) - org-agent:*skills-registry*) + (opencortex:skill-priority skill) + (opencortex:skill-dependencies skill))))) + opencortex:*skills-registry*) output))) (defskill :skill-harness-monitor diff --git a/skills/org-skill-homoiconic-memory.org b/skills/org-skill-homoiconic-memory.org index a823dbc..374104d 100644 --- a/skills/org-skill-homoiconic-memory.org +++ b/skills/org-skill-homoiconic-memory.org @@ -94,7 +94,7 @@ Ensures every headline has a unique ID property using the system standard `org-i (id (getf props :ID))) (if (and id (not (equal id ""))) node - (let ((new-id (org-agent:org-id-get-create))) + (let ((new-id (opencortex:org-id-get-create))) (setf (getf node :properties) (append props (list :ID new-id))) (harness-log "MEMORY - Injected standard ID ~a" new-id) node)))) @@ -159,16 +159,16 @@ Converts a structured AST back into Org-mode text. ** 1. Unit Tests (FiveAM) #+begin_src lisp -(defpackage :org-agent-memory-tests - (:use :cl :fiveam :org-agent)) -(in-package :org-agent-memory-tests) +(defpackage :opencortex-memory-tests + (:use :cl :fiveam :opencortex)) +(in-package :opencortex-memory-tests) (def-suite memory-suite :description "Tests for Homoiconic Memory.") (in-suite memory-suite) (test test-id-injection (let* ((node (list :type :HEADLINE :properties nil)) - (normalized (org-agent::memory-ensure-id node))) + (normalized (opencortex::memory-ensure-id node))) (is (not (null (getf (getf normalized :properties) :ID)))))) #+end_src diff --git a/skills/org-skill-lisp-validator.org b/skills/org-skill-lisp-validator.org index 7d2f40e..c28735b 100644 --- a/skills/org-skill-lisp-validator.org +++ b/skills/org-skill-lisp-validator.org @@ -52,28 +52,28 @@ Define a high-integrity, recursive security sandbox for Lisp execution. ;; Strings format concatenate string-downcase string-upcase search ;; Kernel specifics - org-agent::harness-log - org-agent::snapshot-memory - org-agent::rollback-memory - org-agent::lookup-object - org-agent::list-objects-by-type - org-agent::ingest-ast - org-agent::find-headline-missing-id - org-agent::context-query-store - org-agent::context-get-active-projects - org-agent::context-get-recent-completed-tasks - org-agent::context-list-all-skills - org-agent::context-get-system-logs - org-agent::context-assemble-global-awareness - org-agent::org-object-id - org-agent::org-object-type - org-agent::org-object-attributes - org-agent::org-object-content - org-agent::org-object-parent-id - org-agent::org-object-children - org-agent::org-object-version - org-agent::org-object-last-sync - org-agent::org-object-hash + opencortex::harness-log + opencortex::snapshot-memory + opencortex::rollback-memory + opencortex::lookup-object + opencortex::list-objects-by-type + opencortex::ingest-ast + opencortex::find-headline-missing-id + opencortex::context-query-store + opencortex::context-get-active-projects + opencortex::context-get-recent-completed-tasks + opencortex::context-list-all-skills + opencortex::context-get-system-logs + opencortex::context-assemble-global-awareness + opencortex::org-object-id + opencortex::org-object-type + opencortex::org-object-attributes + opencortex::org-object-content + opencortex::org-object-parent-id + opencortex::org-object-children + opencortex::org-object-version + opencortex::org-object-last-sync + opencortex::org-object-hash ;; Essential macros declare ignore ;; Let's also add simple data types @@ -125,7 +125,7 @@ We allow other skills to register safe symbols for the validator. ** Cognitive Tools #+begin_src lisp -(org-agent:def-cognitive-tool :lisp-validator-status "Returns validator-related telemetry, including blocked actions and harness status." +(opencortex:def-cognitive-tool :lisp-validator-status "Returns validator-related telemetry, including blocked actions and harness status." nil :body (lambda (args) (declare (ignore args)) @@ -140,7 +140,7 @@ We allow other skills to register safe symbols for the validator. ** Skill Definition #+begin_src lisp -(org-agent:defskill :skill-lisp-validator +(opencortex:defskill :skill-lisp-validator :priority 900 ; High priority, before most skills :trigger (lambda (ctx) ;; Check if any proposed action is an :eval or :shell call @@ -157,26 +157,26 @@ We allow other skills to register safe symbols for the validator. * Phase E: Chaos (Verification) #+begin_src lisp -(defpackage :org-agent-lisp-validator-tests - (:use :cl :fiveam :org-agent) +(defpackage :opencortex-lisp-validator-tests + (:use :cl :fiveam :opencortex) (:export #:lisp-validator-suite)) -(in-package :org-agent-lisp-validator-tests) +(in-package :opencortex-lisp-validator-tests) (def-suite lisp-validator-suite :description "Tests for the Lisp Validator.") (in-suite lisp-validator-suite) (test test-basic-math-safe - (is (org-agent:lisp-validator-validate "(+ 1 2)"))) + (is (opencortex:lisp-validator-validate "(+ 1 2)"))) (test test-blocked-eval - (is (not (org-agent:lisp-validator-validate "(eval '(+ 1 2))")))) + (is (not (opencortex:lisp-validator-validate "(eval '(+ 1 2))")))) (test test-blocked-shell - (is (not (org-agent:lisp-validator-validate "(uiop:run-program \"ls\")")))) + (is (not (opencortex:lisp-validator-validate "(uiop:run-program \"ls\")")))) (test test-nested-unsafe - (is (not (org-agent:lisp-validator-validate "(let ((x 1)) (delete-file \"test.txt\"))")))) + (is (not (opencortex:lisp-validator-validate "(let ((x 1)) (delete-file \"test.txt\"))")))) (test test-safe-kernel-api - (is (org-agent:lisp-validator-validate "(org-agent::lookup-object \"node-1\")"))) + (is (opencortex:lisp-validator-validate "(opencortex::lookup-object \"node-1\")"))) #+end_src diff --git a/skills/org-skill-llm-gateway.org b/skills/org-skill-llm-gateway.org index 5648c4c..cb2c5c1 100644 --- a/skills/org-skill-llm-gateway.org +++ b/skills/org-skill-llm-gateway.org @@ -92,7 +92,7 @@ This is the primary actuator for neural reasoning. It handles the specific JSON (case provider (:gemini-web - (let ((res (uiop:symbol-call :org-agent.skills.org-skill-web-research :ask-gemini-web full-prompt))) + (let ((res (uiop:symbol-call :opencortex.skills.org-skill-web-research :ask-gemini-web full-prompt))) (if res (list :status :success :content res) (list :status :error :message "Web Research Failure")))) (:ollama @@ -118,7 +118,7 @@ This is the primary actuator for neural reasoning. It handles the specific JSON (:anthropic `(("Content-Type" . "application/json") ("x-api-key" . ,api-key) ("anthropic-version" . "2023-06-01"))) (:gemini-api `(("Content-Type" . "application/json") ("x-goog-api-key" . ,api-key))) (:openrouter `(("Content-Type" . "application/json") ("Authorization" . ,(format nil "Bearer ~a" api-key)) - ("HTTP-Referer" . "https://github.com/amr/org-agent") ("X-Title" . "org-agent Autonomous Kernel"))) + ("HTTP-Referer" . "https://github.com/amr/opencortex") ("X-Title" . "opencortex Autonomous Kernel"))) (t `(("Content-Type" . "application/json") ("Authorization" . ,(format nil "Bearer ~a" api-key)))))) (body (case provider (:anthropic (cl-json:encode-json-to-string `((model . ,(or model "claude-3-5-sonnet-20240620")) (max_tokens . 4096) (system . ,system-prompt) (messages . (( (role . "user") (content . ,prompt) )))))) @@ -160,7 +160,7 @@ Register each supported provider with the harness's neural registry. #+begin_src lisp (dolist (p '(:anthropic :gemini-api :gemini-web :groq :ollama :openai :openrouter)) - (org-agent:register-probabilistic-backend p (lambda (prompt system-prompt &key model) + (opencortex:register-probabilistic-backend p (lambda (prompt system-prompt &key model) (execute-llm-request prompt system-prompt :provider p :model model)))) #+end_src diff --git a/skills/org-skill-onboarding.org b/skills/org-skill-onboarding.org index ed482b5..981b8ec 100644 --- a/skills/org-skill-onboarding.org +++ b/skills/org-skill-onboarding.org @@ -16,7 +16,7 @@ The *Onboarding Skill* ensures that the Lisp Machine environment is correctly ca :END: ** 1. Purpose -Define automated behaviors for verifying and configuring the org-agent environment. +Define automated behaviors for verifying and configuring the opencortex environment. ** 2. User Needs - *Environment Verification:* Confirm SBCL, Quicklisp, and core binaries are present. diff --git a/skills/org-skill-policy-enforcer.org b/skills/org-skill-policy-enforcer.org index bd0d53b..06ac9c3 100644 --- a/skills/org-skill-policy-enforcer.org +++ b/skills/org-skill-policy-enforcer.org @@ -11,7 +11,7 @@ The *Policy Enforcer* is the deterministic gate that ensures all probabilistic proposals adhere to the Core Invariants defined in the [[id:47425a43-2be0-423c-8509-22592cfe9c9e][System Policy]]. ** Architectural Intent: The Implicit Bridge -Unlike traditional software where a "Kernel" might have hardcoded rules, the Org-Agent harness is a "dumb" pipeline. This skill creates the bridge between human-readable rules and machine-enforced constraints through three mechanisms: +Unlike traditional software where a "Kernel" might have hardcoded rules, the OpenCortex harness is a "dumb" pipeline. This skill creates the bridge between human-readable rules and machine-enforced constraints through three mechanisms: 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. @@ -25,13 +25,13 @@ Unlike traditional software where a "Kernel" might have hardcoded rules, the Org :priority 1000 ; Absolute highest priority :trigger (lambda (context) t) ; Always active as a fallback :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.\") + \"You are the OpenCortex Policy Enforcer. Your goal is to ensure all actions empower the user through the Lisp Machine and adhere to the System Policy.\") :deterministic (lambda (action context) ;; Basic invariant check: Block actions that appear to violate autonomy (let ((payload (getf action :payload))) (if (and payload (search \"proprietary\" (format nil \"~s\" payload))) (progn - (org-agent:harness-log \"DETERMINISTIC [Policy]: Autonomy violation suspected. Blocking action.\") + (opencortex:harness-log \"DETERMINISTIC [Policy]: Autonomy violation suspected. Blocking action.\") nil) action)))) #+end_src diff --git a/skills/org-skill-policy.org b/skills/org-skill-policy.org index 2dea62f..61294fe 100644 --- a/skills/org-skill-policy.org +++ b/skills/org-skill-policy.org @@ -8,13 +8,13 @@ #+FILETAGS: :platform:policy:alignment:autonomy: * Overview -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. +The *opencortex* 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. * Package Context Every skill executes within its own jailed package namespace, while inheriting core harness symbols. #+begin_src lisp :tangle ../src/policy.lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src * The Core Invariants @@ -52,7 +52,7 @@ The main deterministic entry point for the policy skill. It orchestrates the var "The main policy gate. Sub-calls engineering standards if available." (let ((current-action (policy-check-autonomy action context))) (when current-action - (let ((eng-pkg (find-package :org-agent.skills.org-skill-engineering-standards))) + (let ((eng-pkg (find-package :opencortex.skills.org-skill-engineering-standards))) (when eng-pkg (let ((eng-gate (find-symbol "ENGINEERING-STANDARDS-GATE" eng-pkg))) (when (and eng-gate (fboundp eng-gate)) diff --git a/skills/org-skill-protocol-validator.org b/skills/org-skill-protocol-validator.org index f4dd541..a5fbbb2 100644 --- a/skills/org-skill-protocol-validator.org +++ b/skills/org-skill-protocol-validator.org @@ -7,7 +7,7 @@ #+FILETAGS: :protocol:communication-protocol:security:validation:autonomy: * Overview -The *Communication 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 *Communication Protocol Schema Validator* skill provides deep structural validation for all messages entering the opencortex 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 *Communication Protocol Schema Validator* skill provides deep structural val :END: ** 1. Purpose -Enforce a formal grammar for the Org-Agent Control Protocol (communication protocol). +Enforce a formal grammar for the OpenCortex Control Protocol (communication protocol). ** 2. User Needs - *Type Safety:* Ensure mandatory keys (e.g., `:type`, `:payload`) are present. @@ -46,7 +46,7 @@ Decouple protocol parsing (framing/unframing) from semantic validation. ** Schema Enforcement #+begin_src lisp :tangle ../src/communication-validator.lisp -(in-package :org-agent) +(in-package :opencortex) (defun validate-communication-protocol-schema (msg) "Strict structural validation for incoming communication protocol messages." diff --git a/skills/org-skill-scribe.org b/skills/org-skill-scribe.org index 2f0f238..ad9dc05 100644 --- a/skills/org-skill-scribe.org +++ b/skills/org-skill-scribe.org @@ -42,7 +42,7 @@ The Scribe reacts to the `:heartbeat` sensor. It maintains a state file (`scribe ** Package Context #+begin_src lisp -(in-package :org-agent) +(in-package :opencortex) #+end_src ** State: Checkpoint Management @@ -54,14 +54,14 @@ We track the last processed universal time to avoid redundant distillation. (defun scribe-load-state () "Loads the scribe checkpoint from the state directory." - (let ((state-file (uiop:merge-pathnames* "state/scribe-checkpoint.lisp" (asdf:system-source-directory :org-agent)))) + (let ((state-file (uiop:merge-pathnames* "state/scribe-checkpoint.lisp" (asdf:system-source-directory :opencortex)))) (if (uiop:file-exists-p state-file) (setf *scribe-last-checkpoint* (read-from-string (uiop:read-file-string state-file))) (setf *scribe-last-checkpoint* 0)))) (defun scribe-save-state () "Saves the current universal-time as the new checkpoint." - (let ((state-file (uiop:merge-pathnames* "state/scribe-checkpoint.lisp" (asdf:system-source-directory :org-agent)))) + (let ((state-file (uiop:merge-pathnames* "state/scribe-checkpoint.lisp" (asdf:system-source-directory :opencortex)))) (ensure-directories-exist state-file) (with-open-file (out state-file :direction :output :if-exists :supersede) (format out "~a" (get-universal-time))))) @@ -125,7 +125,7 @@ The deterministic gate receives the list of proposed notes and writes them to th #+begin_src lisp (defun scribe-commit-notes (proposals) "Writes proposed atomic notes to the notes/ directory. Appends if the note exists." - (let ((notes-dir (uiop:merge-pathnames* "notes/" (asdf:system-source-directory :org-agent)))) + (let ((notes-dir (uiop:merge-pathnames* "notes/" (asdf:system-source-directory :opencortex)))) (ensure-directories-exist notes-dir) (dolist (note proposals) (let* ((title (getf note :title)) diff --git a/skills/org-skill-self-fix.org b/skills/org-skill-self-fix.org index edc7ed6..066a358 100644 --- a/skills/org-skill-self-fix.org +++ b/skills/org-skill-self-fix.org @@ -27,8 +27,8 @@ The *Self-Fix Agent* is the system's "Repair Mechanism." It takes failure hypoth (is-skill (and (stringp (namestring target-file)) (search "skills/" (namestring target-file))))) - (org-agent:snapshot-memory) - (org-agent:harness-log "SELF-FIX - Attempting surgical fix on ~a..." target-file) + (opencortex:snapshot-memory) + (opencortex:harness-log "SELF-FIX - Attempting surgical fix on ~a..." target-file) (handler-case (if (uiop:file-exists-p target-file) @@ -40,25 +40,25 @@ The *Self-Fix Agent* is the system's "Repair Mechanism." It takes failure hypoth (if is-skill (progn - (org-agent:harness-log "SELF-FIX - Reloading modified skill ~a..." target-file) - (if (org-agent:load-skill-from-org target-file) + (opencortex:harness-log "SELF-FIX - Reloading modified skill ~a..." target-file) + (if (opencortex:load-skill-from-org target-file) (progn - (org-agent:harness-log "SELF-FIX SUCCESS - Applied and reloaded.") + (opencortex:harness-log "SELF-FIX SUCCESS - Applied and reloaded.") t) (progn - (org-agent:harness-log "SELF-FIX FAILURE - Skill reload failed. Rolling back.") + (opencortex:harness-log "SELF-FIX FAILURE - Skill reload failed. Rolling back.") (with-open-file (out target-file :direction :output :if-exists :supersede) (write-string content out)) - (org-agent:rollback-memory 0) + (opencortex:rollback-memory 0) nil))) (progn - (org-agent:harness-log "SELF-FIX SUCCESS - Applied fix to file.") + (opencortex:harness-log "SELF-FIX SUCCESS - Applied fix to file.") t))) - (progn (org-agent:harness-log "SELF-FIX FAILURE - Pattern not found.") nil))) - (progn (org-agent:harness-log "SELF-FIX FAILURE - File not found.") nil)) + (progn (opencortex:harness-log "SELF-FIX FAILURE - Pattern not found.") nil))) + (progn (opencortex:harness-log "SELF-FIX FAILURE - File not found.") nil)) (error (c) - (org-agent:harness-log "SELF-FIX CRASH - ~a. Rolling back." c) - (org-agent:rollback-memory 0) + (opencortex:harness-log "SELF-FIX CRASH - ~a. Rolling back." c) + (opencortex:rollback-memory 0) nil)))) #+end_src @@ -77,11 +77,11 @@ The *Self-Fix Agent* is the system's "Repair Mechanism." It takes failure hypoth ** Skill Definition #+begin_src lisp -(org-agent:defskill :skill-self-fix +(opencortex:defskill :skill-self-fix :priority 95 :trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :repair-request)) :probabilistic (lambda (context) - (format nil "You are the org-agent Repair Actuator. Synthesize a surgical fix for the reported failure. + (format nil "You are the opencortex Repair Actuator. Synthesize a surgical fix for the reported failure. Return a Lisp plist for :repair-file.")) :deterministic (lambda (action context) (let ((payload (getf action :payload))) diff --git a/skills/org-skill-shell-actuator.org b/skills/org-skill-shell-actuator.org index 17d842f..70bf69b 100644 --- a/skills/org-skill-shell-actuator.org +++ b/skills/org-skill-shell-actuator.org @@ -110,13 +110,13 @@ The primary secure actuator for host system calls. (cond ;; 1. Metacharacter check (Injection prevention) ((not (shell-command-safe-p cmd-string)) - (org-agent:inject-stimulus + (opencortex:inject-stimulus `(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd-string :stdout "" :stderr "ERROR - Security Violation: Dangerous metacharacters detected." :exit-code 1)) :stream (getf context :reply-stream))) ;; 2. Whitelist check ((not (member executable *allowed-commands* :test #'string=)) - (org-agent:inject-stimulus + (opencortex:inject-stimulus `(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd-string :stdout "" :stderr "ERROR - Command not in security whitelist." :exit-code 1)) :stream (getf context :reply-stream))) @@ -124,7 +124,7 @@ The primary secure actuator for host system calls. (t (multiple-value-bind (stdout stderr exit-code) (uiop:run-program cmd-string :output :string :error-output :string :ignore-error-status t) - (org-agent:inject-stimulus + (opencortex:inject-stimulus `(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd-string :stdout ,(or stdout "") :stderr ,(or stderr "") :exit-code ,exit-code)) :stream (getf context :reply-stream))))))) #+end_src @@ -139,7 +139,7 @@ Executes a synthesized script (Python/Lisp/JS) in a controlled directory. (let* ((payload (getf action :payload)) (language (getf payload :language)) (content (getf payload :content)) - (sandbox-dir "/tmp/org-agent-sandbox/") + (sandbox-dir "/tmp/opencortex-sandbox/") (filename (format nil "synth-~a.~a" (get-universal-time) (case language (:python "py") (:lisp "lisp") (:js "js") (t "txt")))) (full-path (format nil "~a~a" sandbox-dir filename))) @@ -153,7 +153,7 @@ Executes a synthesized script (Python/Lisp/JS) in a controlled directory. (:js (format nil "node ~a" full-path))))) (multiple-value-bind (stdout stderr exit-code) (uiop:run-program cmd :output :string :error-output :string :ignore-error-status t) - (org-agent:inject-stimulus + (opencortex:inject-stimulus `(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd :stdout ,(or stdout "") :stderr ,(or stderr "") :exit-code ,exit-code :synthesis-p t)) :stream (getf context :reply-stream)))))) #+end_src @@ -213,7 +213,7 @@ Hardware-Level Isolation for future security evolution. ~a #+end_example" cmd exit-code stdout stderr))) - `(:type :request :target :emacs :payload (:action :insert-at-end :buffer "*org-agent-chat*" :text ,result-text)))))) + `(:type :request :target :emacs :payload (:action :insert-at-end :buffer "*opencortex-chat*" :text ,result-text)))))) #+end_src * Registration @@ -222,7 +222,7 @@ Hardware-Level Isolation for future security evolution. Register the shell channel as a physical actuator. #+begin_src lisp -(org-agent:register-actuator :shell #'execute-shell-safely) +(opencortex:register-actuator :shell #'execute-shell-safely) #+end_src ** Registration: Skill diff --git a/skills/org-skill-state-persistence.org b/skills/org-skill-state-persistence.org index 1165097..0966788 100644 --- a/skills/org-skill-state-persistence.org +++ b/skills/org-skill-state-persistence.org @@ -239,9 +239,9 @@ Expose persistence capabilities to the neural Probabilistic Engine. ** 1. Unit Tests (FiveAM) #+begin_src lisp -(defpackage :org-agent-persistence-tests - (:use :cl :fiveam :org-agent)) -(in-package :org-agent-persistence-tests) +(defpackage :opencortex-persistence-tests + (:use :cl :fiveam :opencortex)) +(in-package :opencortex-persistence-tests) (def-suite persistence-suite :description "Tests for State Persistence Layer.") (in-suite persistence-suite) @@ -253,10 +253,10 @@ Expose persistence capabilities to the neural Probabilistic Engine. (let ((obj (make-org-object :id test-id :content "Integrity Check" :hash test-hash))) (setf (gethash test-hash *history-store*) obj) (setf (gethash test-id *memory*) obj)) - (org-agent:persistence-dump-local) + (opencortex:persistence-dump-local) (clrhash *memory*) (clrhash *history-store*) - (org-agent:persistence-load-local) + (opencortex:persistence-load-local) (is (not (null (gethash test-id *memory*)))) (is (equal "Integrity Check" (org-object-content (gethash test-id *memory*)))))) #+end_src diff --git a/src/act.lisp b/src/act.lisp index 2d0477f..dd97950 100644 --- a/src/act.lisp +++ b/src/act.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defvar *default-actuator* :cli) (defvar *silent-actuators* '(:cli :system-message :emacs)) @@ -36,7 +36,7 @@ (:eval (let ((code (getf payload :code))) (eval (read-from-string code)))) (:create-skill (let* ((filename (getf payload :filename)) (content (getf payload :content)) - (skills-dir (merge-pathnames "skills/" (asdf:system-source-directory :org-agent))) + (skills-dir (merge-pathnames "skills/" (asdf:system-source-directory :opencortex))) (full-path (merge-pathnames filename skills-dir))) (with-open-file (out full-path :direction :output :if-exists :supersede) (write-string content out)) (load-skill-from-org full-path))) diff --git a/src/communication-validator.lisp b/src/communication-validator.lisp index 956adbd..3d67ef6 100644 --- a/src/communication-validator.lisp +++ b/src/communication-validator.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defun validate-communication-protocol-schema (msg) "Strict structural validation for incoming communication protocol messages." diff --git a/src/communication.lisp b/src/communication.lisp index 37370da..e5b02aa 100644 --- a/src/communication.lisp +++ b/src/communication.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defvar *actuator-registry* (make-hash-table :test 'equal) "Global registry mapping target keywords to their physical actuator functions.") diff --git a/src/context.lisp b/src/context.lisp index 175ddbf..aafaf7c 100644 --- a/src/context.lisp +++ b/src/context.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defun context-query-store (&key tag todo-state type) "Filters the Memory based on tags, todo states, or types." diff --git a/src/deterministic.lisp b/src/deterministic.lisp index c2b7589..a0ccc34 100644 --- a/src/deterministic.lisp +++ b/src/deterministic.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defun decide (proposed-action context) "The Deterministic Safety Gate: iterates through all skill deterministic-gates sorted by priority." diff --git a/src/loop.lisp b/src/loop.lisp index 6626d9c..29aef8e 100644 --- a/src/loop.lisp +++ b/src/loop.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defvar *interrupt-flag* nil) (defvar *interrupt-lock* (bt:make-lock "harness-interrupt-lock")) @@ -41,12 +41,12 @@ (sleep interval) ;; inject-stimulus is synchronous for heartbeats, preventing accumulation. (inject-stimulus (list :type :EVENT :payload (list :sensor :heartbeat :unix-time (get-universal-time)))))) - :name "org-agent-heartbeat")))) + :name "opencortex-heartbeat")))) (defun main () "Entry point for the Skeleton MVP. Handles initialization and graceful shutdown." (let* ((home (uiop:getenv "HOME")) - (env-file (uiop:merge-pathnames* ".local/share/org-agent/.env" (uiop:ensure-directory-pathname home)))) + (env-file (uiop:merge-pathnames* ".local/share/opencortex/.env" (uiop:ensure-directory-pathname home)))) (when (uiop:file-exists-p env-file) (cl-dotenv:load-env env-file))) (initialize-actuators) diff --git a/src/memory.lisp b/src/memory.lisp index f6d3fd9..a5860e5 100644 --- a/src/memory.lisp +++ b/src/memory.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defvar *memory* (make-hash-table :test 'equal)) diff --git a/src/org-agent.el b/src/org-agent.el index 0461ed2..ce86a22 100644 --- a/src/org-agent.el +++ b/src/org-agent.el @@ -1,4 +1,4 @@ -;;; org-agent.el --- Probabilistic-Deterministic Lisp Machine Kernel for Org-mode -*- lexical-binding: t; -*- +;;; opencortex.el --- Probabilistic-Deterministic Lisp Machine Kernel for Org-mode -*- lexical-binding: t; -*- ;; Copyright (C) 2026 Amr ;; @@ -6,11 +6,11 @@ ;; Version: 0.1.0 ;; Package-Requires: ((emacs "27.1")) ;; Keywords: convenience, org -;; URL: https://github.com/amr/org-agent +;; URL: https://github.com/amr/opencortex ;;; Commentary: -;; org-agent provides a Probabilistic-Deterministic Lisp Machine interface for Emacs. +;; opencortex 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 communication protocol socket. @@ -21,94 +21,94 @@ (require 'org-id) (require 'org-element) -(defgroup org-agent nil - "Emacs interface for the org-agent Common Lisp daemon." +(defgroup opencortex nil + "Emacs interface for the opencortex Common Lisp daemon." :group 'org) -(defcustom org-agent-port 9105 - "The port the org-agent daemon is listening on." +(defcustom opencortex-port 9105 + "The port the opencortex daemon is listening on." :type 'integer - :group 'org-agent) + :group 'opencortex) -(defcustom org-agent-host "127.0.0.1" - "The host the org-agent daemon is running on." +(defcustom opencortex-host "127.0.0.1" + "The host the opencortex daemon is running on." :type 'string - :group 'org-agent) + :group 'opencortex) -(defcustom org-agent-executable-path "org-agent-server" - "Path to the compiled org-agent-server binary. +(defcustom opencortex-executable-path "opencortex-server" + "Path to the compiled opencortex-server binary. If nil, Emacs will not attempt to start the daemon automatically and will assume you have started it manually (e.g., via SBCL)." :type '(choice (string :tag "Path to executable") (const :tag "Manual daemon management" nil)) - :group 'org-agent) + :group 'opencortex) -(defvar org-agent--network-process nil +(defvar opencortex--network-process nil "The network process connected to the daemon.") -(defvar org-agent--daemon-process nil +(defvar opencortex--daemon-process nil "The spawned daemon child process.") -(defun org-agent--start-daemon () +(defun opencortex--start-daemon () "Start the daemon binary if not already running." - (when (and org-agent-executable-path - (not (process-live-p org-agent--daemon-process))) - (message "org-agent: Starting daemon (%s)..." org-agent-executable-path) - (setq org-agent--daemon-process + (when (and opencortex-executable-path + (not (process-live-p opencortex--daemon-process))) + (message "opencortex: Starting daemon (%s)..." opencortex-executable-path) + (setq opencortex--daemon-process (make-process - :name "org-agent-daemon" - :buffer "*org-agent-daemon*" - :command (list org-agent-executable-path (number-to-string org-agent-port)) + :name "opencortex-daemon" + :buffer "*opencortex-daemon*" + :command (list opencortex-executable-path (number-to-string opencortex-port)) :connection-type 'pipe)) ;; Give it a moment to bind to the port (sleep-for 1.0))) -(defun org-agent-connect () - "Connect to the org-agent daemon, starting it if necessary." +(defun opencortex-connect () + "Connect to the opencortex daemon, starting it if necessary." (interactive) - (when org-agent--network-process - (delete-process org-agent--network-process)) + (when opencortex--network-process + (delete-process opencortex--network-process)) - (org-agent--start-daemon) + (opencortex--start-daemon) (condition-case err (progn - (setq org-agent--network-process + (setq opencortex--network-process (make-network-process - :name "org-agent" - :buffer "*org-agent*" + :name "opencortex" + :buffer "*opencortex*" :family 'ipv4 - :host org-agent-host - :service org-agent-port - :filter #'org-agent--filter - :sentinel #'org-agent--sentinel)) - (message "org-agent: Connected to daemon.")) + :host opencortex-host + :service opencortex-port + :filter #'opencortex--filter + :sentinel #'opencortex--sentinel)) + (message "opencortex: Connected to daemon.")) (error - (message "org-agent: Failed to connect to daemon at %s:%s. Ensure it is running. Error: %s" - org-agent-host org-agent-port (error-message-string err))))) + (message "opencortex: Failed to connect to daemon at %s:%s. Ensure it is running. Error: %s" + opencortex-host opencortex-port (error-message-string err))))) -(defun org-agent-disconnect () - "Disconnect from the org-agent daemon." +(defun opencortex-disconnect () + "Disconnect from the opencortex daemon." (interactive) - (when org-agent--network-process - (delete-process org-agent--network-process) - (setq org-agent--network-process nil) - (message "org-agent: Disconnected from network.")) - (when org-agent--daemon-process - (delete-process org-agent--daemon-process) - (setq org-agent--daemon-process nil) - (message "org-agent: Killed daemon process."))) + (when opencortex--network-process + (delete-process opencortex--network-process) + (setq opencortex--network-process nil) + (message "opencortex: Disconnected from network.")) + (when opencortex--daemon-process + (delete-process opencortex--daemon-process) + (setq opencortex--daemon-process nil) + (message "opencortex: Killed daemon process."))) -(defun org-agent--filter (proc string) +(defun opencortex--filter (proc string) "Handle incoming communication protocol messages from the daemon via PROC with STRING." (let ((buf (process-buffer proc))) (when (buffer-live-p buf) (with-current-buffer buf (goto-char (point-max)) (insert string) - (org-agent--process-buffer buf proc))))) + (opencortex--process-buffer buf proc))))) -(defun org-agent--process-buffer (buffer &optional proc) +(defun opencortex--process-buffer (buffer &optional proc) "Process the communication protocol message BUFFER, optionally using PROC." (with-current-buffer buffer (goto-char (point-min)) @@ -121,88 +121,88 @@ will assume you have started it manually (e.g., via SBCL)." (msg-str (buffer-substring msg-start msg-end)) (plist (car (read-from-string msg-str)))) (delete-region (point-min) msg-end) - (org-agent--handle-message proc plist)) + (opencortex--handle-message proc plist)) ;; Message incomplete, stop loop (goto-char (point-max)) (setq msg-len 1000000)))))) ; Break loop -(defun org-agent--plist-get (plist prop) +(defun opencortex--plist-get (plist prop) "Case-insensitive keyword lookup for communication protocol 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) +(defun opencortex--handle-message (proc plist) "Route and execute incoming communication protocol 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))) + (let ((type (opencortex--plist-get plist :type)) + (id (opencortex--plist-get plist :id)) + (payload (or (opencortex--plist-get plist :payload) plist))) (cond ((member type '(:request :REQUEST)) - (org-agent--execute-request proc id payload)) + (opencortex--execute-request proc id payload)) ((member type '(:response :RESPONSE)) - (message "org-agent: Received response for ID %s" id)) + (message "opencortex: Received response for ID %s" id)) ((member type '(:log :LOG)) - (let ((text (org-agent--plist-get payload :text))) - (org-agent--insert-to-history (concat "[reasoning] " text "\n") 'org-agent-system-face))) - (t (message "org-agent: Received unknown message type %s" type))))) + (let ((text (opencortex--plist-get payload :text))) + (opencortex--insert-to-history (concat "[reasoning] " text "\n") 'opencortex-system-face))) + (t (message "opencortex: Received unknown message type %s" type))))) -(defun org-agent--execute-request (proc id payload) +(defun opencortex--execute-request (proc id payload) "Execute an actuator request from the daemon via PROC with ID and PAYLOAD." - (let ((action (org-agent--plist-get payload :action))) + (let ((action (opencortex--plist-get payload :action))) (cond ((member action '(:eval :EVAL)) - (let ((code (org-agent--plist-get payload :code))) + (let ((code (opencortex--plist-get payload :code))) (condition-case err (let ((result (eval (read code)))) - (org-agent-send + (opencortex-send `(:type :RESPONSE :id ,id :payload (:status :success :result ,(format "%s" result))))) (error - (org-agent-send + (opencortex-send `(:type :RESPONSE :id ,id :payload (:status :error :message ,(error-message-string err)))))))) ((member action '(:message :MESSAGE)) - (message "org-agent [DAEMON]: %s" (org-agent--plist-get payload :text)) - (org-agent-send `(:type :RESPONSE :id ,id :payload (:status :success)))) + (message "opencortex [DAEMON]: %s" (opencortex--plist-get payload :text)) + (opencortex-send `(:type :RESPONSE :id ,id :payload (:status :success)))) ((member action '(:insert-at-end :INSERT-AT-END)) - (let ((text (org-agent--plist-get payload :text))) - (org-agent--insert-to-history (concat "\nAGENT: " text "\n\n")) - (org-agent-send `(:type :RESPONSE :id ,id :payload (:status :success))))) + (let ((text (opencortex--plist-get payload :text))) + (opencortex--insert-to-history (concat "\nAGENT: " text "\n\n")) + (opencortex-send `(:type :RESPONSE :id ,id :payload (:status :success))))) ((member action '(:refactor-subtree :REFACTOR-SUBTREE)) - (let ((target-id (org-agent--plist-get payload :target-id)) - (properties (org-agent--plist-get payload :properties))) + (let ((target-id (opencortex--plist-get payload :target-id)) + (properties (opencortex--plist-get payload :properties))) (condition-case err (save-excursion (when target-id (org-id-goto target-id)) (dolist (prop properties) (org-set-property (car prop) (cdr prop))) - (org-agent-send `(:type :RESPONSE :id ,id :payload (:status :success)))) + (opencortex-send `(:type :RESPONSE :id ,id :payload (:status :success)))) (error - (org-agent-send + (opencortex-send `(:type :RESPONSE :id ,id :payload (:status :error :message ,(error-message-string err)))))))) (t - (message "org-agent: Unknown action %s" action) - (org-agent-send `(:type :RESPONSE :id ,id :payload (:status :unsupported))))))) + (message "opencortex: Unknown action %s" action) + (opencortex-send `(:type :RESPONSE :id ,id :payload (:status :unsupported))))))) -(defun org-agent--sentinel (proc event) +(defun opencortex--sentinel (proc event) "Handle network process PROC lifecycle EVENT." (when (string-match "finished" event) - (setq org-agent--network-process nil) - (message "org-agent: Connection lost."))) + (setq opencortex--network-process nil) + (message "opencortex: Connection lost."))) -(defun org-agent-send (plist) +(defun opencortex-send (plist) "Send a Lisp PLIST to the daemon using communication protocol framing." (let* ((msg (prin1-to-string plist)) (len (length msg)) (framed (format "%06x%s" len msg))) - (if (and org-agent--network-process (process-live-p org-agent--network-process)) - (process-send-string org-agent--network-process framed) - (message "org-agent (offline): %s" framed)))) + (if (and opencortex--network-process (process-live-p opencortex--network-process)) + (process-send-string opencortex--network-process framed) + (message "opencortex (offline): %s" framed)))) -(defun org-agent--buffer-to-sexp () +(defun opencortex--buffer-to-sexp () "Transform the current Org buffer into a pure Lisp AST (plist)." - (org-agent--clean-element (org-element-parse-buffer))) + (opencortex--clean-element (org-element-parse-buffer))) -(defun org-agent--clean-element (element) +(defun opencortex--clean-element (element) "Recursively transform an Org ELEMENT into a pure Lisp plist." (cond ((listp element) @@ -225,86 +225,86 @@ will assume you have started it manually (e.g., via SBCL)." (setq cleaned-props (plist-put cleaned-props :TODO-STATE (format "%s" todo))))) (list :type type :properties cleaned-props - :contents (mapcar #'org-agent--clean-element children)))) + :contents (mapcar #'opencortex--clean-element children)))) ((stringp element) element) (t (format "%s" element)))) ;;; Sensors -(defun org-agent-notify-save () +(defun opencortex-notify-save () "Sensor: Notify daemon with full Semantic Perception (AST) when saved." - (when (and org-agent--network-process (derived-mode-p 'org-mode)) - (org-agent-send + (when (and opencortex--network-process (derived-mode-p 'org-mode)) + (opencortex-send `(:type :EVENT :payload (:sensor :buffer-update :file ,(buffer-file-name) :state :saved - :ast ,(org-agent--buffer-to-sexp)))))) + :ast ,(opencortex--buffer-to-sexp)))))) -(defun org-agent-notify-point () +(defun opencortex-notify-point () "Sensor: Notify daemon of the element currently at point (Incremental Perception). This is much faster than parsing the entire buffer and allows for real-time responsiveness to the user's cursor position." - (when (and org-agent--network-process (derived-mode-p 'org-mode)) + (when (and opencortex--network-process (derived-mode-p 'org-mode)) (let ((element (org-element-at-point))) - (org-agent-send + (opencortex-send `(:type :EVENT :payload (:sensor :point-update :file ,(buffer-file-name) - :element ,(org-agent--clean-element element))))))) + :element ,(opencortex--clean-element element))))))) ;;; Interaction Commands -(defun org-agent-set-model-cascade (cascade-string) +(defun opencortex-set-model-cascade (cascade-string) "Set the ordered list of LLM providers to use as fallbacks. CASCADE-STRING should be a comma-separated list of keywords, e.g., ':gemini,:openai,:ollama'." (interactive "sEnter model cascade (e.g. :gemini,:openai): ") - (unless org-agent--network-process - (org-agent-connect)) + (unless opencortex--network-process + (opencortex-connect)) (let ((cascade (mapcar #'intern (split-string cascade-string ",")))) - (org-agent-send + (opencortex-send `(:type :REQUEST :id ,(truncate (float-time)) :target :system :payload (:action :set-cascade :cascade ,cascade))) - (message "org-agent: Requesting model cascade update to %s" cascade))) -(defgroup org-agent-faces nil - "Faces for the org-agent chat interface." - :group 'org-agent) + (message "opencortex: Requesting model cascade update to %s" cascade))) +(defgroup opencortex-faces nil + "Faces for the opencortex chat interface." + :group 'opencortex) -(defface org-agent-user-face +(defface opencortex-user-face '((((class color) (background dark)) :foreground "LightSkyBlue" :weight bold) (((class color) (background light)) :foreground "blue" :weight bold) (t :weight bold :underline t)) "Face for user messages in chat history." - :group 'org-agent-faces) + :group 'opencortex-faces) -(defface org-agent-system-face +(defface opencortex-system-face '((t :slant italic :foreground "gray50")) "Face for system and reasoning logs." - :group 'org-agent-faces) + :group 'opencortex-faces) -(defun org-agent-chat () - "Modern chat interface for the org-agent kernel. +(defun opencortex-chat () + "Modern chat interface for the opencortex kernel. Opens a history buffer and a dedicated input area." (interactive) - (let ((chat-buf (get-buffer-create "*org-agent-chat*")) - (input-buf (get-buffer-create "*org-agent-input*"))) + (let ((chat-buf (get-buffer-create "*opencortex-chat*")) + (input-buf (get-buffer-create "*opencortex-input*"))) ;; History Buffer Setup (with-current-buffer chat-buf (unless (eq major-mode 'special-mode) (special-mode) (let ((inhibit-read-only t)) (erase-buffer) - (insert "--- org-agent History ---\n\n")))) + (insert "--- opencortex History ---\n\n")))) ;; Input Buffer Setup (with-current-buffer input-buf (unless (eq major-mode 'org-mode) (org-mode) - (local-set-key (kbd "C-c C-c") #'org-agent-chat-send) - (local-set-key (kbd "C-c C-k") #'org-agent-interrupt)) + (local-set-key (kbd "C-c C-c") #'opencortex-chat-send) + (local-set-key (kbd "C-c C-k") #'opencortex-interrupt)) (let ((inhibit-read-only t)) (delete-region (point-min) (point-max)) (insert "# Type your message and press C-c C-c to send.\n"))) @@ -315,19 +315,19 @@ Opens a history buffer and a dedicated input area." (let ((win (split-window-below -6))) ; 6 lines for input (set-window-buffer win input-buf) (select-window win)))) -(defun org-agent-interrupt () - "Interrupt the org-agent reasoning loop." +(defun opencortex-interrupt () + "Interrupt the opencortex reasoning loop." (interactive) - (unless org-agent--network-process - (org-agent-connect)) - (org-agent-send + (unless opencortex--network-process + (opencortex-connect)) + (opencortex-send `(:type :EVENT :payload (:sensor :interrupt))) - (message "org-agent: Interrupt signal sent.")) + (message "opencortex: Interrupt signal sent.")) -(defun org-agent--insert-to-history (text &optional face) +(defun opencortex--insert-to-history (text &optional face) "Insert TEXT into the chat history buffer with optional FACE and scroll." - (let ((buf (get-buffer-create "*org-agent-chat*"))) + (let ((buf (get-buffer-create "*opencortex-chat*"))) (with-current-buffer buf (let ((inhibit-read-only t)) (save-excursion @@ -340,16 +340,16 @@ Opens a history buffer and a dedicated input area." (set-window-point w (point-max)))) nil t))))) -(defun org-agent-chat-send () +(defun opencortex-chat-send () "Send the current chat buffer content to the agent." (interactive) - (unless org-agent--network-process - (org-agent-connect)) + (unless opencortex--network-process + (opencortex-connect)) (let* ((text (buffer-substring-no-properties (point-min) (point-max))) (clean-text (string-trim (replace-regexp-in-string "^#.*\n" "" text)))) (when (> (length clean-text) 0) ;; Append to history with styling - (org-agent--insert-to-history (concat "YOU: " clean-text "\n\n") 'org-agent-user-face) + (opencortex--insert-to-history (concat "YOU: " clean-text "\n\n") 'opencortex-user-face) ;; Clear input buffer (let ((inhibit-read-only t)) @@ -357,66 +357,66 @@ Opens a history buffer and a dedicated input area." (insert "# Type your message and press C-c C-c to send.\n")) ;; Send to daemon - (org-agent-send + (opencortex-send `(:type :EVENT :payload (:sensor :chat-message :text ,clean-text))) - (message "org-agent: Message sent.")))) + (message "opencortex: Message sent.")))) -(defun org-agent-auth-google (code) +(defun opencortex-auth-google (code) "Submit the Google OAuth authorization CODE to the daemon." (interactive "sEnter Google Authorization Code: ") - (unless org-agent--network-process - (org-agent-connect)) - (org-agent-send + (unless opencortex--network-process + (opencortex-connect)) + (opencortex-send `(:type :REQUEST :id ,(truncate (float-time)) :target :system :payload (:action :auth-google-code :code ,code))) - (message "org-agent: Authorization code sent to daemon.")) + (message "opencortex: Authorization code sent to daemon.")) -(defun org-agent-organize-subtree () +(defun opencortex-organize-subtree () ... "Command: Ask the agent to organize the current Org subtree." (interactive) - (org-agent-run-command :organize-subtree)) + (opencortex-run-command :organize-subtree)) -(defun org-agent-summarize-buffer () +(defun opencortex-summarize-buffer () "Command: Ask the agent to summarize the current buffer." (interactive) - (org-agent-run-command :summarize-buffer)) + (opencortex-run-command :summarize-buffer)) -(defun org-agent-run-command (command-type) +(defun opencortex-run-command (command-type) "Generic runner for high-level COMMAND-TYPE." - (unless org-agent--network-process - (org-agent-connect)) - (let ((ast (org-agent--buffer-to-sexp))) - (org-agent-send + (unless opencortex--network-process + (opencortex-connect)) + (let ((ast (opencortex--buffer-to-sexp))) + (opencortex-send `(:type :EVENT :payload (:sensor :user-command :command ,command-type :file ,(buffer-file-name) :ast ,ast))) - (message "org-agent: Requesting '%s'..." command-type))) + (message "opencortex: Requesting '%s'..." command-type))) ;;;###autoload -(define-minor-mode org-agent-mode - "Global minor mode for the org-agent Probabilistic-Deterministic kernel. +(define-minor-mode opencortex-mode + "Global minor mode for the opencortex Probabilistic-Deterministic kernel. When enabled, this mode starts the Lisp daemon (if configured) and establishes the network connection to enable proactive Org-mode sensing." :global t - :group 'org-agent - (if org-agent-mode + :group 'opencortex + (if opencortex-mode (progn - (add-hook 'after-save-hook #'org-agent-notify-save) - (add-hook 'post-command-hook #'org-agent-notify-point) - (add-hook 'kill-emacs-hook #'org-agent-disconnect) - (org-agent-connect)) - (remove-hook 'after-save-hook #'org-agent-notify-save) - (remove-hook 'post-command-hook #'org-agent-notify-point) - (remove-hook 'kill-emacs-hook #'org-agent-disconnect) - (org-agent-disconnect))) + (add-hook 'after-save-hook #'opencortex-notify-save) + (add-hook 'post-command-hook #'opencortex-notify-point) + (add-hook 'kill-emacs-hook #'opencortex-disconnect) + (opencortex-connect)) + (remove-hook 'after-save-hook #'opencortex-notify-save) + (remove-hook 'post-command-hook #'opencortex-notify-point) + (remove-hook 'kill-emacs-hook #'opencortex-disconnect) + (opencortex-disconnect))) -(provide 'org-agent) -;;; org-agent.el ends here +(provide 'opencortex) +;;; opencortex.el ends here diff --git a/src/package.lisp b/src/package.lisp index fbde7f5..67fbaff 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1,4 +1,4 @@ -(defpackage :org-agent +(defpackage :opencortex (:use :cl) (:export ;; --- communication protocol --- @@ -103,7 +103,7 @@ ;; --- AST Helpers --- #:find-headline-missing-id)) -(in-package :org-agent) +(in-package :opencortex) (defvar *system-logs* nil) (defvar *logs-lock* (bt:make-lock "harness-logs-lock")) diff --git a/src/perceive.lisp b/src/perceive.lisp index a6ef592..ecbd95a 100644 --- a/src/perceive.lisp +++ b/src/perceive.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defvar *async-sensors* '(:chat-message :delegation :user-command) "List of sensors that should be processed asynchronously to avoid blocking gateways.") @@ -18,7 +18,7 @@ (restart-case (handler-bind ((error (lambda (c) (harness-log "ASYNC ERROR: ~a" c) (invoke-restart 'skip-event)))) (process-signal raw-message)) (skip-event () nil))) - :name "org-agent-async-task") + :name "opencortex-async-task") (restart-case (handler-bind ((error (lambda (c) (harness-log "SYSTEM ERROR: ~a" c) (invoke-restart 'skip-event)))) (process-signal raw-message)) (skip-event () (harness-log "SYSTEM RECOVERY: Stimulus dropped.~%")))))) diff --git a/src/policy.lisp b/src/policy.lisp index c3f003b..bac930c 100644 --- a/src/policy.lisp +++ b/src/policy.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defun policy-check-autonomy (action context) "Ensures the action does not violate the Autonomy invariant." @@ -11,7 +11,7 @@ "The main policy gate. Sub-calls engineering standards if available." (let ((current-action (policy-check-autonomy action context))) (when current-action - (let ((eng-pkg (find-package :org-agent.skills.org-skill-engineering-standards))) + (let ((eng-pkg (find-package :opencortex.skills.org-skill-engineering-standards))) (when eng-pkg (let ((eng-gate (find-symbol "ENGINEERING-STANDARDS-GATE" eng-pkg))) (when (and eng-gate (fboundp eng-gate)) diff --git a/src/probabilistic.lisp b/src/probabilistic.lisp index 455da42..fbcd7dd 100644 --- a/src/probabilistic.lisp +++ b/src/probabilistic.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defvar *probabilistic-backends* (make-hash-table :test 'equal)) @@ -71,7 +71,7 @@ (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. + "ACTUATOR IDENTITY: You are the pure Lisp actuator for the opencortex kernel. MANDATE: Output EXACTLY ONE Common Lisp property list starting with (:type :REQUEST). ZERO CONVERSATION: Do not explain. Do not say 'Okay'. Do not use markdown blocks. STRICT RULE: Do not output multiple lists. Do not chain multiple requests. @@ -84,7 +84,7 @@ DO NOT embed tool calls inside text strings. tool-belt " IMPORTANT: To reply to the user, you MUST use: -(:type :REQUEST :target :emacs :action :insert-at-end :buffer \"*org-agent-chat*\" :text \"* \") +(:type :REQUEST :target :emacs :action :insert-at-end :buffer \"*opencortex-chat*\" :text \"* \") To call a tool, you MUST use: (:type :REQUEST :target :tool :action :call :tool \"\" :args (:arg1 \"val\")) diff --git a/src/reason.lisp b/src/reason.lisp index 1df7f5d..995b1a8 100644 --- a/src/reason.lisp +++ b/src/reason.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defvar *probabilistic-backends* (make-hash-table :test 'equal)) (defvar *provider-cascade* nil) diff --git a/src/skills.lisp b/src/skills.lisp index 3bc361f..9954f98 100644 --- a/src/skills.lisp +++ b/src/skills.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (defstruct skill name priority dependencies trigger-fn probabilistic-prompt deterministic-fn) @@ -123,7 +123,7 @@ (lines (uiop:split-string content :separator '(#\Newline))) (in-lisp-block nil) (lisp-code "") - (pkg-name (intern (string-upcase (format nil "ORG-AGENT.SKILLS.~a" skill-base-name)) :keyword))) + (pkg-name (intern (string-upcase (format nil "OPENCORTEX.SKILLS.~a" skill-base-name)) :keyword))) (dolist (line lines) (let ((clean-line (string-trim '(#\Space #\Tab #\Return) line))) @@ -150,7 +150,7 @@ (harness-log "HARNESS: Jailing skill '~a' in package ~a" skill-base-name pkg-name) (unless (find-package pkg-name) (let ((new-pkg (make-package pkg-name :use '(:cl)))) - (do-external-symbols (sym (find-package :org-agent)) (shadowing-import sym new-pkg)))) + (do-external-symbols (sym (find-package :opencortex)) (shadowing-import sym new-pkg)))) (let ((*read-eval* nil) (*package* (find-package pkg-name))) (eval (read-from-string (format nil "(progn ~a)" lisp-code)))) @@ -256,9 +256,9 @@ EXAMPLES: :guard (lambda (args context) (declare (ignore context)) (let ((code (getf args :code))) - (let ((harness-pkg (find-package :org-agent.skills.org-skill-lisp-validator))) + (let ((harness-pkg (find-package :opencortex.skills.org-skill-lisp-validator))) (if harness-pkg - (uiop:symbol-call :org-agent.skills.org-skill-lisp-validator :lisp-validator-validate code) + (uiop:symbol-call :opencortex.skills.org-skill-lisp-validator :lisp-validator-validate code) t)))) :body (lambda (args) (let ((code (getf args :code))) diff --git a/system/state/memory-image.lisp b/system/state/memory-image.lisp index 556c38e..43a95cc 100644 --- a/system/state/memory-image.lisp +++ b/system/state/memory-image.lisp @@ -1,4 +1,4 @@ -(in-package :org-agent) +(in-package :opencortex) (SETF (GETHASH "fake-hash-123" *HISTORY-STORE*) #S(ORG-OBJECT diff --git a/tests/boot-sequence-tests.lisp b/tests/boot-sequence-tests.lisp index d1a45bd..90474db 100644 --- a/tests/boot-sequence-tests.lisp +++ b/tests/boot-sequence-tests.lisp @@ -1,7 +1,7 @@ -(defpackage :org-agent-boot-tests - (:use :cl :fiveam :org-agent) +(defpackage :opencortex-boot-tests + (:use :cl :fiveam :opencortex) (:export #:boot-suite)) -(in-package :org-agent-boot-tests) +(in-package :opencortex-boot-tests) (def-suite boot-suite :description "Verification of the Micro-Loader.") (in-suite boot-suite) @@ -12,7 +12,7 @@ (with-open-file (out tmp-file :direction :output :if-exists :supersede) (format out ":PROPERTIES:~%:ID: test-id~%:END:~%#+DEPENDS_ON: dep1 dep2~%")) (unwind-protect - (multiple-value-bind (id deps) (org-agent::parse-skill-metadata tmp-file) + (multiple-value-bind (id deps) (opencortex::parse-skill-metadata tmp-file) (is (equal "test-id" id)) (is (member "dep1" deps :test #'string=)) (is (member "dep2" deps :test #'string=))) @@ -20,7 +20,7 @@ (test test-topological-sort-basic "Verify that skills are ordered by dependency." - (let ((tmp-dir "/tmp/org-agent-boot-test/")) + (let ((tmp-dir "/tmp/opencortex-boot-test/")) (uiop:ensure-all-directories-exist (list tmp-dir)) ;; A depends on B (with-open-file (out (merge-pathnames "org-skill-a.org" tmp-dir) :direction :output :if-exists :supersede) @@ -32,7 +32,7 @@ (format out "#+TITLE: Agent~%")) (unwind-protect - (let ((sorted (org-agent::topological-sort-skills tmp-dir))) + (let ((sorted (opencortex::topological-sort-skills tmp-dir))) ;; B must appear before A (let ((pos-a (position "org-skill-a" sorted :key #'pathname-name :test #'string-equal)) (pos-b (position "org-skill-b" sorted :key #'pathname-name :test #'string-equal))) @@ -43,7 +43,7 @@ (test test-topological-sort-circular "Verify that circular dependencies raise an error." - (let ((tmp-dir "/tmp/org-agent-boot-test-circ/")) + (let ((tmp-dir "/tmp/opencortex-boot-test-circ/")) (uiop:ensure-all-directories-exist (list tmp-dir)) ;; A depends on B, B depends on A (with-open-file (out (merge-pathnames "org-skill-a.org" tmp-dir) :direction :output :if-exists :supersede) @@ -52,7 +52,7 @@ (format out "#+DEPENDS_ON: org-skill-a~%")) (unwind-protect - (signals error (org-agent::topological-sort-skills tmp-dir)) + (signals error (opencortex::topological-sort-skills tmp-dir)) (uiop:delete-directory-tree (uiop:ensure-directory-pathname tmp-dir) :validate t)))) (test test-skill-jailing @@ -62,13 +62,13 @@ (format out "#+begin_src lisp~%(defvar *jailed-var* 42)~%#+end_src")) (unwind-protect (progn - (org-agent::load-skill-from-org tmp-skill) - (let ((pkg (find-package :ORG-AGENT.SKILLS.ORG-SKILL-JAIL-TEST))) + (opencortex::load-skill-from-org tmp-skill) + (let ((pkg (find-package :OPENCORTEX.SKILLS.ORG-SKILL-JAIL-TEST))) (is (not (null pkg))) (is (= 42 (symbol-value (find-symbol "*JAILED-VAR*" pkg)))))) (uiop:delete-file-if-exists tmp-skill)))) (test test-syntax-validation "Verify that malformed Lisp is caught by the pre-flight check." - (is (nth-value 0 (org-agent::validate-lisp-syntax "(defun x () t)"))) - (is (not (nth-value 0 (org-agent::validate-lisp-syntax "(defun x ("))))) + (is (nth-value 0 (opencortex::validate-lisp-syntax "(defun x () t)"))) + (is (not (nth-value 0 (opencortex::validate-lisp-syntax "(defun x ("))))) diff --git a/tests/communication-tests.lisp b/tests/communication-tests.lisp index 7133993..175c230 100644 --- a/tests/communication-tests.lisp +++ b/tests/communication-tests.lisp @@ -1,9 +1,9 @@ -(defpackage :org-agent-tests - (:use :cl :fiveam :org-agent)) -(in-package :org-agent-tests) +(defpackage :opencortex-tests + (:use :cl :fiveam :opencortex)) +(in-package :opencortex-tests) (def-suite communication-protocol-suite - :description "Test suite for org-agent Communication Protocol (communication protocol)") + :description "Test suite for opencortex Communication Protocol (communication protocol)") (in-suite communication-protocol-suite) (test test-framing @@ -11,17 +11,17 @@ (let ((msg "(:type :EVENT :payload (:action :handshake))")) ;; As the Analyst, I expect a function 'frame-message' to exist (is (string= "00002c(:type :EVENT :payload (:action :handshake))" - (org-agent:frame-message msg))))) + (opencortex:frame-message msg))))) (test test-parse-message "Verify that incoming framed strings are parsed into Lisp plists." (let ((framed "00002c(:type :EVENT :payload (:action :handshake))")) (is (equal '(:type :EVENT :payload (:action :handshake)) - (org-agent:parse-message framed))))) + (opencortex:parse-message framed))))) (test test-hello-handshake "Verify the structure of the HELLO handshake message." - (let ((hello (org-agent:make-hello-message "0.1.0"))) + (let ((hello (opencortex:make-hello-message "0.1.0"))) (is (eq :EVENT (getf hello :type))) (is (eq :handshake (getf (getf hello :payload) :action))) (is (string= "0.1.0" (getf (getf hello :payload) :version))))) @@ -31,6 +31,6 @@ (let* ((ast '(:type :org-data :contents ((:type :HEADLINE :properties (:TITLE "No ID Here") :contents nil) (:type :HEADLINE :properties (:ID "exists" :TITLE "Has ID") :contents nil)))) - (found (org-agent::find-headline-missing-id ast))) + (found (opencortex::find-headline-missing-id ast))) (is (not (null found))) (is (string= "No ID Here" (getf (getf found :properties) :TITLE))))) diff --git a/tests/immune-system-tests.lisp b/tests/immune-system-tests.lisp index 002dcc1..a9fd332 100644 --- a/tests/immune-system-tests.lisp +++ b/tests/immune-system-tests.lisp @@ -1,8 +1,8 @@ -(defpackage :org-agent-immune-system-tests - (:use :cl :fiveam :org-agent) +(defpackage :opencortex-immune-system-tests + (:use :cl :fiveam :opencortex) (:export #:immune-suite)) -(in-package :org-agent-immune-system-tests) +(in-package :opencortex-immune-system-tests) (def-suite immune-suite :description "Verification of the Immune System (Core Error Hooks).") @@ -11,43 +11,43 @@ (test tool-error-injection "Verify that a crashing tool triggers a :tool-error stimulus." - (clrhash org-agent::*cognitive-tools*) + (clrhash opencortex::*cognitive-tools*) (def-cognitive-tool :crashing-tool "Always fails." nil :body (lambda (args) (declare (ignore args)) (error "KABOOM"))) (let* ((stimulus '(:type :EVENT :payload (:sensor :user-command :command :trigger-crash))) ;; Mock a skill that calls the crashing tool - (skill (org-agent::make-skill + (skill (opencortex::make-skill :name "crasher" :priority 100 :trigger-fn (lambda (ctx) t) :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*) - (setf (gethash "crasher" org-agent::*skills-registry*) skill) + (clrhash opencortex::*skills-registry*) + (setf (gethash "crasher" opencortex::*skills-registry*) skill) ;; Since cognitive-loop is recursive and our core hooks inject a NEW stimulus, ;; we can't easily capture it in a single synchronous call without mocking cognitive-loop. ;; However, we can check if harness-log received the "SYSTEM ERROR" message. (harness-log "CLEAN LOG") - (org-agent:process-signal stimulus) + (opencortex:process-signal stimulus) (let ((logs (context-get-system-logs 20))) ;; We expect the pipeline to at least acknowledge the tool error (is (cl:some (lambda (line) (search "EVENT (TOOL-ERROR)" line)) logs))))) (test loop-error-injection "Verify that a crash in think/decide triggers a :loop-error stimulus." - (clrhash org-agent::*skills-registry*) - (org-agent::defskill :evil-skill + (clrhash opencortex::*skills-registry*) + (opencortex::defskill :evil-skill :priority 100 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :test)) :probabilistic (lambda (ctx) (error "CRITICAL BRAIN FAILURE")) :deterministic nil) (harness-log "CLEAN LOG") - (org-agent:process-signal '(:type :EVENT :payload (:sensor :test))) + (opencortex:process-signal '(:type :EVENT :payload (:sensor :test))) (let ((logs (context-get-system-logs 20))) ;; Check for the PIPELINE CRASH log (is (cl:some (lambda (line) (search "PIPELINE CRASH: CRITICAL BRAIN FAILURE" line)) logs)) diff --git a/tests/memory-tests.lisp b/tests/memory-tests.lisp index c209078..19d7f6f 100644 --- a/tests/memory-tests.lisp +++ b/tests/memory-tests.lisp @@ -1,8 +1,8 @@ -(defpackage :org-agent-memory-tests - (:use :cl :fiveam :org-agent) +(defpackage :opencortex-memory-tests + (:use :cl :fiveam :opencortex) (:export #:memory-suite)) -(in-package :org-agent-memory-tests) +(in-package :opencortex-memory-tests) (def-suite memory-suite :description "Tests for the Merkle-Tree Memory.") diff --git a/tests/org-agent-test.el b/tests/org-agent-test.el index 126051b..02d4634 100644 --- a/tests/org-agent-test.el +++ b/tests/org-agent-test.el @@ -1,61 +1,61 @@ -;;; org-agent-test.el --- Tests for the org-agent Emacs stub +;;; opencortex-test.el --- Tests for the opencortex Emacs stub (require 'ert) (require 'cl-lib) -(require 'org-agent "/home/amr/.openclaw/workspace/memex/5_projects/org-agent/src/org-agent.el") +(require 'opencortex "/home/amr/.openclaw/workspace/memex/5_projects/opencortex/src/opencortex.el") -(ert-deftest test-org-agent-framing () - "Verify that org-agent-send correctly frames a plist." +(ert-deftest test-opencortex-framing () + "Verify that opencortex-send correctly frames a plist." (let ((captured-framed nil)) (cl-letf (((symbol-function 'process-send-string) (lambda (proc string) (setq captured-framed string))) ((symbol-function 'process-live-p) (lambda (proc) t)) - (org-agent--process t)) - (org-agent-send '(:type :EVENT :id 1)) + (opencortex--process t)) + (opencortex-send '(:type :EVENT :id 1)) (should (string= "000014(:type :EVENT :id 1)" captured-framed))))) -(ert-deftest test-org-agent-parsing () +(ert-deftest test-opencortex-parsing () "Verify that the filter correctly parses communication protocol framed messages." - (let ((mock-buffer (generate-new-buffer " *org-agent-test*")) + (let ((mock-buffer (generate-new-buffer " *opencortex-test*")) (received-plist nil)) - (cl-letf (((symbol-function 'org-agent--handle-message) + (cl-letf (((symbol-function 'opencortex--handle-message) (lambda (proc plist) (setq received-plist plist)))) (with-current-buffer mock-buffer (insert "000014(:type :EVENT :id 1)") - (org-agent--process-buffer mock-buffer) + (opencortex--process-buffer mock-buffer) (should (equal '(:type :EVENT :id 1) received-plist)) (should (= (buffer-size) 0)))))) -(ert-deftest test-org-agent-actuator-message () +(ert-deftest test-opencortex-actuator-message () "Verify that the :message actuator works." - (let ((org-agent--process nil) + (let ((opencortex--process nil) (captured-response nil)) - (cl-letf (((symbol-function 'org-agent-send) + (cl-letf (((symbol-function 'opencortex-send) (lambda (plist) (setq captured-response plist)))) - (org-agent--execute-request nil 101 '(:action :message :text "Hello from Daemon")) + (opencortex--execute-request nil 101 '(:action :message :text "Hello from Daemon")) ;; Check that we sent a success response back (should (eq :RESPONSE (plist-get captured-response :type))) (should (eq :success (plist-get (plist-get captured-response :payload) :status)))))) -(ert-deftest test-org-agent-run-command () - "Verify that org-agent-run-command sends the correct event." +(ert-deftest test-opencortex-run-command () + "Verify that opencortex-run-command sends the correct event." (let ((captured-framed nil)) (cl-letf (((symbol-function 'process-send-string) (lambda (proc string) (setq captured-framed string))) ((symbol-function 'process-live-p) (lambda (proc) t)) - (org-agent--process t)) - (org-agent-run-command :test-cmd) + (opencortex--process t)) + (opencortex-run-command :test-cmd) (should (string-match-p ":sensor :user-command" captured-framed)) (should (string-match-p ":command :test-cmd" captured-framed))))) -(ert-deftest test-org-agent-ast-cleaning () - "Verify that org-agent--clean-element produces a pure plist." +(ert-deftest test-opencortex-ast-cleaning () + "Verify that opencortex--clean-element produces a pure plist." (let* ((org-text "* Hello\nWorld") (ast (with-temp-buffer (org-mode) (insert org-text) (org-element-parse-buffer))) - (cleaned (org-agent--clean-element ast))) + (cleaned (opencortex--clean-element ast))) (should (plist-get cleaned :type)) (should (eq 'org-data (plist-get cleaned :type))) ;; Check that children exist @@ -63,11 +63,11 @@ ;; Check that we didn't leak buffer objects (should-not (plist-get (plist-get cleaned :properties) :buffer)))) -(ert-deftest test-org-agent-actuator-eval () +(ert-deftest test-opencortex-actuator-eval () "Verify that the :eval actuator can execute elisp." - (let ((org-agent--process nil) + (let ((opencortex--process nil) (captured-response nil)) - (cl-letf (((symbol-function 'org-agent-send) + (cl-letf (((symbol-function 'opencortex-send) (lambda (plist) (setq captured-response plist)))) - (org-agent--execute-request nil 102 '(:action :eval :code "(+ 1 2)")) + (opencortex--execute-request nil 102 '(:action :eval :code "(+ 1 2)")) (should (equal "3" (plist-get (plist-get captured-response :payload) :result)))))) diff --git a/tests/peripheral-vision-tests.lisp b/tests/peripheral-vision-tests.lisp index 7bfa177..2b0880a 100644 --- a/tests/peripheral-vision-tests.lisp +++ b/tests/peripheral-vision-tests.lisp @@ -1,7 +1,7 @@ -(defpackage :org-agent-peripheral-vision-tests - (:use :cl :fiveam :org-agent) +(defpackage :opencortex-peripheral-vision-tests + (:use :cl :fiveam :opencortex) (:export #:vision-suite)) -(in-package :org-agent-peripheral-vision-tests) +(in-package :opencortex-peripheral-vision-tests) (def-suite vision-suite :description "Verification of Foveal-Peripheral context model.") @@ -9,7 +9,7 @@ (test test-foveal-rendering "Verify that the foveal target is rendered with content, while siblings are skeletal." - (clrhash org-agent::*memory*) + (clrhash opencortex::*memory*) (let* ((ast '(:type :HEADLINE :properties (:ID "proj-root" :TITLE "Project" :TAGS "project") :contents ((:type :HEADLINE :properties (:ID "node-foveal" :TITLE "Foveal Node") :raw-content "FOVEAL CONTENT" :contents nil) @@ -24,7 +24,7 @@ (test test-awareness-budget "Verify that context-assemble-global-awareness handles multiple projects." - (clrhash org-agent::*memory*) + (clrhash opencortex::*memory*) (ingest-ast '(:type :HEADLINE :properties (:ID "p1" :TITLE "Project 1" :TAGS "project") :contents nil)) (ingest-ast '(:type :HEADLINE :properties (:ID "p2" :TITLE "Project 2" :TAGS "project") :contents nil)) (let ((output (context-assemble-global-awareness))) diff --git a/tests/pipeline-tests.lisp b/tests/pipeline-tests.lisp index a60887e..6f37afd 100644 --- a/tests/pipeline-tests.lisp +++ b/tests/pipeline-tests.lisp @@ -1,6 +1,6 @@ -(defpackage :org-agent-pipeline-tests - (:use :cl :fiveam :org-agent)) -(in-package :org-agent-pipeline-tests) +(defpackage :opencortex-pipeline-tests + (:use :cl :fiveam :opencortex)) +(in-package :opencortex-pipeline-tests) (def-suite pipeline-suite :description "Verification of the Reactive Signal Pipeline.") @@ -8,8 +8,8 @@ (defun setup-mock-skills () "Register mock skills for testing." - (clrhash org-agent::*skills-registry*) - (org-agent::defskill :mock-refactor + (clrhash opencortex::*skills-registry*) + (opencortex::defskill :mock-refactor :priority 100 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :command) :organize-subtree)) :probabilistic (lambda (ctx) "Mock probabilistic prompt") @@ -18,7 +18,7 @@ :payload (:action :refactor-subtree :target-id nil :properties (("ID" . "node-123")))))) - (org-agent::defskill :mock-safety + (opencortex::defskill :mock-safety :priority 50 :trigger (lambda (ctx) t) ; always triggers :probabilistic (lambda (ctx) "Mock probabilistic") @@ -26,11 +26,11 @@ (test test-perceive-gate "Perceive gate should update the object store and normalize signal." - (clrhash org-agent::*memory*) + (clrhash opencortex::*memory*) (let* ((signal (list :type :EVENT :payload (list :sensor :buffer-update :ast (list :type :HEADLINE :properties (list :ID "test-node" :TITLE "Test") :contents nil)))) (result (perceive-gate signal))) (is (eq :perceived (getf result :status))) - (is (not (null (gethash "test-node" org-agent::*memory*)))))) + (is (not (null (gethash "test-node" opencortex::*memory*)))))) (test test-decide-gate-safety "Decide gate should block unsafe LLM proposals." @@ -46,7 +46,7 @@ (test test-pipeline-flow-flat "Verify that process-signal correctly executes a signal through gates." (setup-mock-skills) - (clrhash org-agent::*memory*) + (clrhash opencortex::*memory*) (let ((signal (list :type :EVENT :payload (list :sensor :buffer-update)))) (process-signal signal) (pass "Pipeline completed execution."))) @@ -61,7 +61,7 @@ (setf (uiop:getenv "LLM_ENDPOINT") "http://mock") (setf (uiop:getenv "MEMEX_USER") "Amr") (is (not (null (uiop:getenv "LLM_ENDPOINT")))) - (is (stringp (org-agent::get-env "MEMEX_USER")))) + (is (stringp (opencortex::get-env "MEMEX_USER")))) (test test-path-resolution "Verify that context-resolve-path expands environment variables." @@ -72,13 +72,13 @@ (test test-skill-dependencies "Verify that resolve-skill-dependencies correctly flattens the graph." (setup-mock-skills) - (org-agent::defskill :mock-dependent + (opencortex::defskill :mock-dependent :priority 10 :dependencies (list "mock-safety") :trigger (lambda (ctx) nil) :probabilistic nil :deterministic nil) - (let ((deps (org-agent::resolve-skill-dependencies "mock-dependent"))) + (let ((deps (opencortex::resolve-skill-dependencies "mock-dependent"))) (is (member "mock-safety" deps :test #'string-equal)) (is (member "mock-dependent" deps :test #'string-equal)))) @@ -90,7 +90,7 @@ (test test-global-awareness-assembly "Verify that context-assemble-global-awareness reports active projects." - (clrhash org-agent::*memory*) + (clrhash opencortex::*memory*) (ingest-ast (list :type :HEADLINE :properties (list :ID "proj-1" :TITLE "Project Alpha" :TAGS "project") :contents nil)) (let ((awareness (context-assemble-global-awareness))) (is (search "Project Alpha" awareness)) @@ -98,13 +98,13 @@ (test test-micro-rollback "Verify that a pipeline crash triggers an automatic Memory rollback." - (clrhash org-agent::*memory*) - (clrhash org-agent::*history-store*) - (setf org-agent::*object-store-snapshots* nil) + (clrhash opencortex::*memory*) + (clrhash opencortex::*history-store*) + (setf opencortex::*object-store-snapshots* nil) ;; State A (ingest-ast (list :type :HEADLINE :properties (list :ID "node-1" :TITLE "State A") :contents nil)) (setup-mock-skills) - (org-agent::defskill :crashing-skill + (opencortex::defskill :crashing-skill :priority 200 :trigger (lambda (ctx) t) :probabilistic (lambda (ctx) (list :type :REQUEST :payload (list :action :eval :code "(error \"BOOM\")")))