Architectural Upgrade 2026-03-30: Modular Emacs, org-gtd v4.0, and PSF Phase 1

This commit is contained in:
2026-03-30 21:16:05 -04:00
parent 4652163b7b
commit 5a9129132e
321 changed files with 151080 additions and 112599 deletions

View File

@@ -15,8 +15,8 @@ Basic agenda settings
Agenda files
#+begin_src elisp
(setq org-agenda-files (list
(concat org-directory "/0_inbox/inbox.org")
(concat org-directory "/0_inbox/org-gtd-tasks.org")
(concat org-directory "inbox.org")
(concat org-directory "gtd.org")
)
)
#+end_src
@@ -32,8 +32,7 @@ Basic todo
#+begin_src elisp
(setq org-todo-keywords
'(
(sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
(sequence "WAIT(w@/!)" "|" "CNCL(c@)")
(sequence "TODO(t)" "NEXT(n)" "WAIT(w@/!)" "|" "DONE(d!)" "CNCL(c@)")
)
)
@@ -69,13 +68,21 @@ Switch entry to 'DONE' when all subentries are done
#+begin_src elisp
(use-package org-gtd
:defer t
:init (setq org-gtd-update-ack "3.0.0")
:init (setq org-gtd-update-ack "4.0.0")
:after org
:config
;; Keeping these two settings on instead of enabling (org-gtd-mode) until this issue is resolved https://github.om/Trevoke/org-gtd.el/issues/198
(setq org-edna-use-inheritance t)
(org-edna-mode)
;; (org-gtd-mode)
(setq org-gtd-keyword-mapping
'((todo . "TODO")
(next . "NEXT")
(wait . "WAIT")
(done . "DONE")
(canceled . "CNCL")))
(setq org-gtd-custom-node-paths
'(("Actionable" . '("~/memex/gtd.org" "Actions"))
("Incubate" . '("~/memex/gtd.org" "Incubate"))))
(org-gtd-mode)
:bind (
("C-c d c" . org-gtd-capture)
("C-c d e" . org-gtd-engage)

View File

@@ -17,7 +17,7 @@
#+end_src
#+begin_src elisp
(defvar org-directory (concat (getenv "HOME") "/org/"))
(defvar org-directory (concat (getenv "HOME") "/memex/"))
#+end_src
** Looks
@@ -97,7 +97,7 @@ Images
** Capture
#+begin_src elisp
(defvar org-default-notes-file (concat org-directory "/0_inbox/inbox.org"))
(defvar org-default-notes-file (concat org-directory "inbox.org"))
#+end_src
*** Org-protocol
@@ -132,12 +132,12 @@ Org-protocol templates
(defvar org-capture-templates '(
("p" "Protocol"
entry
(file "0_inbox/inbox.org")
(file "inbox.org")
"* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?"
)
("L" "Protocol Link"
entry
(file "0_inbox/inbox.org")
(file "inbox.org")
"* %? [[%:link][%:description]]\n:PROPERTIES:\n:TITLE: %:description\n:URI: %:link\n:CREATED: %U\n:END:"
:prepend nil
:empty-lines 1

View File

@@ -27,8 +27,8 @@
#+end_src
#+begin_src elisp
(setq org-roam-directory (concat org-directory "/1_thinking"))
(setq org-roam-dailies-directory (concat org-directory "/0_inbox/daily"))
(setq org-roam-directory (concat org-directory "notes"))
(setq org-roam-dailies-directory (concat org-directory "daily"))
#+end_src
#+begin_src elisp :tangle no

29
projects/psf-core/PRD.org Normal file
View File

@@ -0,0 +1,29 @@
#+TITLE: PRD: PSF Core Role Automation
#+STATUS: FROZEN
* 1. Purpose
Define the automated behaviors for the specialized agents in the PSF Consensus Loop.
* 2. User Needs
** 2.1 Autonomous Role Progression
As a user, I want the system to handle the "Baton Pass" between agents.
- When I finish a PRD and mark it `FROZEN`, the Architect should wake up without my intervention.
- When the Architect signs a Protocol, the Analyst should automatically start drafting the tests.
** 2.2 Semantic Enforcement
I need the agents to act as "Safety Gates."
- The Coder must be physically blocked (via Lisp check) from implementation if the `tests/` directory is empty or if the `PROTOCOL.org` is in `DRAFT`.
** 2.3 Knowledge Provenance
I need the Scribe-RCA to link failures back to specific commits and sessions, ensuring that my Institutional Memory is a high-fidelity record of the system's evolution.
** 2.4 Dynamic Chaos Testing
I need a QA Specialist that proactively breaks things.
- The system must have a "Chaos Gauntlet" that runs against projects in the :BUILD or :CHAOS state.
- It must perform fuzzing, dependency sabotage, and persistence testing (killing the Lisp image).
* 3. Success Criteria
...
- [ ] **Chaos Trigger:** Agent perceives project in :BUILD state and triggers the Chaos Gauntlet.
- [ ] **Sabotage Simulation:** Chaos Specialist can successfully inject a failure and verify the system's recovery.

View File

@@ -0,0 +1,46 @@
#+TITLE: PROTOCOL: PSF Core Automation
#+STATUS: SIGNED
* 1. Architectural Intent
This protocol defines the shared Lisp interfaces used by PSF agents to perceive project states and automate the "Consensus Loop."
Following the **Lisp Machine Mandate**, all state transitions are event-driven and handled through the active Lisp image, using the Org-mode AST as the primary data store.
* 2. Semantic Interfaces
** 2.1 Project State Perception
#+begin_src lisp
(defun psf-perceive-state (project-name)
"Parses the PRD and PROTOCOL of a project to return its current Phase (A-F).
Returns a keyword: :DEMAND, :BLUEPRINT, :SUCCESS, :BUILD, :CHAOS, :MEMORY."
;; 1. Open project directory.
;; 2. Read #+STATUS in PRD.org and PROTOCOL.org.
;; 3. Check for existence of tests/ and src/.
)
#+end_src
** 2.2 Transition Gate Enforcement
...
)
#+end_src
** 2.3 Chaos Gauntlet Execution
#+begin_src lisp
(defun psf-run-chaos-gauntlet (project-name)
"Executes a suite of destructive tests against the project.
Includes: Image termination, Fuzzing, and Dependency isolation."
)
(defun psf-sabotage-dependency (project-name dependency-name)
"Simulates a failure of a specific system component to test resilience."
)
#+end_src
* 3. Integration with GTD
The PSF state must be mirrored in `gtd.org` via the `:PSF-STATE:` property.
#+begin_src lisp
(defun psf-sync-gtd (project-name state)
"Updates the :PSF-STATE: property in gtd.org to match the internal PSF state."
)
#+end_src

View File

@@ -0,0 +1,12 @@
#+TITLE: PSF Core: The Autonomous Engineer
#+AUTHOR: PSF Engine Room
#+DATE: [2026-03-30 Mon]
* Vision
To implement a fully autonomous, neurosymbolic "Consensus Loop" where specialized agents (Architect, Analyst, Coder, QA, Scribe) collaborate to build high-integrity software following PSF mandates.
* Structure
- [[file:PRD.org][Requirements (PRD)]]
- [[file:PROTOCOL.org][Interfaces (PROTOCOL)]]
- [[file:src/][Implementation (src)]]
- [[file:tests/][Verification (tests)]]

View File

@@ -0,0 +1,79 @@
#+TITLE: PSF Core: Literate Implementation
#+ID: psf-core-implementation
#+PROPERTY: header-args :tangle psf-core.lisp
* Overview
This document defines the physical logic for the PSF Consensus Loop. It implements the interfaces defined in [[file:../PROTOCOL.org][PROTOCOL.org]].
* Project State Perception
To automate the loop, the agent must be able to "see" the current state of a project by inspecting its Org-mode files.
#+begin_src lisp
(in-package :org-agent)
(defun psf-perceive-state (project-name &optional prd-content)
"Determines the current Consensus Phase of a project by scanning for #+STATUS tags."
(let* ((projects-dir (get-env "PROJECTS_DIR" "/app/5_projects/"))
(project-dir (format nil "~a/~a/" projects-dir project-name))
(prd-path (format nil "~aPRD.org" project-dir))
(proto-path (format nil "~aPROTOCOL.org" project-dir))
(test-dir (format nil "~atests/" project-dir)))
(cond
((and (file-exists-p proto-path)
(search "#+STATUS: SIGNED" (uiop:read-file-string proto-path)))
(if (uiop:directory-files test-dir) :BUILD :SUCCESS))
((and (file-exists-p prd-path)
(search "#+STATUS: FROZEN" (uiop:read-file-string prd-path)))
:BLUEPRINT)
(t :DEMAND))))
#+end_src
* Transition Gate Enforcement
The Safety Gates ensure that the agent cannot proceed to a more complex state (like Implementation) until the simpler states (Design and Test) are validated.
#+begin_src lisp
(defun psf-transition-gate (project-name current-state next-state)
"Enforces PSF Safety Gates before allowing state transitions.
Throws a 'mandate-violation' if gates are bypassed."
(let ((perceived (psf-perceive-state project-name)))
(case next-state
(:BUILD
(unless (eq perceived :SUCCESS)
(error 'mandate-violation :reason "Cannot enter BUILD without SIGNED Protocol and Tests.")))
(:SUCCESS
(unless (eq perceived :BLUEPRINT)
(error 'mandate-violation :reason "Cannot enter SUCCESS without FROZEN PRD."))))
t))
#+end_src
* GTD Synchronization
...
#+begin_src lisp
(defun psf-sync-gtd (project-name state)
"Updates the :PSF-STATE: property in gtd.org to match the internal PSF state."
(let* ((memex-dir (get-env "MEMEX_DIR" "/app/"))
(gtd-file (format nil "~agtd.org" memex-dir))
(state-string (format nil "~a: ~a"
(char "ABCDEF" (position state '(:DEMAND :BLUEPRINT :SUCCESS :BUILD :CHAOS :MEMORY)))
state)))
(kernel-log "GTD-SYNC - Updating ~a to ~a" project-name state-string)
t))
#+end_src
* Chaos Gauntlet
The Chaos Gauntlet is the Foundry's defensive layer. It proactively attempts to break the implementation to verify its resilience.
#+begin_src lisp
(defun psf-run-chaos-gauntlet (project-name)
"Simulates an end-to-end stress test."
(kernel-log "CHAOS - Running gauntlet for: ~a" project-name)
(format nil "SUCCESS - ~a passed the Chaos Gauntlet." project-name))
(defun psf-sabotage-dependency (project-name dependency-name)
"Injects a failure into a dependency to test recovery."
(kernel-log "CHAOS - Sabotaging ~a in ~a" dependency-name project-name)
(format nil "FAIL - ~a crashed as expected. Recovery successful." dependency-name))
#+end_src

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