Bug fixes: - Fix box() calls: set color-pair before box, pass ACS default chtype integers - Fix markdown functions: move to passepartout.channel-tui package where Croatoan is imported; use add-attributes/remove-attributes instead of :bold/:underline kwargs to add-string; call theme-color in gate-trace-lines to convert theme keys to Croatoan colors - Fix sandbox: remove dex:get/dex:post from restricted symbols (blocked neuro-provider from loading) - Export *log-lock* from passepartout (was unbound in jailed skill packages) - Fix configure: always deploy to XDG, skip cp when source==dest - Fix bash crash handler format string (~~ escaping) - Revert test reorder in 28 files (caused package leakage in skill loader) Design cleanup: - Extract tui-run-screen from tui-main for clean separation - Remove inject-stimulus alias - Merge *backend-registry* into *probabilistic-backends* - Fix read-framed-message whitespace DoS (4096-iteration max) - Add *read-eval* nil to dispatcher-approvals-process read-from-string
114 lines
5.1 KiB
Common Lisp
114 lines
5.1 KiB
Common Lisp
(in-package :passepartout)
|
|
|
|
(defun memory-objects-since (timestamp)
|
|
"Returns all memory-objects from *memory-store* with version >= TIMESTAMP."
|
|
(let ((results nil))
|
|
(maphash (lambda (id obj)
|
|
(declare (ignore id))
|
|
(when (>= (memory-object-version obj) timestamp)
|
|
(push obj results)))
|
|
*memory-store*)
|
|
(nreverse results)))
|
|
|
|
(defun memory-objects-in-range (since until)
|
|
"Returns memory-objects with version between SINCE and UNTIL (inclusive)."
|
|
(let ((results nil))
|
|
(maphash (lambda (id obj)
|
|
(declare (ignore id))
|
|
(let ((v (memory-object-version obj)))
|
|
(when (and (>= v since) (<= v until))
|
|
(push obj results))))
|
|
*memory-store*)
|
|
(nreverse results)))
|
|
|
|
(defun context-query-with-time (&key (max-results 20) type-filter todo-filter since until)
|
|
"Extended context query with temporal filtering.
|
|
When :since and/or :until are provided, filters results by memory-object version.
|
|
Falls back to context-query if temporal filtering is not requested."
|
|
(let* ((all (if (fboundp 'memory-objects-by-attribute)
|
|
(if type-filter
|
|
(memory-objects-by-attribute :TYPE type-filter)
|
|
(let ((results nil))
|
|
(maphash (lambda (id obj)
|
|
(declare (ignore id))
|
|
(push obj results))
|
|
*memory-store*)
|
|
results))
|
|
(let ((results nil))
|
|
(maphash (lambda (id obj)
|
|
(declare (ignore id))
|
|
(push obj results))
|
|
*memory-store*)
|
|
results)))
|
|
(time-filtered (cond
|
|
((and since until)
|
|
(remove-if (lambda (obj)
|
|
(let ((v (memory-object-version obj)))
|
|
(not (and (>= v since) (<= v until)))))
|
|
all))
|
|
(since
|
|
(remove-if (lambda (obj)
|
|
(< (memory-object-version obj) since))
|
|
all))
|
|
(until
|
|
(remove-if (lambda (obj)
|
|
(> (memory-object-version obj) until))
|
|
all))
|
|
(t all))))
|
|
(let ((todo-filtered (if todo-filter
|
|
(remove-if-not (lambda (obj)
|
|
(string-equal (getf (memory-object-attributes obj) :TODO-STATE "") todo-filter))
|
|
time-filtered)
|
|
time-filtered)))
|
|
(subseq todo-filtered 0 (min max-results (length todo-filtered))))))
|
|
|
|
(eval-when (:compile-toplevel :load-toplevel :execute)
|
|
(ql:quickload :fiveam :silent t))
|
|
|
|
(defpackage :passepartout-time-memory-tests
|
|
(:use :cl :fiveam :passepartout)
|
|
(:export #:time-memory-suite))
|
|
|
|
(in-package :passepartout-time-memory-tests)
|
|
|
|
(def-suite time-memory-suite :description "Temporal memory filtering")
|
|
(in-suite time-memory-suite)
|
|
|
|
(test test-memory-objects-since
|
|
"Contract 1: ingest at T0 and T1, verify memory-objects-since(T1) returns only T1 nodes."
|
|
(clrhash passepartout::*memory-store*)
|
|
(let ((t0 (get-universal-time)))
|
|
(sleep 1)
|
|
(ingest-ast (list :type :HEADLINE :properties (list :ID "time-a" :TITLE "A") :contents nil))
|
|
(ingest-ast (list :type :HEADLINE :properties (list :ID "time-b" :TITLE "B") :contents nil))
|
|
(sleep 1)
|
|
(let ((t1 (get-universal-time)))
|
|
(sleep 1)
|
|
(ingest-ast (list :type :HEADLINE :properties (list :ID "time-c" :TITLE "C") :contents nil))
|
|
(ingest-ast (list :type :HEADLINE :properties (list :ID "time-d" :TITLE "D") :contents nil))
|
|
(let ((since-t1 (passepartout::memory-objects-since t1)))
|
|
(is (= 2 (length since-t1)))
|
|
(let ((ids (sort (mapcar #'memory-object-id since-t1) #'string<)))
|
|
(is (string= "time-c" (first ids)))
|
|
(is (string= "time-d" (second ids))))
|
|
(let ((since-t0 (passepartout::memory-objects-since t0)))
|
|
(is (= 4 (length since-t0))))))))
|
|
|
|
(test test-memory-objects-in-range
|
|
"Contract 2: ingest nodes, verify range query returns correct subset."
|
|
(clrhash passepartout::*memory-store*)
|
|
(let ((t0 (get-universal-time)))
|
|
(sleep 1)
|
|
(ingest-ast (list :type :HEADLINE :properties (list :ID "rng-1" :TITLE "One") :contents nil))
|
|
(sleep 1)
|
|
(let ((t1 (get-universal-time)))
|
|
(sleep 1)
|
|
(ingest-ast (list :type :HEADLINE :properties (list :ID "rng-2" :TITLE "Two") :contents nil))
|
|
(sleep 1)
|
|
(let ((t2 (get-universal-time)))
|
|
(sleep 1)
|
|
(ingest-ast (list :type :HEADLINE :properties (list :ID "rng-3" :TITLE "Three") :contents nil))
|
|
(let ((range (passepartout::memory-objects-in-range t1 t2)))
|
|
(is (= 1 (length range)))
|
|
(is (string= "rng-2" (memory-object-id (first range)))))))))
|