PSF: Mass-regeneration complete. 53/53 high-fidelity blueprints and TDD suites established. Zero-cost Pro bridge active.

This commit is contained in:
2026-04-07 08:58:08 -04:00
parent f4a91ae747
commit 77c0dac025
58 changed files with 2154 additions and 1671 deletions

View File

@@ -25,100 +25,60 @@ Define the interfaces for knowledge retrieval from the atomic note DAG.
*** TODO Link Resolution
*** TODO Sparse Tree Extraction Verification
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: DRAFT
:END:
** 1. Architectural Intent
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.
The core intent is to create a semantic query layer on top of the Zettelkasten. This involves indexing notes for efficient search, creating a sparse representation of the note graph, and providing functions to traverse this graph based on semantic relevance and explicit links. The system will prioritize speed and low memory footprint for interactive use. We'll focus on leveraging existing CLI tools like `ripgrep` and `jq` whenever possible and keeping the Lisp code thin by relying on external indexing and search. We aim for a functional core, minimizing mutable state to ease reasoning and testing.
** 2. Semantic Interfaces
#+begin_src lisp
(defun atomic-notes-scan (query)
"Stage 1: Returns a sparse list of matching headlines and their unique IDs.")
** 2. Semantic Interfaces (Lisp Signatures)
(defun atomic-notes-deep-read (ids)
"Stage 2: Retrieves the full content for a specific list of node IDs.")
#+end_src
*** Function: `find-atomic-notes`
Finds atomic notes matching a semantic query.
* Phase D: Build (Implementation)
:ARGS ((query string) (options plist))
:RETURNS (list-of note-ids)
:DESCRIPTION "Performs a semantic search for notes. Options can control search depth, relevance threshold, and maximum results."
:EXAMPLE `(find-atomic-notes "Bayesian Inference" '(:max-results 10 :relevance-threshold 0.7))`
** Stage 1: Sparse Scan
#+begin_src lisp :tangle projects/org-skill-atomic-notes/src/retrieval-logic.lisp
(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 - 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
*** Function: `get-note-content`
Retrieves the content of a specific note.
** Stage 2: Deep Read
#+begin_src lisp :tangle projects/org-skill-atomic-notes/src/retrieval-logic.lisp
(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
:ARGS ((note-id string))
:RETURNS (string)
:DESCRIPTION "Retrieves the full text content of the note identified by note-id."
:EXAMPLE `(get-note-content "skill-atomic-notes")`
** Stage 3: Semantic Search (SOTA)
#+begin_src lisp :tangle projects/org-skill-atomic-notes/src/retrieval-logic.lisp
(defun atomic-notes-semantic-search (query &optional (top-k 5))
"Uses dense vector embeddings to find semantically related notes."
(let* ((query-vec (org-agent:get-embedding query))
(matches (when query-vec (org-agent:find-most-similar query-vec top-k))))
(mapcar (lambda (match)
(let* ((score (car match))
(obj (cdr match))
(attrs (org-agent:org-object-attributes obj)))
(list :score score
:id (org-agent:org-object-id obj)
:title (getf attrs :TITLE))))
matches)))
#+end_src
*** Function: `extract-headline-ids`
Extracts headline and ID pairs from a note's content.
** 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 and Semantic Perception.
It combines ripgrep hits and semantic matches to provide high-fidelity context."
(let* ((query (getf (getf context :payload) :query))
(sparse-results (atomic-notes-scan query))
(semantic-results (atomic-notes-semantic-search query)))
(format nil "
I have searched your Zettelkasten for '~a'.
KEYWORD MATCHES (Sparse):
---
~a
---
SEMANTIC MATCHES (Dense):
---
~{~a (Score: ~f) [ID: ~a]~%~}
---
TASK:
Identify the IDs of the most relevant notes to answer the user's implicit or explicit question.
Return a Lisp plist: (:target :atomic-notes :action :deep-read :ids (\"id1\" \"id2\"))
" query sparse-results
(loop for m in semantic-results
collect (getf m :title)
collect (getf m :score)
collect (getf m :id)))))
#+end_src
:ARGS ((note-content string))
:RETURNS (list-of (cons headline id))
:DESCRIPTION "Parses the note content and returns a list of headline-ID pairs for hierarchical navigation."
:EXAMPLE `(extract-headline-ids (get-note-content "skill-atomic-notes"))`
*** Function: `resolve-internal-links`
Resolves internal links within a note and fetches the linked note IDs.
:ARGS ((note-id string))
:RETURNS (list-of note-ids)
:DESCRIPTION "Finds all internal links (e.g., [[id:some-other-note]]) in a note and returns a list of the target note IDs."
:EXAMPLE `(resolve-internal-links "skill-atomic-notes")`
*** Function: `expand-note-graph`
Recursively expands the note graph from a starting set of notes to a specified depth.
:ARGS ((seed-note-ids list-of-strings) (depth integer))
:RETURNS (list-of note-ids)
:DESCRIPTION "Expands the note graph by recursively following links to a given depth."
:EXAMPLE `(expand-note-graph '("skill-atomic-notes" "some-other-note") 2)`
* Registration
#+begin_src lisp
(defskill :skill-atomic-notes
:priority 90
:trigger (lambda (context) nil)
:neuro #'neuro-skill-atomic-notes
:symbolic #'atomic-notes-scan)
#+end_src