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,44 @@
import os
import shutil
def simulate_scaffold(name, type, projects_dir, gtd_file):
project_dir = os.path.join(projects_dir, name)
if os.path.exists(project_dir):
return f"ERROR - Project {name} already exists."
# 1. Create Structure
os.makedirs(os.path.join(project_dir, "src"))
os.makedirs(os.path.join(project_dir, "tests"))
os.makedirs(os.path.join(project_dir, "docs"))
# 2. Create Boilerplate
with open(os.path.join(project_dir, "README.org"), "w") as f:
f.write(f"#+TITLE: {name}\n#+CREATED: [2026-03-31]\n")
# 3. GTD Integration
with open(gtd_file, "a") as f:
f.write(f"\n** NEXT {name}\n :PROPERTIES:\n :ID: proj-{name}\n :END:\n")
return f"SUCCESS - PSF Project {name} scaffolded."
if __name__ == "__main__":
test_projects_dir = "/tmp/psf_test_projects"
test_gtd_file = "/tmp/psf_test_gtd.org"
if os.path.exists(test_projects_dir):
shutil.rmtree(test_projects_dir)
os.makedirs(test_projects_dir)
with open(test_gtd_file, "w") as f:
f.write("* Projects\n")
print("--- Test: Project Scaffolding ---")
result = simulate_scaffold("test-project", "Lisp", test_projects_dir, test_gtd_file)
print(result)
# Verify
if os.path.exists(os.path.join(test_projects_dir, "test-project/src")) and "test-project" in open(test_gtd_file).read():
print("Status: PASS")
else:
print("Status: FAIL")

View File

@@ -0,0 +1,61 @@
#+TITLE: PSF Core: Literate Verification
#+ID: psf-core-verification
#+PROPERTY: header-args :tangle test-suite.lisp
* Overview
This document defines the **Success Criteria** for the PSF Core Role Automation. It ensures that our agents are perceiving and enforcing the Consensus Loop correctly.
* Test Setup
#+begin_src lisp
(defpackage :psf-core-tests
(:use :cl :fiveam :org-agent))
(in-package :psf-core-tests)
(def-suite psf-core-suite :description "Consensus Loop Automation Tests")
(in-suite psf-core-suite)
#+end_src
* 1. Perception Logic
We must verify that the agent can distinguish between a Draft PRD and a Frozen PRD.
#+begin_src lisp
(test perceive-frozen-prd
"Verify that a project with a FROZEN PRD is correctly identified as being in Phase B."
(let ((mock-prd "#+TITLE: Mock\n#+STATUS: FROZEN"))
(is (eq :BLUEPRINT (psf-perceive-state "mock-project" mock-prd)))))
#+end_src
* 2. Mandate Enforcement
The system must raise a `mandate-violation` if a transition to the Build phase is attempted without passing the Quality gate (Tests).
#+begin_src lisp
(test block-build-without-tests
"Ensure the system blocks transition to :BUILD if the tests directory is missing or empty."
(let ((mock-project "empty-project"))
(signals mandate-violation
(psf-transition-gate mock-project :SUCCESS :BUILD))))
#+end_src
* 3. GTD Integration
...
#+begin_src lisp
(test sync-gtd-property
"Verify that the :PSF-STATE: property update returns success."
(is (eq t (psf-sync-gtd "mock-project" :BLUEPRINT))))
#+end_src
* 4. Chaos Integrity
The Chaos Gauntlet must be able to simulate a dependency failure and return a report.
#+begin_src lisp
(test simulate-sabotage
"Verify that the Chaos Specialist can detect an injected failure."
(let ((project "chaos-test"))
(is (search "FAIL" (psf-sabotage-dependency project "sqlite3")))))
#+end_src
* Execution
#+begin_src lisp
(run! 'psf-core-suite)
#+end_src