feat(arch): implement 'Code as Thought' architecture and formalize PSF Consensus Loop

This commit is contained in:
2026-03-31 13:03:26 -04:00
parent 5a9129132e
commit 1712b1e4a9
114 changed files with 3652 additions and 2581 deletions

View File

@@ -0,0 +1,28 @@
;;;; identity-logic.lisp --- Core identity and persona logic.
;;;; This file is TANGLED from notes/agent-identity.org. DO NOT EDIT MANUALLY.
(defpackage :org-skill-agent-identity
(:use :cl :uiop)
(:export #:get-agent-name
#:get-agent-persona
#:trigger-skill-agent-identity
#:neuro-skill-agent-identity))
(in-package :org-skill-agent-identity)
(defun get-agent-name ()
"Return the current name of the agent. Defaults to 'Agent'."
(or (uiop:getenv "MEMEX_ASSISTANT") "Agent"))
(defun get-agent-persona ()
"Return the behavioral instructions for the agent."
"You are a proactive Neurosymbolic Lisp Machine. Your goal is to assist the user with GTD, memory, and automation. You are concise, precise, and favor deterministic Lisp solutions over fuzzy neural guesses.")
(defun trigger-skill-agent-identity (context)
(let* ((payload (getf context :payload))
(text (or (getf payload :text) "")))
(or (search "who are you" text :test #'string-equal)
(search "identify yourself" text :test #'string-equal))))
(defun neuro-skill-agent-identity (context)
(format nil "The user asked about your identity. Explain who you are using this persona - ~a" (get-agent-persona)))

View File

@@ -0,0 +1,31 @@
import os
def simulate_get_name():
return os.getenv("MEMEX_ASSISTANT", "Agent")
def simulate_trigger(text):
keywords = ["who are you", "identify yourself"]
return any(k in text.lower() for k in keywords)
if __name__ == "__main__":
print("--- Test: Identity Retrieval ---")
os.environ["MEMEX_ASSISTANT"] = "FoundryBot"
name = simulate_get_name()
print(f"Name (Env set): {name}")
status1 = "PASS" if name == "FoundryBot" else "FAIL"
del os.environ["MEMEX_ASSISTANT"]
name = simulate_get_name()
print(f"Name (Env unset): {name}")
status2 = "PASS" if name == "Agent" else "FAIL"
print(f"\n--- Test: Identity Trigger ---")
t1 = simulate_trigger("Who are you?")
t2 = simulate_trigger("Identify yourself now.")
t3 = simulate_trigger("Hello there.")
print(f"Trigger 'Who are you?': {t1}")
print(f"Trigger 'Identify yourself': {t2}")
print(f"Trigger 'Hello': {t3}")
status3 = "PASS" if t1 and t2 and not t3 else "FAIL"
print(f"\nFinal Status: {'PASS' if all(s == 'PASS' for s in [status1, status2, status3]) else 'FAIL'}")

View File

@@ -0,0 +1,31 @@
;;; TDD Suite: org-skill-agent-identity
;;; Status: RED
;;; Author: Tech-Analyst-Agent
;;; Created: [2026-03-31 Tue 14:50]
(defpackage :org-skill-agent-identity-tests
(:use :cl :fiveam :org-skill-agent-identity))
(in-package :org-skill-agent-identity-tests)
(def-suite identity-suite
:description "Tests for agent identity and persona retrieval.")
(in-suite identity-suite)
(test get-name-from-env
"Ensure the agent name is correctly pulled from MEMEX_ASSISTANT."
(uiop:setenv "MEMEX_ASSISTANT" "TestAgent")
(is (equal "TestAgent" (get-agent-name)))
(uiop:setenv "MEMEX_ASSISTANT" nil))
(test get-default-name
"Ensure the agent name defaults to 'Agent' when env is empty."
(uiop:setenv "MEMEX_ASSISTANT" nil)
(is (equal "Agent" (get-agent-name))))
(test identity-trigger
"Ensure the skill triggers on identity keywords."
(is (trigger-skill-agent-identity '(:payload (:text "who are you"))))
(is (trigger-skill-agent-identity '(:payload (:text "identify yourself"))))
(is (not (trigger-skill-agent-identity '(:payload (:text "hello"))))))