diff --git a/docs/.#DESIGN_DECISIONS.org b/docs/.#DESIGN_DECISIONS.org new file mode 120000 index 0000000..8ab6b0e --- /dev/null +++ b/docs/.#DESIGN_DECISIONS.org @@ -0,0 +1 @@ +user@amr.1407003:1778162380 \ No newline at end of file diff --git a/docs/DESIGN_DECISIONS.org b/docs/DESIGN_DECISIONS.org index bf4ffb9..6055b68 100644 --- a/docs/DESIGN_DECISIONS.org +++ b/docs/DESIGN_DECISIONS.org @@ -948,8 +948,6 @@ For the philosophical foundations, see the Whitehead analysis in the Validation Alfred North Whitehead's two major bodies of work — /Principia Mathematica/ (1910–1913, with Bertrand Russell) and /Process and Reality/ (1929) — provide both the historical foundation and the descriptive vocabulary for Passepartout's architecture. The first gave us the type theory that structures the gate stack; the second gave us the process ontology that describes the pipeline. -*** Historical Connection: PM → Lisp - /Principia Mathematica/ is a direct ancestor of Lisp. Alonzo Church's lambda calculus (1930s), from which John McCarthy built Lisp (1958), was a response to PM's foundational program. PM's notation: #+BEGIN_EXAMPLE @@ -961,8 +959,6 @@ Alfred North Whitehead's two major bodies of work — /Principia Mathematica/ (1 These map directly to Lisp: ~(lambda (x) (φ x))~, ~(class (x) (φ x))~, ~(the (x) (φ x))~. McCarthy cited PM as an influence. The connection is genetic, not metaphorical. -*** Process Philosophy as Architectural Vocabulary - Whitehead's process philosophy is a metaphysics of /becoming/ rather than /being/. The fundamental entities are not substances but /processes/ (/actual entities/, /occasions of experience/). This maps precisely to Passepartout's pipeline architecture: | Whiteheadian Concept | Passepartout Mapping | Significance | @@ -984,12 +980,8 @@ The foveal-peripheral model maps directly onto Whitehead's two modes of percepti Whitehead also gives Passepartout a /descriptive vocabulary/ that is precise, standard, and already maps perfectly to the design. "I am concrescing signal 47 through gates 0-8" is not poetry — it is a precise description of dispatcher operation. "Gate 3 has negatively prehended signal 136" means the secret-content gate rejected signal 136. "The satisfaction includes a file-write prehension with Merkle commit abc123" means the response contains a file write with the given Merkle hash. The agent uses this vocabulary in its ~/why~ output and in the ARCHITECTURE.org documentation. -*** What Whitehead Does Not Contribute - Not everything is useful. PM's full formalism — 300+ pages to prove ~1+1=2~ — is catastrophic as a reasoning engine. The /ideas/ (type theory, descriptions, propositional functions) are what matter, not the notation. Similarly, Whitehead's later concept of God (the "principle of concretion") and the full 25-category metaphysical system have no useful mapping to an agent architecture. Select the concepts that map; don't build a process-philosophy engine. -*** Relation to the Neurosymbolic Architecture - Passepartout is level 4 neuro-symbolic (symbolic gates + neural LLM, deterministic components coordinate heterogeneous systems). PM's type theory adds level-5 properties: /structural/ safety guarantees rather than /empirical/ ones. The dispatcher becomes not just a runtime gate stack but a type-theoretic framework where category errors are impossible by construction — just as PM made Russell's paradox impossible by construction. The Whiteheadian vocabulary reinforces the architectural identity: Passepartout is not a chatbot with safety checks. It is a /process/ — a continuous concrescence of prehensions producing satisfactions — whose safety is guaranteed by the type structure of the prehending entities. ** Historical Lineage — McCarthy's Advice Taker @@ -1013,15 +1005,7 @@ The connection is not metaphorical. McCarthy cited /Principia Mathematica/ as an Reference: McCarthy, J. (1959). Programs with Common Sense. /Proceedings of the Teddington Conference on the Mechanization of Thought Processes./ -** Philosophical Validation — The Neurosymbolic Consensus -:PROPERTIES: -:ID: design-validation -:CREATED: [2026-05-10 Sun] -:END: - -Three papers from the neurosymbolic AI research community validate the architectural thesis from complementary angles. - -*** Marcus (2020): The Case Against Pure Deep Learning +** Marcus (2020): The Case Against Pure Deep Learning Gary Marcus's "The Next Decade in AI" argues that deep learning alone is "data hungry, shallow, brittle, and limited in its ability to generalize." The paper demonstrates GPT-2 failing at basic commonsense reasoning: @@ -1034,7 +1018,7 @@ Marcus's core claim — "we have no hope of achieving robust intelligence withou Reference: Marcus, G. (2020). The Next Decade in AI: Four Steps Towards Robust Artificial Intelligence. arXiv:2002.06177. -*** Gaur & Sheth (2023): CREST — Trustworthy Neurosymbolic AI +** Gaur & Sheth (2023): CREST — Trustworthy Neurosymbolic AI Gaur and Sheth present the CREST framework: Consistency, Reliability, user-level Explainability, and Safety build Trust — and they argue these require neurosymbolic methods. Their empirical finding: GPT-3.5 breached safety constraints 30% of the time when asked identical questions repeatedly. Claude's 16 safety rules and Sparrow's 23 rules provide no /inherent/ safety — they are heuristic guardrails that can be breached through prompt variation. @@ -1042,7 +1026,7 @@ These findings validate three Passepartout design commitments: (1) prompt-level Reference: Gaur, M., & Sheth, A. (2023). Building Trustworthy NeuroSymbolic AI Systems: Consistency, Reliability, Explainability, and Safety. arXiv:2312.06798. -*** Sheth et al. (2022): Knowledge-Infused Learning +** Sheth et al. (2022): Knowledge-Infused Learning Sheth, Gunaratna, Bhatt, and Gaur define Knowledge-infused Learning (KiL) as "combining various types of explicit knowledge with data-driven deep learning techniques." They identify three infusion levels (shallow, semi-deep, deep) and position KiL as "a sweet spot in neuro-symbolic AI." diff --git a/lisp/channel-tui-main.lisp b/lisp/channel-tui-main.lisp index 0394b42..7fbf315 100644 --- a/lisp/channel-tui-main.lisp +++ b/lisp/channel-tui-main.lisp @@ -672,8 +672,7 @@ (text (setf (st :busy) nil) (add-msg :agent text :gate-trace gate-trace)) ((eq action :handshake) - (setf (st :daemon-version) (getf payload :version)) - (add-msg :system (format nil "Connected v~a" (getf payload :version)))) + (setf (st :daemon-version) (getf payload :version))) (t (add-msg :agent (format nil "~a" msg)))))) (defun send-daemon (msg) @@ -864,8 +863,11 @@ (add-msg :system "* Swank unavailable *")))) (cl-tty.input:with-raw-terminal (cl-tty.backend:with-terminal (be w h) - (let ((tty (sb-sys:make-fd-stream 0 :input t :buffering :none))) - ;; Initial render + ;; Log backend info and terminal dimensions + (let ((backend-type (if (typep be 'cl-tty.backend:modern-backend) + "modern" "simple"))) + (add-msg :system (format nil "* ~a backend ~dx~d *" backend-type w h))) + ;; Initial render (cl-tty.backend:backend-clear be) (view-status be w h) (view-chat be w h) @@ -881,35 +883,33 @@ (setf (st :connected) nil (st :busy) nil) (add-msg :system "* Connection lost — type /reconnect to retry *")))) - ;; Check for terminal resize (SIGWINCH sets this flag) - (when (boundp 'cl-tty.input::*terminal-resized-p*) - (when cl-tty.input::*terminal-resized-p* - (setf cl-tty.input::*terminal-resized-p* nil) + ;; Read key input via cl-tty read-event (10ms timeout) + (multiple-value-bind (type data) + (cl-tty.input:read-event be :timeout 0.01) + (when (eq type :resize) (multiple-value-setq (w h) (cl-tty.backend:backend-size be)) - (setf (st :dirty) (list t t t)))) - ;; Read key input from fd 0 (blocking via listen + read-char) - (let ((raw-ch (when (listen tty) (read-char tty nil nil)))) - (when raw-ch - (let ((code (char-code raw-ch))) - (let ((ch (cond - ((= code 13) :enter) - ((= code 10) :enter) - ((= code 27) :escape) - ((= code 9) :tab) - ((or (= code 127) (= code 8)) :backspace) - ((and (>= code 1) (<= code 26)) - (intern (string-upcase (format nil "CTRL-~a" - (code-char (+ #x60 code)))) - :keyword)) - (t raw-ch)))) - (case ch - (:CTRL-Q (setf (st :running) nil)) - (:CTRL-P (command-palette-show-commands)) - (:CTRL-B (setf (st :sidebar-visible) (not (st :sidebar-visible))) - (setf (st :dirty) (list t t nil))) - (:CTRL-L (setf (st :dirty) (list t t t))) - (t (on-key ch))))))) - (when (or (first (st :dirty)) (second (st :dirty)) (third (st :dirty))) + (setf (st :dirty) (list t t t))) + (when data + (let* ((ke data) + (ch (if (cl-tty.input:key-event-p ke) + (let ((k (cl-tty.input:key-event-key ke))) + (if (cl-tty.input:key-event-ctrl ke) + (intern (format nil "CTRL-~a" k) :keyword) + k)) + ke))) + (case ch + (:CTRL-Q (setf (st :running) nil)) + (:CTRL-P (command-palette-show-commands)) + (:CTRL-B (setf (st :sidebar-visible) (not (st :sidebar-visible))) + (setf (st :dirty) (list t t nil))) + (:CTRL-L (setf (st :dirty) (list t t t))) + (t (on-key ch)))))) + ;; Re-query terminal size once after daemon handshake + (when (and (st :connected) (st :daemon-version) (not (st :size-queried))) + (multiple-value-setq (w h) (cl-tty.backend:backend-size be)) + (setf (st :dirty) (list t t t)) + (setf (st :size-queried) t)) + (when (or (first (st :dirty)) (second (st :dirty)) (third (st :dirty))) (cl-tty.backend:backend-clear be) (view-status be w h) (view-chat be w h) @@ -951,8 +951,7 @@ (t (theme-color :agent-fg))) nil :bold sel-p) (incf y-off))))))) - (sleep 0.1)))) - (close tty)) + (sleep 0.1)))) (disconnect-daemon))) (eval-when (:compile-toplevel :load-toplevel :execute) diff --git a/lisp/channel-tui-state.lisp b/lisp/channel-tui-state.lisp index ea5d3df..66c3cd5 100644 --- a/lisp/channel-tui-state.lisp +++ b/lisp/channel-tui-state.lisp @@ -178,6 +178,7 @@ :command-palette-dialog nil ; v0.8.0 :session-cost 0.0 ; v0.9.0 :daemon-version nil ; filled by handshake + :size-queried nil ; re-query once post-handshake :dirty (list nil nil nil)))) (defvar *sidebar-panels* diff --git a/lisp/channel-tui-view.lisp b/lisp/channel-tui-view.lisp index 4cea970..e2a2fab 100644 --- a/lisp/channel-tui-view.lisp +++ b/lisp/channel-tui-view.lisp @@ -25,8 +25,7 @@ Returns a list of strings, one per line." (length (st :messages)) (or (st :rule-count) 0))) (right (format nil "$~,2f ~a" (or (st :session-cost) 0.0) (now)))) - (dotimes (col w) - (cl-tty.backend:draw-text fb 0 (- h 1) (make-string w :initial-element #\Space) nil bg)) + (cl-tty.backend:draw-rect fb 0 (- h 1) w 1 :bg bg) (cl-tty.backend:draw-text fb 1 (- h 1) left fg nil) (cl-tty.backend:draw-text fb (- w (length right) 2) (- h 1) right fg nil)))