feat(psf): complete high-integrity loop for advanced features

This commit is contained in:
2026-03-31 18:28:47 -04:00
parent b3d89f88e5
commit 46356535c8
16 changed files with 736 additions and 195 deletions

View File

@@ -0,0 +1,24 @@
(defpackage :org-skill-persistence-tests
(:use :cl :fiveam :org-skill-object-store-persistence))
(in-package :org-skill-persistence-tests)
(def-suite persistence-suite
:description "Tests for Object Store serialization fidelity.")
(in-suite persistence-suite)
(test serialize-org-object
"Ensure a complex org-object struct can be dumped and re-read exactly."
(let ((obj (org-agent:make-org-object
:id "test-uuid"
:type :HEADLINE
:attributes '(:TITLE "Test Note" :TODO-STATE "TODO")
:children '("child-1" "child-2"))))
(let ((serialized (prin1-to-string `(setf (gethash "test-uuid" org-agent:*object-store*) ,obj))))
;; Read back the form
(let ((recovered-form (read-from-string serialized)))
(let ((recovered-obj (nth 2 (nth 2 recovered-form))))
(is (equal (org-agent:org-object-id recovered-obj) "test-uuid"))
(is (eq (org-agent:org-object-type recovered-obj) :HEADLINE))
(is (equal (getf (org-agent:org-object-attributes recovered-obj) :TITLE) "Test Note")))))))

View File

@@ -0,0 +1,22 @@
def simulate_calculate_rate(executions, failures):
if executions == 0:
return 0
return (failures / executions) * 100
if __name__ == "__main__":
print("--- Test 1: Healthy Skill ---")
r1 = simulate_calculate_rate(100, 2)
print(f"Rate: {r1}%")
status1 = "PASS" if r1 == 2.0 else "FAIL"
print("\n--- Test 2: Failing Skill (Threshold Breach) ---")
r2 = simulate_calculate_rate(50, 25)
print(f"Rate: {r2}%")
status2 = "PASS" if r2 == 50.0 else "FAIL"
print("\n--- Test 3: Zero Execution Grace ---")
r3 = simulate_calculate_rate(0, 0)
print(f"Rate: {r3}%")
status3 = "PASS" if r3 == 0 else "FAIL"
print(f"\nFinal Status: {'PASS' if all(s == 'PASS' for s in [status1, status2, status3]) else 'FAIL'}")

View File

@@ -0,0 +1,33 @@
import re
def simulate_harness_walk(form, whitelist):
if isinstance(form, str):
return True
if isinstance(form, list):
fn = form[0]
if fn not in whitelist:
return False
return all(simulate_harness_walk(arg, whitelist) for arg in form[1:])
return True
if __name__ == "__main__":
whitelist = ["message", "insert", "plist-get", "list", "quote"]
print("--- Test 1: Safe Call ---")
safe_form = ["message", "Hello World"]
res1 = simulate_harness_walk(safe_form, whitelist)
print(f"Result: {res1}")
print("\n--- Test 2: Unsafe Call (Direct) ---")
unsafe_form = ["shell-command", "rm -rf /"]
res2 = simulate_harness_walk(unsafe_form, whitelist)
print(f"Result: {res2}")
print("\n--- Test 3: Nested Malicious Call ---")
# (message (shell-command "evil"))
nested_form = ["message", ["shell-command", "evil"]]
res3 = simulate_harness_walk(nested_form, whitelist)
print(f"Result: {res3}")
status = "PASS" if res1 and not res2 and not res3 else "FAIL"
print(f"\nFinal Status: {status}")

View File

@@ -0,0 +1,13 @@
(defpackage :org-skill-sub-agent-tests
(:use :cl :fiveam :org-skill-sub-agent-manager))
(in-package :org-skill-sub-agent-tests)
(test spawn-thread-and-registry
"Ensure a sub-agent thread is created and added to the registry."
(let ((initial-count (length org-skill-sub-agent-manager::*active-sub-agents*)))
(sub-agent-spawn "Test Goal" '(:test-context t))
(is (= (1+ initial-count) (length org-skill-sub-agent-manager::*active-sub-agents*)))
(let ((spawned (car org-skill-sub-agent-manager::*active-sub-agents*)))
(is (bt:threadp spawned))
(is (bt:thread-alive-p spawned)))))