REFAC: Global rename of org-agent to opencortex

This commit is contained in:
2026-04-14 12:10:11 -04:00
parent b58b780a44
commit 849c078c37
95 changed files with 662 additions and 642 deletions

View File

@@ -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 (")))))

View File

@@ -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)))))

View File

@@ -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))

View File

@@ -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.")

View File

@@ -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))))))

View File

@@ -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)))

View File

@@ -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\")")))