fix(chaos): use standard getenv for absolute tangle paths

This commit is contained in:
2026-04-28 17:57:57 -04:00
parent d787981d0d
commit d55384fb65
35 changed files with 234 additions and 234 deletions

View File

@@ -18,31 +18,31 @@ To ensure OpenCortex behaves as a first-class POSIX citizen, we adopt the **XDG
4. **Bin (`~/.local/bin`)**: The CLI shim for global invocation.
** The Detection Invariant: Shell Probing
Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure that missing variables are handled as logic failures, not type crashes. Furthermore, binary detection must use a shell probe (`command -v` or `which`) to account for varying `$PATH` inheritance between interactive and headless sessions.
Common Lisp's `getenv` is strictly typed in SBCL. The Doctor must ensure that missing variables are handled as logic failures, not type crashes. Furthermore, binary detection must use a shell probe (`command -v` or `which`) to account for varying `$PATH` inheritance between interactive and headless sessions.
* Phase B: Protocol (Success Criteria)
** Package Context
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests"))
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-doctor-tests
(:use :cl :fiveam :opencortex)
(:export #:doctor-suite))
#+end_src
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests"))
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(in-package :opencortex-doctor-tests)
#+end_src
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests"))
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(def-suite doctor-suite :description "Verification of the System Doctor diagnostic logic")
#+end_src
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests"))
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(in-suite doctor-suite)
#+end_src
** Dependency Tests
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests"))
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(test test-dependency-check-fail
"Verify that missing binaries are correctly identified as failures."
(let ((opencortex::*doctor-required-binaries* '("non-existent-binary-123")))
@@ -50,34 +50,34 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src
** Environment Tests
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests"))
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(test test-env-validation-fail
"Verify that an invalid MEMEX_DIR triggers a critical failure."
(let ((old-m (uiop:getenv "MEMEX_DIR"))
(old-s (uiop:getenv "SKILLS_DIR")))
(let ((old-m (getenv "MEMEX_DIR"))
(old-s (getenv "SKILLS_DIR")))
(unwind-protect
(progn
(setf (uiop:getenv "MEMEX_DIR") "/non/existent/path/999")
(setf (getenv "MEMEX_DIR") "/non/existent/path/999")
(is (null (opencortex:doctor-check-env))))
(setf (uiop:getenv "MEMEX_DIR") (or old-m ""))
(setf (uiop:getenv "SKILLS_DIR") (or old-s "")))))
(setf (getenv "MEMEX_DIR") (or old-m ""))
(setf (getenv "SKILLS_DIR") (or old-s "")))))
#+end_src
* Phase C: Implementation (Build)
** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
#+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(in-package :opencortex)
#+end_src
** Global Configuration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
#+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defvar *doctor-required-binaries* '("sbcl" "emacs" "git" "socat" "nc")
"List of external binaries required for full system operation.")
#+end_src
** Dependency Verification
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
#+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-check-dependencies ()
"Verifies that required external binaries are available in the PATH via a shell probe."
(let ((all-ok t))
@@ -95,15 +95,15 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src
** Environment & XDG Validation
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
#+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-check-env ()
"Validates XDG directories and environment configuration against the POSIX standard."
(harness-log "DOCTOR: Checking XDG environment...")
(let ((all-ok t)
(config-dir (uiop:getenv "OC_CONFIG_DIR"))
(data-dir (uiop:getenv "OC_DATA_DIR"))
(state-dir (uiop:getenv "OC_STATE_DIR"))
(memex-dir (uiop:getenv "MEMEX_DIR")))
(config-dir (getenv "OC_CONFIG_DIR"))
(data-dir (getenv "OC_DATA_DIR"))
(state-dir (getenv "OC_STATE_DIR"))
(memex-dir (getenv "MEMEX_DIR")))
(flet ((check-dir (name path critical)
(if (and path (> (length path) 0))
@@ -124,11 +124,11 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src
** LLM Connectivity
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
#+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-check-llm ()
"Tests connectivity to primary LLM providers. Non-critical fallback allowed."
(harness-log "DOCTOR: Checking LLM connectivity...")
(let ((openrouter-key (uiop:getenv "OPENROUTER_API_KEY")))
(let ((openrouter-key (getenv "OPENROUTER_API_KEY")))
(if (and openrouter-key (> (length openrouter-key) 0))
(progn
(harness-log " [OK] OpenRouter API Key detected.")
@@ -139,7 +139,7 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src
** Orchestration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
#+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-run-all ()
"Executes the full diagnostic suite and returns T if system is healthy."
(harness-log "==================================================")
@@ -159,7 +159,7 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src
** CLI Entry Point
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
#+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-main ()
"Entry point for the 'doctor' CLI command."
(if (doctor-run-all)