feat(psf): implement advanced foundry automation and memory optimization

This commit is contained in:
2026-03-31 18:13:26 -04:00
parent 70be8ab93e
commit b3d89f88e5
17 changed files with 11187 additions and 20 deletions

View File

@@ -31,35 +31,58 @@ Define the interfaces for knowledge retrieval from the atomic note DAG.
:END:
** 1. Architectural Intent
Interfaces for scanning and resolving nodes in the Zettelkasten. Source of truth is `$MEMEX_NOTES`.
Interfaces for scanning and resolving nodes in the Zettelkasten. It implements a two-stage retrieval process: Sparse Perception (Headlines/IDs) followed by Targeted Deep-Reading.
** 2. Semantic Interfaces
#+begin_src lisp
(defun atomic-notes-perceive (query)
"Performs a sparse-tree scan of the Zettelkasten.")
(defun atomic-notes-scan (query)
"Stage 1: Returns a sparse list of matching headlines and their unique IDs.")
(defun atomic-notes-resolve-link (link-target)
"Follows a link (ID or file) to retrieve the target node content.")
(defun atomic-notes-deep-read (ids)
"Stage 2: Retrieves the full content for a specific list of node IDs.")
#+end_src
* Phase D: Build (Implementation)
** Sparse Perception
** Stage 1: Sparse Scan
#+begin_src lisp :tangle projects/org-skill-atomic-notes/src/retrieval-logic.lisp
(defun atomic-notes-perceive (query)
"Performs a sparse-tree scan of the Zettelkasten for the given query."
(defun atomic-notes-scan (query)
"Uses ripgrep to find matching headlines and extracts their IDs."
(let ((notes-dir (or (uiop:getenv "MEMEX_NOTES") "notes/")))
(kernel-log "MEMORY - Scanning Atomic Notes for: ~a" query)
(uiop:run-program (list "rg" "-i" query notes-dir) :output :string)))
(kernel-log "MEMORY - Sparse Scan for: ~a" query)
;; We grep for headlines and include the following line which usually has the ID property
(uiop:run-program (list "rg" "-i" "-A" "1" (format nil "^\\*+.*~a" query) notes-dir)
:output :string)))
#+end_src
** Link Resolution
** Stage 2: Deep Read
#+begin_src lisp :tangle projects/org-skill-atomic-notes/src/retrieval-logic.lisp
(defun atomic-notes-resolve-link (link-target)
"Resolves a link to a physical Org file."
(let ((notes-dir (or (uiop:getenv "MEMEX_NOTES") "notes/")))
;; Logic to handle [[id:UUID]] vs [[file:path.org]]
(format nil "Resolving link: ~a" link-target)))
(defun atomic-notes-deep-read (ids)
"Retrieves the full content subtree for given IDs from the Object Store."
(let ((results '()))
(dolist (id ids)
(let ((obj (org-agent:lookup-object id)))
(when obj
(push (list :id id :content (org-agent:org-object-content obj)) results))))
results))
#+end_src
** Neuro-Cognitive Intelligence
#+begin_src lisp :tangle projects/org-skill-atomic-notes/src/retrieval-logic.lisp
(defun neuro-skill-atomic-notes (context)
"Neural stage of Sparse Perception.
It analyzes the search results and decides which specific IDs to 'deep read'."
(let ((query-results (atomic-notes-scan (getf (getf context :payload) :query))))
(format nil "
I found the following headlines matching your query:
---
~a
---
TASK:
Identify the IDs of the most relevant notes.
Return a Lisp plist: (:target :atomic-notes :action :deep-read :ids (\"id1\" \"id2\"))
" query-results)))
#+end_src
* Registration
@@ -67,6 +90,6 @@ Interfaces for scanning and resolving nodes in the Zettelkasten. Source of truth
(defskill :skill-atomic-notes
:priority 90
:trigger (lambda (context) nil)
:neuro (lambda (context) nil)
:symbolic #'atomic-notes-perceive)
:neuro #'neuro-skill-atomic-notes
:symbolic #'atomic-notes-scan)
#+end_src