Phase 1 — dedup + hardening (~9 items): - Remove duplicate *skill-registry* defvar from core-skills - Merge *backend-registry* into *probabilistic-backends*, delete backend-register - Remove inject-stimulus alias, standardize on stimulus-inject - Add pre-eval sandbox (skill-source-scan) blocks restricted symbols before eval - Remove dead plist-get function; remove duplicate json-alist-to-plist export - Fix read-framed-message whitespace DoS (4096-iteration max) - Add *read-eval* nil to dispatcher-approvals-process read-from-string (RCE) - Add test-op to ASDF; update .asd version 0.4.3→0.7.2 Phase 2 — prose + contracts + reorder: - Split ROADMAP: 2623→1089 lines (TODO only), CHANGELOG: 260→1528 lines (full DONE history, 14 versions reverse chron) - Add Contracts + Overview to 6 channel files + embedding-native + programming-standards + symbolic-scope - Reorder 28 .org files: Contract → Test Suite → Implementation (TDD order) - Add 7-phase inline prose to think() in core-reason - Expand USER_MANUAL: 183→461 lines (10 new sections) Phase 3 — decomposition + export organization: - Decompose think() into think-assemble-prompt, think-call-llm, think-parse-response orchestrator - Organize 188 exports into 16 grouped sections by module Phase 4 — budget enforcement + error protocol: - Per-session budget enforcement (SESSION_BUDGET_USD env var, budget-exhausted-p, guard in think-call-llm) - Error condition hierarchy (6 conditions: pipeline-error, llm-error, gate-error, budget-error, protocol-error) - Restarts in loop-process: skip-signal, use-fallback, abort-pipeline
114 lines
5.1 KiB
Common Lisp
114 lines
5.1 KiB
Common Lisp
(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)))))))))
|
|
|
|
(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))))))
|