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,34 @@
;;;; config-logic.lisp --- Homoiconic configuration retrieval.
;;;; This file is TANGLED from notes/environment-config.org. DO NOT EDIT MANUALLY.
(defpackage :org-skill-environment-config
(:use :cl)
(:export #:get-config-attribute
#:get-tiered-model))
(in-package :org-skill-environment-config)
(defun get-config-attribute (property-key &optional default)
"Searches the global *object-store* for any headline containing PROPERTY-KEY."
;; Note: In a real environment, this would access the org-agent:*object-store*
;; For the purpose of this skill implementation, we define the signature.
(let ((store (and (boundp 'org-agent:*object-store*) org-agent:*object-store*)))
(if store
(maphash (lambda (id obj)
(declare (ignore id))
(when (eq (org-agent:org-object-type obj) :HEADLINE)
(let ((val (getf (org-agent:org-object-attributes obj) property-key)))
(when val
(return-from get-config-attribute val)))))
store)
default))
default)
(defun get-tiered-model (tier default-model)
"Retrieves a model ID based on a tier keyword (:POWERFUL, :FAST, :FREE)."
(let ((prop (case tier
(:powerful :LLM_MODEL_POWERFUL)
(:fast :LLM_MODEL_FAST)
(:free :LLM_MODEL_FREE)
(t :LLM_MODEL_TEXT))))
(get-config-attribute prop default-model)))

View File

@@ -0,0 +1,26 @@
def simulate_get_tiered_model(tier, mock_store):
mapping = {
"powerful": "LLM_MODEL_POWERFUL",
"fast": "LLM_MODEL_FAST",
"free": "LLM_MODEL_FREE"
}
prop_key = mapping.get(tier.lower(), "LLM_MODEL_TEXT")
return mock_store.get(prop_key, "gpt-3.5-turbo") # Default
if __name__ == "__main__":
mock_store = {
"LLM_MODEL_POWERFUL": "claude-3-opus",
"LLM_MODEL_FAST": "gpt-4o-mini"
}
print("--- Test: Tier Resolution ---")
m1 = simulate_get_tiered_model("powerful", mock_store)
m2 = simulate_get_tiered_model("fast", mock_store)
m3 = simulate_get_tiered_model("free", mock_store) # Not in store
print(f"Powerful: {m1}")
print(f"Fast: {m2}")
print(f"Free (Default): {m3}")
status = "PASS" if m1 == "claude-3-opus" and m2 == "gpt-4o-mini" and m3 == "gpt-3.5-turbo" else "FAIL"
print(f"\nFinal Status: {status}")

View File

@@ -0,0 +1,24 @@
;;; TDD Suite: org-skill-environment-config
;;; Status: RED
;;; Author: Tech-Analyst-Agent
;;; Created: [2026-03-31 Tue 15:10]
(defpackage :org-skill-environment-config-tests
(:use :cl :fiveam :org-skill-environment-config))
(in-package :org-skill-environment-config-tests)
(def-suite config-suite
:description "Tests for homoiconic configuration retrieval.")
(in-suite config-suite)
(test retrieve-attribute
"Ensure a property can be retrieved from a mock object store."
;; Requires mock object store logic
(skip "Mock object store required."))
(test model-tiering-resolution
"Ensure tiers are mapped to the correct properties."
;; We can mock get-config-attribute to test the mapping logic
(skip "Internal mapping test required."))