diff --git a/lisp/core-defpackage.lisp b/lisp/core-defpackage.lisp index adc5a23..e7aba4b 100644 --- a/lisp/core-defpackage.lisp +++ b/lisp/core-defpackage.lisp @@ -15,12 +15,13 @@ #:stop-daemon #:log-message #:main - #:doctor-run-all - #:doctor-main - #:doctor-check-dependencies - #:doctor-check-env - #:register-provider - #:system-ready-p + #:diagnostics-run-all + #:diagnostics-main + #:diagnostics-dependencies-check + #:diagnostics-env-check + #:register-provider + #:provider-openai-request + #:system-ready-p #:run-setup-wizard #:skill-gateway-register #:skill-gateway-link @@ -242,7 +243,7 @@ (format t "┌─────────────────────────────────────────────┐~%") (format t "│ ERROR: ~A~%" (type-of condition)) (format t "│~%") - (format t "│ Run: passepartout doctor~%") + (format t "│ Run: passepartout diagnostics~%") (format t "│ For system diagnostics~%") (format t "└─────────────────────────────────────────────┘~%") (format t "~%") diff --git a/lisp/core-loop.lisp b/lisp/core-loop.lisp index d8c04b8..6e280a5 100644 --- a/lisp/core-loop.lisp +++ b/lisp/core-loop.lisp @@ -88,8 +88,8 @@ (format t "==================================================~%") (handler-case (progn - (when (fboundp 'doctor-run-all) - (let ((result (doctor-run-all :auto-install nil))) + (when (fboundp 'diagnostics-run-all) + (let ((result (diagnostics-run-all :auto-install nil))) (setf *health-check-ran* t) (if result (progn @@ -98,10 +98,10 @@ (progn (setf *system-health* :degraded) (format t "DAEMON: Health check found issues.~%") - (format t " Run 'passepartout doctor --fix' to repair.~%"))))) + (format t " Run 'passepartout diagnostics' to repair.~%"))))) (setf *health-check-ran* t)) (error (c) - (format t "DOCTOR ERROR: ~a~%" c) + (format t "DIAGNOSTICS ERROR: ~a~%" c) (setf *system-health* :unhealthy) (setf *health-check-ran* t))) (format t "==================================================~%~%")) @@ -117,7 +117,7 @@ (actuator-initialize) (skill-initialize-all) - ;; Run proactive doctor before starting services + ;; Run proactive diagnostics before starting services (diagnostics-startup-run) (heartbeat-start) diff --git a/lisp/gateway-tui-main.lisp b/lisp/gateway-tui-main.lisp index 28fb8a3..9b1d5b8 100644 --- a/lisp/gateway-tui-main.lisp +++ b/lisp/gateway-tui-main.lisp @@ -162,4 +162,4 @@ (redraw sw cw ch iw) (refresh scr) (sleep 0.03)) - (disconnect-daemon)))) + (disconnect-daemon)))) diff --git a/lisp/system-diagnostics.lisp b/lisp/system-diagnostics.lisp index 8f02f6c..adfdf69 100644 --- a/lisp/system-diagnostics.lisp +++ b/lisp/system-diagnostics.lisp @@ -1,3 +1,5 @@ +(in-package :passepartout) + (defvar *diagnostics-binaries* '("sbcl" "emacs" "git" "socat" "nc") "List of external binaries required for full system operation.") diff --git a/org/core-defpackage.org b/org/core-defpackage.org index 1f016e7..ea95848 100644 --- a/org/core-defpackage.org +++ b/org/core-defpackage.org @@ -40,12 +40,13 @@ The package definition. All public symbols are exported here. #:stop-daemon #:log-message #:main - #:doctor-run-all - #:doctor-main - #:doctor-check-dependencies - #:doctor-check-env - #:register-provider - #:system-ready-p + #:diagnostics-run-all + #:diagnostics-main + #:diagnostics-dependencies-check + #:diagnostics-env-check + #:register-provider + #:provider-openai-request + #:system-ready-p #:run-setup-wizard #:skill-gateway-register #:skill-gateway-link @@ -304,7 +305,7 @@ Friendly error handler that replaces the raw SBCL debugger with a diagnostic mes (format t "┌─────────────────────────────────────────────┐~%") (format t "│ ERROR: ~A~%" (type-of condition)) (format t "│~%") - (format t "│ Run: passepartout doctor~%") + (format t "│ Run: passepartout diagnostics~%") (format t "│ For system diagnostics~%") (format t "└─────────────────────────────────────────────┘~%") (format t "~%") diff --git a/org/core-loop.org b/org/core-loop.org index 236caed..1cbbf54 100644 --- a/org/core-loop.org +++ b/org/core-loop.org @@ -225,8 +225,8 @@ This is the "fail open" principle applied to boot: the system should start even (format t "==================================================~%") (handler-case (progn - (when (fboundp 'doctor-run-all) - (let ((result (doctor-run-all :auto-install nil))) + (when (fboundp 'diagnostics-run-all) + (let ((result (diagnostics-run-all :auto-install nil))) (setf *health-check-ran* t) (if result (progn @@ -235,10 +235,10 @@ This is the "fail open" principle applied to boot: the system should start even (progn (setf *system-health* :degraded) (format t "DAEMON: Health check found issues.~%") - (format t " Run 'passepartout doctor --fix' to repair.~%"))))) + (format t " Run 'passepartout diagnostics' to repair.~%"))))) (setf *health-check-ran* t)) (error (c) - (format t "DOCTOR ERROR: ~a~%" c) + (format t "DIAGNOSTICS ERROR: ~a~%" c) (setf *system-health* :unhealthy) (setf *health-check-ran* t))) (format t "==================================================~%~%")) @@ -272,7 +272,7 @@ Boot sequence: (actuator-initialize) (skill-initialize-all) - ;; Run proactive doctor before starting services + ;; Run proactive diagnostics before starting services (diagnostics-startup-run) (heartbeat-start) diff --git a/org/core-manifest.org b/org/core-manifest.org index 49e6ec8..497f1b0 100644 --- a/org/core-manifest.org +++ b/org/core-manifest.org @@ -51,9 +51,9 @@ Note: not every harness or skill file has a corresponding test file. Tests exist (:file "tests/programming-lisp-tests") (:file "tests/boot-sequence-tests") (:file "tests/model-explorer-tests") + (:file "tests/diagnostics-tests") (:file "tests/tui-tests") - (:file "tests/llm-gateway-tests") - (:file "tests/doctor-tests"))) + (:file "tests/llm-gateway-tests"))) #+end_src ** TUI System diff --git a/org/gateway-tui-main.org b/org/gateway-tui-main.org index 052b220..ef59b1c 100644 --- a/org/gateway-tui-main.org +++ b/org/gateway-tui-main.org @@ -180,5 +180,30 @@ Event handlers + daemon I/O + main loop. (redraw sw cw ch iw) (refresh scr) (sleep 0.03)) - (disconnect-daemon)))) + (disconnect-daemon)))) + +#+end_src + +* Test Suite +#+begin_src lisp :tangle ../tests/tui-tests.lisp +(eval-when (:compile-toplevel :load-toplevel :execute) + (ql:quickload :fiveam :silent t)) + +(defpackage :passepartout-tui-tests + (:use :cl :passepartout) + (:export #:tui-suite)) + +(in-package :passepartout-tui-tests) + +(fiveam:def-suite tui-suite :description "Verification of the TUI parsing and styling logic") +(fiveam:in-suite tui-suite) + +(fiveam:test test-tui-connection-drop + "Tier 2 Chaos: Verify that handle-return degrades gracefully when the daemon connection is lost." + (let ((passepartout.gateway-tui::*incoming-msgs* nil) + (passepartout.gateway-tui::*input-buffer* (make-array 5 :element-type 'character :initial-contents "hello" :fill-pointer 5 :adjustable t)) + (mock-stream (make-string-output-stream))) + (close mock-stream) + (passepartout.gateway-tui::handle-return mock-stream) + (fiveam:is (member "ERROR: Connection to daemon lost." passepartout.gateway-tui::*incoming-msgs* :test #'string=)))) #+end_src diff --git a/org/system-diagnostics.org b/org/system-diagnostics.org index 2ba5fd8..d2ccf03 100644 --- a/org/system-diagnostics.org +++ b/org/system-diagnostics.org @@ -21,6 +21,11 @@ Binary detection must use shell probing (`which`) to account for varying `$PATH` * Phase C: Implementation (Build) +** Package Context +#+begin_src lisp +(in-package :passepartout) +#+end_src + ** Global Configuration ;; REPL-VERIFIED: 2026-05-03T13:00:00 #+begin_src lisp @@ -238,24 +243,34 @@ The doctor checks all supported LLM providers and detects local Ollama instances * Phase D: Verification (Testing) -** Dependency Test -#+begin_src lisp :tangle no -(test test-doctor-dependency-check +#+begin_src lisp :tangle ../tests/diagnostics-tests.lisp +(eval-when (:compile-toplevel :load-toplevel :execute) + (ql:quickload :fiveam :silent t)) + +(defpackage :passepartout-diagnostics-tests + (:use :cl :fiveam :passepartout) + (:export #:diagnostics-suite)) + +(in-package :passepartout-diagnostics-tests) + +(def-suite diagnostics-suite :description "Verification of the System Diagnostics logic") +(in-suite diagnostics-suite) + +(test test-diagnostics-dependency-fail "Verify that missing binaries are correctly identified as failures." (let ((passepartout::*diagnostics-binaries* '("non-existent-binary-123"))) - (is (null (passepartout:diagnostics-dependencies-check))))) -#+end_src + (is (null (diagnostics-dependencies-check))))) -** Environment Test -#+begin_src lisp :tangle no -(test test-doctor-env-check +(test test-diagnostics-env-fail "Verify that an invalid MEMEX_DIR triggers a critical failure." - (let ((old-m (uiop:getenv "MEMEX_DIR"))) + (let ((old-m (uiop:getenv "MEMEX_DIR")) + (old-d (uiop:getenv "PASSEPARTOUT_DATA_DIR"))) (unwind-protect (progn (setf (uiop:getenv "MEMEX_DIR") "/non/existent/path/999") - (is (null (passepartout:diagnostics-env-check)))) - (setf (uiop:getenv "MEMEX_DIR") (or old-m ""))))) + (is (null (diagnostics-env-check)))) + (setf (uiop:getenv "MEMEX_DIR") (or old-m "")) + (setf (uiop:getenv "PASSEPARTOUT_DATA_DIR") (or old-d ""))))) #+end_src * Phase E: Lifecycle diff --git a/org/system-model-provider.org b/org/system-model-provider.org index 937dd0b..57212fa 100644 --- a/org/system-model-provider.org +++ b/org/system-model-provider.org @@ -161,3 +161,23 @@ If API-KEY is nil, reads from environment." :priority 50 :trigger (lambda (ctx) (declare (ignore ctx)) nil)) #+end_src + +* Test Suite +#+begin_src lisp :tangle ../tests/llm-gateway-tests.lisp +(eval-when (:compile-toplevel :load-toplevel :execute) + (ql:quickload :fiveam :silent t)) + +(defpackage :passepartout-llm-gateway-tests + (:use :cl :passepartout) + (:export #:llm-gateway-suite)) + +(in-package :passepartout-llm-gateway-tests) + +(fiveam:def-suite llm-gateway-suite :description "Tests for the LLM provider backend") +(fiveam:in-suite llm-gateway-suite) + +(fiveam:test test-provider-rejects-bad-keyword + "Verify that provider-openai-request returns :error for an unregistered provider." + (let ((result (provider-openai-request "hello" "test" :provider :not-a-real-provider))) + (fiveam:is (eq (getf result :status) :error)))) +#+end_src diff --git a/passepartout.asd b/passepartout.asd index 6ac172a..6638e5c 100644 --- a/passepartout.asd +++ b/passepartout.asd @@ -22,9 +22,9 @@ (:file "tests/programming-lisp-tests") (:file "tests/boot-sequence-tests") (:file "tests/model-explorer-tests") + (:file "tests/diagnostics-tests") (:file "tests/tui-tests") - (:file "tests/llm-gateway-tests") - (:file "tests/doctor-tests"))) + (:file "tests/llm-gateway-tests"))) (defsystem :passepartout/tui :depends-on (:passepartout :croatoan :usocket :bordeaux-threads)