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,42 @@
import os
import re
def simulate_distill(title, content, source):
filename = title.lower().replace(" ", "_") + ".org"
target_path = os.path.join("notes", filename)
# Mocking the note creation
note_content = f"#+TITLE: {title}\n#+ID: mock-id\n\nSource: [[file:{source}]]\n\n{content}"
# In simulation, we just verify the content structure
if f"Source: [[file:{source}]]" in note_content and title in note_content:
return target_path
return None
def simulate_audit(project_path):
violations = []
if not os.path.exists(os.path.join(project_path, "PRD.org")):
violations.append("MISSING_PRD")
if not os.path.exists(os.path.join(project_path, "PROTOCOL.org")):
violations.append("MISSING_PROTOCOL")
return violations
if __name__ == "__main__":
# Test 1: Distillation
path = simulate_distill("Lisp Sovereignty", "Control the code.", "daily/2026-03-31.org")
print(f"--- Test: Distillation ---")
print(f"Target Path: {path}")
print(f"Status: {'PASS' if path == 'notes/lisp_sovereignty.org' else 'FAIL'}")
# Test 2: Audit (Current Project)
print(f"\n--- Test: Audit (org-skill-scribe) ---")
violations = simulate_audit("projects/org-skill-scribe")
print(f"Violations: {violations}")
print(f"Status: {'PASS' if not violations else 'FAIL'}")
# Test 3: Audit (A broken project if exists)
# We'll just mock a non-existent one
print(f"\n--- Test: Audit (Non-existent) ---")
violations = simulate_audit("projects/missing-project")
print(f"Violations: {violations}")
print(f"Status: {'PASS' if 'MISSING_PRD' in violations else 'FAIL'}")

View File

@@ -0,0 +1,49 @@
;;; TDD Suite: org-skill-scribe (Distillation & Audit)
;;; Status: RED
;;; Author: Tech-Analyst-Agent
;;; Created: [2026-03-31 Tue 14:00]
(defpackage :org-skill-scribe-tests
(:use :cl :fiveam :org-skill-scribe))
(in-package :org-skill-scribe-tests)
(def-suite scribe-pipeline-suite
:description "Tests for the Scribe distillation and audit pipeline.")
(in-suite scribe-pipeline-suite)
;;; --- 2.1 State Perception Tests ---
(test scan-for-knowledge-gaps
"Ensure the scribe correctly identifies new daily files via Git."
;; Requires mock Git environment
(skip "Mock Git environment required."))
;;; --- 2.2 Concept Distillation Tests ---
(test distill-concept-with-backlink
"Ensure a concept is transformed into an atomic note with provenance."
(let ((daily-path "/tmp/scribe-daily.org")
(concept '(:title "Lisp Machine Mandate"
:content "The system must be fully introspectable."
:source "daily/2026-03-31.org")))
(let ((note-path (scribe-distill-concept daily-path concept)))
(is (cl-ppcre:scan "lisp_machine_mandate.org" note-path))
(is (cl-ppcre:scan "Source: \\[\\[file:daily/2026-03-31.org\\]\\]"
(uiop:read-file-string note-path))))))
;;; --- 2.3 Mandate Auditing Tests ---
(test audit-compliant-project
"Ensure a project with PRD and PROTOCOL passes the audit."
(let ((project-name "compliant-project"))
;; Logic to scaffold a mock compliant project
(is (null (scribe-audit-foundry-mandate project-name)))))
(test audit-missing-protocol
"Ensure a project missing a PROTOCOL.org is flagged."
(let ((project-name "broken-project"))
;; Logic to scaffold a mock project missing protocol
(let ((violations (scribe-audit-foundry-mandate project-name)))
(is (member :missing-protocol violations)))))