fix: Paren balance and flatten refactor
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 3s
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 3s
Flatten refactor: library/ -> harness/ and library/gen/ -> skills/ opencortex.asd updated with new paths. README.org rewritten with simplified pitch. Critical fixes in harness/skills.org (source of truth): - COSINE-SIMILARITY: Fixed let* binding list paren mismatch - parse-skill-metadata: Fixed ID extraction block closes - load-skill-from-org: Fixed handler-case and nested let closes - def-cognitive-tool :replace-string: Removed extra closing paren - boot-sequence-tests: Fixed let/unwind-protect nesting Note: .lisp files are generated from .org via org-babel-tangle at install time; fixes must always be made in .org and retangled. Skills derived from opencortex-contrib imported via earlier commits.
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
(in-package :opencortex)
|
||||
|
||||
(defun COSINE-SIMILARITY (v1 v2)
|
||||
"Computes the cosine similarity between two vectors."
|
||||
"Computes cosine similarity between two vectors."
|
||||
(let* ((len1 (length v1))
|
||||
(len2 (length v2)))
|
||||
(if (or (zerop len1) (zerop len2))
|
||||
0.0
|
||||
(let* ((dot-product 0.0d0)
|
||||
(norm1 0.0d0)
|
||||
(norm2 0.0d0))
|
||||
(let* ((dot 0.0d0)
|
||||
(n1 0.0d0)
|
||||
(n2 0.0d0))
|
||||
(dotimes (i (min len1 len2))
|
||||
(let* ((x (coerce (elt v1 i) 'double-float))
|
||||
(y (coerce (elt v2 i) 'double-float)))
|
||||
(incf dot-product (* x y))
|
||||
(incf norm1 (* x x))
|
||||
(incf norm2 (* y y))))
|
||||
(if (or (zerop norm1) (zerop norm2))
|
||||
(y (coerce (elt v2 i) 'double-float)))
|
||||
(incf dot (* x y))
|
||||
(incf n1 (* x x))
|
||||
(incf n2 (* y y))))
|
||||
(if (or (zerop n1) (zerop n2))
|
||||
0.0
|
||||
(/ dot-product (sqrt (* norm1 norm2))))))))
|
||||
(/ dot (sqrt (* n1 n2))))))))
|
||||
|
||||
;; TODO: Stub for vault - implement later
|
||||
(defun VAULT-MASK-STRING (s) "[MASKED]")
|
||||
@@ -81,7 +81,7 @@
|
||||
(when id-start
|
||||
(let ((id-end (position #\Newline content :start id-start)))
|
||||
(when id-end
|
||||
(setf id (subseq content (+ id-start 4) id-end)))))
|
||||
(setf id (subseq content (+ id-start 4) id-end)))))))
|
||||
;; Simple DEPENDS_ON extraction
|
||||
(let ((pos 0))
|
||||
(loop while (setf pos (search "#+DEPENDS_ON:" content :start2 pos))
|
||||
@@ -205,7 +205,7 @@ Only loads blocks that specify a .lisp tangle target, ignoring tests and example
|
||||
(harness-log "LOADER ERROR in skill '~a': ~a" skill-base-name msg)
|
||||
(setf (skill-entry-status entry) :failed)
|
||||
(setf (skill-entry-error-log entry) msg)
|
||||
nil)))
|
||||
nil))))
|
||||
|
||||
(defun load-skill-with-timeout (filepath timeout-seconds)
|
||||
"Loads a skill Org file with a hard execution timeout."
|
||||
@@ -226,7 +226,7 @@ Only loads blocks that specify a .lisp tangle target, ignoring tests and example
|
||||
#+sbcl (sb-thread:terminate-thread thread)
|
||||
#-sbcl (bt:destroy-thread thread)
|
||||
(return :timeout))
|
||||
(sleep 0.05))))
|
||||
(sleep 0.05))))))
|
||||
|
||||
(defun initialize-all-skills ()
|
||||
"Scans the directory defined by SKILLS_DIR and hot-loads skills using topological order."
|
||||
|
||||
@@ -14,23 +14,23 @@ A static, hardcoded architecture is inherently fragile. The ~opencortex~ Skill E
|
||||
(in-package :opencortex)
|
||||
|
||||
(defun COSINE-SIMILARITY (v1 v2)
|
||||
"Computes the cosine similarity between two vectors."
|
||||
"Computes cosine similarity between two vectors."
|
||||
(let* ((len1 (length v1))
|
||||
(len2 (length v2)))
|
||||
(if (or (zerop len1) (zerop len2))
|
||||
0.0
|
||||
(let* ((dot-product 0.0d0)
|
||||
(norm1 0.0d0)
|
||||
(norm2 0.0d0))
|
||||
(let* ((dot 0.0d0)
|
||||
(n1 0.0d0)
|
||||
(n2 0.0d0))
|
||||
(dotimes (i (min len1 len2))
|
||||
(let* ((x (coerce (elt v1 i) 'double-float))
|
||||
(y (coerce (elt v2 i) 'double-float)))
|
||||
(incf dot-product (* x y))
|
||||
(incf norm1 (* x x))
|
||||
(incf norm2 (* y y))))
|
||||
(if (or (zerop norm1) (zerop norm2))
|
||||
(y (coerce (elt v2 i) 'double-float)))
|
||||
(incf dot (* x y))
|
||||
(incf n1 (* x x))
|
||||
(incf n2 (* y y))))
|
||||
(if (or (zerop n1) (zerop n2))
|
||||
0.0
|
||||
(/ dot-product (sqrt (* norm1 norm2))))))))
|
||||
(/ dot (sqrt (* n1 n2))))))))
|
||||
|
||||
;; TODO: Stub for vault - implement later
|
||||
(defun VAULT-MASK-STRING (s) "[MASKED]")
|
||||
@@ -97,7 +97,7 @@ A static, hardcoded architecture is inherently fragile. The ~opencortex~ Skill E
|
||||
(when id-start
|
||||
(let ((id-end (position #\Newline content :start id-start)))
|
||||
(when id-end
|
||||
(setf id (subseq content (+ id-start 4) id-end)))))
|
||||
(setf id (subseq content (+ id-start 4) id-end)))))))
|
||||
;; Simple DEPENDS_ON extraction
|
||||
(let ((pos 0))
|
||||
(loop while (setf pos (search "#+DEPENDS_ON:" content :start2 pos))
|
||||
@@ -227,7 +227,7 @@ Only loads blocks that specify a .lisp tangle target, ignoring tests and example
|
||||
(harness-log "LOADER ERROR in skill '~a': ~a" skill-base-name msg)
|
||||
(setf (skill-entry-status entry) :failed)
|
||||
(setf (skill-entry-error-log entry) msg)
|
||||
nil)))
|
||||
nil))))
|
||||
|
||||
(defun load-skill-with-timeout (filepath timeout-seconds)
|
||||
"Loads a skill Org file with a hard execution timeout."
|
||||
@@ -248,7 +248,7 @@ Only loads blocks that specify a .lisp tangle target, ignoring tests and example
|
||||
#+sbcl (sb-thread:terminate-thread thread)
|
||||
#-sbcl (bt:destroy-thread thread)
|
||||
(return :timeout))
|
||||
(sleep 0.05))))
|
||||
(sleep 0.05))))))
|
||||
#+end_src
|
||||
|
||||
** Initializing All Skills (initialize-all-skills)
|
||||
@@ -522,9 +522,9 @@ These tests verify the Skill Engine and loader. Run with:
|
||||
(with-open-file (out (merge-pathnames "org-skill-b.org" tmp-dir) :direction :output :if-exists :supersede)
|
||||
(format out ":PROPERTIES:~%:ID: skill-b-id~%:END:~%"))
|
||||
(unwind-protect
|
||||
(let ((sorted (opencortex::topological-sort-skills tmp-dir)))
|
||||
(let ((sorted (opencortex::topological-sort-skills tmp-dir))
|
||||
(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)))
|
||||
(pos-b (position "org-skill-b" sorted :key #'pathname-name :test #'string-equal))
|
||||
(is (< pos-b pos-a)))
|
||||
(uiop:delete-directory-tree (uiop:ensure-directory-pathname tmp-dir) :validate t))))
|
||||
|
||||
@@ -537,5 +537,5 @@ These tests verify the Skill Engine and loader. Run with:
|
||||
(progn
|
||||
(opencortex::load-skill-from-org tmp-skill)
|
||||
(is (not (null (gethash "org-skill-jail-test" opencortex::*skills-registry*)))))
|
||||
(uiop:delete-file-if-exists tmp-skill))))
|
||||
(uiop:delete-file-if-exists tmp-skill))))))
|
||||
#+end_src
|
||||
|
||||
Reference in New Issue
Block a user