PSF: Stabilizing workspace after crash. Valid kernel/skill fixes.
This commit is contained in:
@@ -45,7 +45,7 @@ Interfaces for blueprint actuation and requirement perception. Source of truth i
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** PRD Perception
|
||||
#+begin_src lisp :tangle projects/org-skill-architect/src/architect-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-architect/src/architect-logic.lisp
|
||||
(defun architect-perceive-frozen-prd (note-path)
|
||||
"Checks if a master note has a FROZEN PRD and lacks a Phase B section."
|
||||
(let ((content (uiop:read-file-string note-path)))
|
||||
@@ -65,7 +65,7 @@ Interfaces for blueprint actuation and requirement perception. Source of truth i
|
||||
#+end_src
|
||||
|
||||
** Cognitive Trigger
|
||||
#+begin_src lisp :tangle projects/org-skill-architect/src/architect-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-architect/src/architect-logic.lisp
|
||||
(defun trigger-skill-architect (context)
|
||||
"Triggers on heartbeat if any master note is in a FROZEN PRD state."
|
||||
(let ((type (getf context :type))
|
||||
@@ -78,7 +78,7 @@ Interfaces for blueprint actuation and requirement perception. Source of truth i
|
||||
#+end_src
|
||||
|
||||
** Neuro-Cognitive Prompt
|
||||
#+begin_src lisp :tangle projects/org-skill-architect/src/architect-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-architect/src/architect-logic.lisp
|
||||
(defun neuro-skill-architect (context)
|
||||
(let* ((payload (getf context :payload))
|
||||
(note (car (getf payload :ready-notes)))
|
||||
@@ -103,13 +103,13 @@ Interfaces for blueprint actuation and requirement perception. Source of truth i
|
||||
#+end_src
|
||||
|
||||
** Blueprint Actuation
|
||||
#+begin_src lisp :tangle projects/org-skill-architect/src/architect-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-architect/src/architect-logic.lisp
|
||||
(defun architect-actuate (action context)
|
||||
(let* ((payload (getf action :payload))
|
||||
(note-path (getf payload :path))
|
||||
(blueprint-content (getf payload :content)))
|
||||
|
||||
(kernel-log "ARCHITECT - Appending PROTOCOL to ~a" note-path)
|
||||
(org-agent:kernel-log "ARCHITECT - Appending PROTOCOL to ~a" note-path)
|
||||
(with-open-file (out note-path :direction :output :if-exists :append)
|
||||
(format out "~%* Phase B: Blueprint (PROTOCOL)~%:PROPERTIES:~%:STATUS: SIGNED~%:END:~%~%~a"
|
||||
blueprint-content))
|
||||
|
||||
@@ -35,14 +35,18 @@ Interfaces for credential retrieval. Source of truth is the system environment.
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
#+begin_src lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-auth-api-key/src/auth-api-key.lisp
|
||||
(defun auth-api-key-get-credentials ()
|
||||
(let ((key (uiop:getenv "LLM_API_KEY")))
|
||||
(when key
|
||||
(list :api-key key))))
|
||||
|
||||
(defun register-auth-provider (provider-name credential-fn)
|
||||
"Register a simple API key provider in the kernel."
|
||||
(org-agent:register-auth-provider provider-name credential-fn))
|
||||
|
||||
;; Register as the default auth provider for Gemini during transition
|
||||
(org-agent:register-auth-provider :gemini #'auth-api-key-get-credentials)
|
||||
(register-auth-provider :gemini #'auth-api-key-get-credentials)
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
|
||||
@@ -48,8 +48,7 @@ Interfaces for the OAuth lifecycle. Source of truth is the Google Identity Platf
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Token State Management
|
||||
#+begin_src lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-auth-google-oauth/src/auth-google-oauth.lisp
|
||||
(defvar *google-token-state* nil)
|
||||
|
||||
(defun auth-google-load-state ()
|
||||
@@ -64,10 +63,7 @@ Interfaces for the OAuth lifecycle. Source of truth is the Google Identity Platf
|
||||
(ensure-directories-exist state-file)
|
||||
(with-open-file (out state-file :direction :output :if-exists :supersede)
|
||||
(print *google-token-state* out))))
|
||||
#+end_src
|
||||
|
||||
** Token Exchange (Handshake)
|
||||
#+begin_src lisp
|
||||
(defun auth-google-receive-code (code)
|
||||
"Exchanges the manual authorization code for access and refresh tokens."
|
||||
(let ((url "https://oauth2.googleapis.com/token")
|
||||
@@ -89,10 +85,7 @@ Interfaces for the OAuth lifecycle. Source of truth is the Google Identity Platf
|
||||
(error (c)
|
||||
(kernel-log "OAUTH ERROR - Handshake failed: ~a" c)
|
||||
nil))))
|
||||
#+end_src
|
||||
|
||||
** Token Refresh
|
||||
#+begin_src lisp
|
||||
(defun auth-google-refresh-token ()
|
||||
"Uses the refresh_token to acquire a new access_token."
|
||||
(let ((refresh-token (getf *google-token-state* :refresh-token))
|
||||
@@ -113,10 +106,7 @@ Interfaces for the OAuth lifecycle. Source of truth is the Google Identity Platf
|
||||
(error (c)
|
||||
(kernel-log "OAUTH ERROR - Refresh failed: ~a" c)
|
||||
nil))))
|
||||
#+end_src
|
||||
|
||||
** Kernel Integration
|
||||
#+begin_src lisp
|
||||
(defun auth-google-get-header ()
|
||||
"Returns the Bearer token header, refreshing if necessary."
|
||||
(unless *google-token-state* (auth-google-load-state))
|
||||
|
||||
@@ -24,20 +24,28 @@ Verify the system's stability and error-handling capabilities under stress.
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Chaos Injection Logic
|
||||
#+begin_src lisp :tangle projects/org-skill-chaos/src/chaos-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-chaos/src/chaos-logic.lisp
|
||||
(defun chaos-inject-error (sensor-type)
|
||||
"Injects a synthetic error into a specific sensor pipeline."
|
||||
(kernel-log "CHAOS - Injecting synthetic error into ~a sensor..." sensor-type)
|
||||
(org-agent:kernel-log "CHAOS - Injecting synthetic error into ~a sensor..." sensor-type)
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor ,sensor-type :error "SYNTHETIC_CHAOS_ERROR"))))
|
||||
|
||||
(defun chaos-test-gitea-timeout ()
|
||||
"Simulates a Gitea connection timeout."
|
||||
(let ((gitea-url (org-agent::get-env "GITEA_URL" "http://localhost:3000")))
|
||||
(kernel-log "CHAOS - Simulating timeout for Gitea at ~a" gitea-url)
|
||||
;; Mock timeout by wrapping a call with an immediate failure
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :shell-response :cmd "git push" :exit-code 128 :stderr "fatal: connection timed out")))))
|
||||
(defun chaos-stress-test (action context)
|
||||
"Executes a randomized stress test by injecting failures into the system."
|
||||
(declare (ignore context))
|
||||
(let* ((payload (getf action :payload))
|
||||
(mode (or (getf payload :mode) :random))
|
||||
(intensity (or (getf payload :intensity) 3)))
|
||||
(org-agent:kernel-log "CHAOS - Commencing stress test (Mode: ~a, Intensity: ~a)" mode intensity)
|
||||
(case mode
|
||||
(:random (dotimes (i intensity)
|
||||
(let ((failure-type (nth (random 3) '(:test-failure :shell-timeout :llm-error))))
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :chaos-injection :type ,failure-type))))))
|
||||
(:shell (org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :shell-response :cmd "git push" :exit-code 128 :stderr "fatal: network unreachable")))))
|
||||
(format nil "SUCCESS - Chaos stress test initiated.")))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
@@ -45,6 +53,8 @@ Verify the system's stability and error-handling capabilities under stress.
|
||||
(defskill :skill-chaos
|
||||
:priority 10 ; Lower priority, used for background testing
|
||||
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :chaos-trigger))
|
||||
:neuro (lambda (context) "Analyze the failure and verify recovery path.")
|
||||
:symbolic (lambda (action context) action))
|
||||
:neuro (lambda (context)
|
||||
(let ((p (getf context :payload)))
|
||||
(format nil "A chaos trigger was received (~a). Should I run a stress test?" (getf p :mode))))
|
||||
:symbolic #'chaos-stress-test)
|
||||
#+end_src
|
||||
|
||||
67
notes/org-skill-context-manager.org
Normal file
67
notes/org-skill-context-manager.org
Normal file
@@ -0,0 +1,67 @@
|
||||
#+TITLE: SKILL: Context Manager (Universal Literate Note)
|
||||
#+ID: skill-context-manager
|
||||
#+STARTUP: content
|
||||
#+FILETAGS: :context:system:psf:
|
||||
|
||||
* Overview
|
||||
The *Context Manager* handles the cognitive stack of the agent, allowing for switching between different projects, areas, and tasks while maintaining a clean environment.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Manage a stack-based context system for the agent.
|
||||
|
||||
** 2. User Needs
|
||||
- *Push/Pop:* Ability to enter and exit specific project contexts.
|
||||
- *Path Resolution:* Resolve relative paths based on the current context.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Stack-based context management.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun context-push (new-context) "Push a new context onto the stack.")
|
||||
(defun context-pop () "Pop the current context.")
|
||||
(defun context-resolve-path (path) "Resolve a path based on current context.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
#+begin_src lisp :tangle ../projects/org-skill-context-manager/src/context-manager.lisp
|
||||
(defvar *context-stack* nil)
|
||||
|
||||
(defun context-push (new-context)
|
||||
"Push a new context (usually a path or a plist) onto the stack."
|
||||
(push new-context *context-stack*)
|
||||
(kernel-log "CONTEXT - Pushed: ~a" new-context))
|
||||
|
||||
(defun context-pop ()
|
||||
"Pop the top context from the stack."
|
||||
(let ((old (pop *context-stack*)))
|
||||
(kernel-log "CONTEXT - Popped: ~a" old)
|
||||
old))
|
||||
|
||||
(defun context-resolve-path (path)
|
||||
"Resolve PATH relative to the current context if it's a directory, otherwise return as is."
|
||||
(let ((current (car *context-stack*)))
|
||||
(if (and current (stringp current) (uiop:directory-pathname-p current))
|
||||
(merge-pathnames path current)
|
||||
path)))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-context-manager
|
||||
:priority 80
|
||||
:trigger (lambda (context) nil)
|
||||
:neuro (lambda (context) nil)
|
||||
:symbolic (lambda (action context) action))
|
||||
#+end_src
|
||||
@@ -46,19 +46,32 @@ Interfaces for temporal perception and task auditing. Source of truth is the cur
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Heartbeat Perception
|
||||
#+begin_src lisp :tangle projects/org-skill-cron/src/cron-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-cron/src/cron.lisp
|
||||
(defvar *cron-registry* nil)
|
||||
|
||||
(defun cron-register (name schedule-fn action-fn)
|
||||
"Register a new cron task."
|
||||
(push (list :name name :schedule schedule-fn :action action-fn :last-run 0) *cron-registry*))
|
||||
|
||||
(defun cron-trigger-loop ()
|
||||
"Iterate through registered tasks and trigger those whose schedule matches."
|
||||
(dolist (task *cron-registry*)
|
||||
(let ((name (getf task :name))
|
||||
(schedule (getf task :schedule))
|
||||
(action (getf task :action)))
|
||||
(when (funcall schedule)
|
||||
(kernel-log "CRON - Triggering task: ~a" name)
|
||||
(funcall action)
|
||||
(setf (getf task :last-run) (get-universal-time))))))
|
||||
|
||||
(defun trigger-skill-cron (context)
|
||||
(let ((type (getf context :type))
|
||||
(payload (getf context :payload)))
|
||||
(when (and (eq type :EVENT) (eq (getf payload :sensor) :heartbeat))
|
||||
;; Side-effect: Check if it's time for the nightly grooming cycle
|
||||
(cron-trigger-loop)
|
||||
(trigger-nightly-grooming)
|
||||
t))) ; Return T to trigger the skill
|
||||
#+end_src
|
||||
t)))
|
||||
|
||||
** Temporal Parsing & Nightly Cycle
|
||||
#+begin_src lisp :tangle projects/org-skill-cron/src/cron-logic.lisp
|
||||
(defun parse-org-timestamp (ts-str)
|
||||
(let ((match (nth-value 1 (cl-ppcre:scan-to-strings "<(\\d{4})-(\\d{2})-(\\d{2}).*>" ts-str))))
|
||||
(if match
|
||||
@@ -69,19 +82,14 @@ Interfaces for temporal perception and task auditing. Source of truth is the cur
|
||||
nil)))
|
||||
|
||||
(defun trigger-nightly-grooming ()
|
||||
"Checks if the current time is within the nightly grooming window (e.g., 3:00 AM - 4:00 AM).
|
||||
If so, and it hasn't run today, it injects a grooming stimulus."
|
||||
"Checks if the current time is within the nightly grooming window (e.g., 3:00 AM - 4:00 AM)."
|
||||
(let* ((now (local-time:now))
|
||||
(hour (local-time:timestamp-hour now)))
|
||||
(when (= hour 3) ; 3 AM
|
||||
(when (= hour 3)
|
||||
(kernel-log "CRON - Initiating Nightly Grooming Cycle...")
|
||||
(org-agent:inject-stimulus `(:type :EVENT :payload (:sensor :grooming-cycle))))))
|
||||
#+end_src
|
||||
|
||||
** Context Injection
|
||||
#+begin_src lisp :tangle projects/org-skill-cron/src/cron-logic.lisp
|
||||
"Retrieves all headlines with DEADLINE timestamps in the next N days.
|
||||
Enables Temporal Context Injection for System 1."
|
||||
(defun context-get-upcoming-deadlines (&optional (days 3))
|
||||
(let* ((now (get-universal-time))
|
||||
(future-limit (+ now (* days 24 60 60)))
|
||||
(all-headlines (org-agent:list-objects-by-type :HEADLINE))
|
||||
@@ -95,7 +103,6 @@ Interfaces for temporal perception and task auditing. Source of truth is the cur
|
||||
upcoming))
|
||||
|
||||
(defun context-get-stalled-waiting-items (&optional (days 3))
|
||||
"Finds items marked WAITING that have not been updated in N days."
|
||||
(let* ((now (get-universal-time))
|
||||
(past-limit (- now (* days 24 60 60)))
|
||||
(all-headlines (org-agent:list-objects-by-type :HEADLINE))
|
||||
@@ -107,32 +114,15 @@ Interfaces for temporal perception and task auditing. Source of truth is the cur
|
||||
(when (and (equal state "WAITING") (< last-sync past-limit))
|
||||
(push (list :title (getf attrs :TITLE)) stalled))))
|
||||
stalled))
|
||||
#+end_src
|
||||
|
||||
** Neuro-Cognitive Intelligence
|
||||
#+begin_src lisp :tangle projects/org-skill-cron/src/cron-logic.lisp
|
||||
(defun neuro-skill-cron (context)
|
||||
"Neural stage for temporal awareness.
|
||||
Injects upcoming calendar events and stalled items into the cognitive loop."
|
||||
(let* ((upcoming (context-get-upcoming-deadlines 3)) ; Look 3 days ahead
|
||||
(stalled (context-get-stalled-waiting-items 3)) ; Look 3 days back
|
||||
(let* ((upcoming (context-get-upcoming-deadlines 3))
|
||||
(stalled (context-get-stalled-waiting-items 3))
|
||||
(now-str (local-time:format-timestring nil (local-time:now))))
|
||||
(format nil "
|
||||
CURRENT TIME: ~a
|
||||
|
||||
UPCOMING DEADLINES (Next 3 Days):
|
||||
---
|
||||
~{~a: ~a~%~}
|
||||
---
|
||||
|
||||
STALLED WAITING ITEMS (> 3 days old):
|
||||
---
|
||||
~{~a~%~}
|
||||
---
|
||||
|
||||
TASK:
|
||||
If any deadline is CRITICAL or OVERDUE, propose a proactive alert or plan adjustment.
|
||||
If there are stalled WAITING items, propose a follow-up action to unblock them.
|
||||
UPCOMING DEADLINES (Next 3 Days): ~{~a: ~a~%~}
|
||||
STALLED WAITING ITEMS (> 3 days old): ~{~a~%~}
|
||||
" now-str
|
||||
(loop for item in upcoming append (list (getf item :deadline) (getf item :title)))
|
||||
(loop for item in stalled collect (getf item :title)))))
|
||||
|
||||
58
notes/org-skill-delegation.org
Normal file
58
notes/org-skill-delegation.org
Normal file
@@ -0,0 +1,58 @@
|
||||
#+TITLE: SKILL: Delegation Manager (Universal Literate Note)
|
||||
#+ID: skill-delegation
|
||||
#+STARTUP: content
|
||||
#+FILETAGS: :delegation:multi-agent:psf:
|
||||
|
||||
* Overview
|
||||
The *Delegation Manager* orchestrates the dispatch of tasks to sub-agents or specialized skills.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Define the protocol for delegating work between agents.
|
||||
|
||||
** 2. User Needs
|
||||
- *Trigger:* Detect when a task requires delegation.
|
||||
- *Actuate:* Execute the delegation to a target skill or agent.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Hierarchical task delegation system.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun delegation-trigger (context) "Determine if context requires delegation.")
|
||||
(defun delegation-actuate (task target) "Actuate delegation of TASK to TARGET.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
#+begin_src lisp :tangle ../projects/org-skill-delegation/src/delegation.lisp
|
||||
(defun delegation-trigger (context)
|
||||
"Examine CONTEXT to see if delegation is needed.
|
||||
Criteria: Task complexity or explicit :delegate-to flag."
|
||||
(let ((complexity (getf context :complexity 0))
|
||||
(explicit-target (getf context :delegate-to)))
|
||||
(or (> complexity 7) explicit-target)))
|
||||
|
||||
(defun delegation-actuate (task target)
|
||||
"Dispatch TASK to TARGET. TARGET can be a sub-agent name or a skill keyword."
|
||||
(kernel-log "DELEGATION - Actuating '~a' for task: ~a" target (getf task :title))
|
||||
(org-agent:spawn-sub-agent :target target :task task))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-delegation
|
||||
:priority 90
|
||||
:trigger #'delegation-trigger
|
||||
:neuro (lambda (context) nil)
|
||||
:symbolic (lambda (action context) action))
|
||||
#+end_src
|
||||
66
notes/org-skill-embedding-generator.org
Normal file
66
notes/org-skill-embedding-generator.org
Normal file
@@ -0,0 +1,66 @@
|
||||
#+TITLE: SKILL: Embedding Generator (Universal Literate Note)
|
||||
#+ID: skill-embedding-generator
|
||||
#+STARTUP: content
|
||||
#+FILETAGS: :embeddings:neural:psf:
|
||||
|
||||
* Overview
|
||||
The *Embedding Generator* provides vector representations of text for semantic search and neural memory.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Generate embeddings for text strings.
|
||||
|
||||
** 2. User Needs
|
||||
- *Provider Choice:* Support for local (Ollama) or remote (Gemini, OpenAI) providers.
|
||||
- *Batching:* Efficiency through batching text (future-proof).
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Unified interface for neural embeddings.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun get-embedding (text &key provider) "Acquire vector embedding for TEXT.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
#+begin_src lisp :tangle ../projects/org-skill-embedding-generator/src/embedding-generator.lisp
|
||||
(defun get-embedding (text &key (provider :ollama))
|
||||
"Retrieves the embedding vector for TEXT using specified PROVIDER."
|
||||
(kernel-log "NEURO [Embedding] - Generating via ~a..." provider)
|
||||
(case provider
|
||||
(:ollama (get-embedding-ollama text))
|
||||
(:gemini (get-embedding-gemini text))
|
||||
(t (error "Unsupported embedding provider: ~a" provider))))
|
||||
|
||||
(defun get-embedding-ollama (text)
|
||||
(let* ((url "http://localhost:11434/api/embeddings")
|
||||
(payload (cl-json:encode-json-to-string `(("model" . "mxbai-embed-large") ("prompt" . ,text))))
|
||||
(response (dex:post url :content payload :headers '(("Content-Type" . "application/json")))))
|
||||
(cdr (assoc :embedding (cl-json:decode-json-from-string response)))))
|
||||
|
||||
(defun get-embedding-gemini (text)
|
||||
(let* ((api-key (getf (org-agent:get-credentials :gemini) :api-key))
|
||||
(url (format nil "https://generativelanguage.googleapis.com/v1beta/models/embedding-001:embedContent?key=~a" api-key))
|
||||
(payload (cl-json:encode-json-to-string `(("content" . (("parts" . ((("text" . ,text))))))))))
|
||||
(let ((response (dex:post url :content payload :headers '(("Content-Type" . "application/json")))))
|
||||
(cdr (assoc :values (cdr (assoc :embedding (cl-json:decode-json-from-string response))))))))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-embedding-generator
|
||||
:priority 50
|
||||
:trigger (lambda (context) nil)
|
||||
:neuro (lambda (context) nil)
|
||||
:symbolic (lambda (action context) action))
|
||||
#+end_src
|
||||
63
notes/org-skill-git-steward.org
Normal file
63
notes/org-skill-git-steward.org
Normal file
@@ -0,0 +1,63 @@
|
||||
#+TITLE: SKILL: Git Steward (Universal Literate Note)
|
||||
#+ID: skill-git-steward
|
||||
#+STARTUP: content
|
||||
#+FILETAGS: :git:vcs:system:psf:
|
||||
|
||||
* Overview
|
||||
The *Git Steward* maintains the integrity of the workspace by automating version control operations.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Automate Git operations for the Memex.
|
||||
|
||||
** 2. User Needs
|
||||
- *Status:* Retrieve the current state of the repository.
|
||||
- *Commit:* Automate staging and committing changes.
|
||||
- *Push:* Synchronize with remote repositories.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Workspace version control management.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun git-status () "Return status of current repository.")
|
||||
(defun git-commit (message) "Stage and commit changes with MESSAGE.")
|
||||
(defun git-push () "Push changes to origin.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
#+begin_src lisp :tangle ../projects/org-skill-git-steward/src/git-steward.lisp
|
||||
(defun git-status ()
|
||||
"Executes git status and returns the output."
|
||||
(uiop:run-program '("git" "status" "--short") :output :string))
|
||||
|
||||
(defun git-commit (message)
|
||||
"Stages all tracked changes and commits them."
|
||||
(kernel-log "GIT - Committing: ~a" message)
|
||||
(uiop:run-program '("git" "add" "-u"))
|
||||
(uiop:run-program `("git" "commit" "-m" ,message)))
|
||||
|
||||
(defun git-push ()
|
||||
"Pushes to the current branch origin."
|
||||
(kernel-log "GIT - Pushing to origin...")
|
||||
(uiop:run-program '("git" "push")))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-git-steward
|
||||
:priority 40
|
||||
:trigger (lambda (context) nil)
|
||||
:neuro (lambda (context) nil)
|
||||
:symbolic (lambda (action context) action))
|
||||
#+end_src
|
||||
59
notes/org-skill-hook-manager.org
Normal file
59
notes/org-skill-hook-manager.org
Normal file
@@ -0,0 +1,59 @@
|
||||
#+TITLE: SKILL: Hook Manager (Universal Literate Note)
|
||||
#+ID: skill-hook-manager
|
||||
#+STARTUP: content
|
||||
#+FILETAGS: :hooks:event-driven:system:psf:
|
||||
|
||||
* Overview
|
||||
The *Hook Manager* enables event-driven extensibility within the agent by allowing functions to be registered and executed at specific lifecycle points.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Provide a hook-based event system.
|
||||
|
||||
** 2. User Needs
|
||||
- *Registration:* Register functions to be called on specific hooks.
|
||||
- *Execution:* Trigger all registered functions for a given hook.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Event-driven extension system.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun register-hook (hook-name fn) "Register FN on HOOK-NAME.")
|
||||
(defun run-hooks (hook-name &rest args) "Run all functions on HOOK-NAME with ARGS.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
#+begin_src lisp :tangle ../projects/org-skill-hook-manager/src/hook-manager.lisp
|
||||
(defvar *hooks* (make-hash-table :test 'equal))
|
||||
|
||||
(defun register-hook (hook-name fn)
|
||||
"Registers a function FN for the given HOOK-NAME."
|
||||
(pushnew fn (gethash hook-name *hooks*))
|
||||
(kernel-log "HOOK - Registered function for ~a" hook-name))
|
||||
|
||||
(defun run-hooks (hook-name &rest args)
|
||||
"Executes all registered functions for HOOK-NAME with ARGS."
|
||||
(let ((fns (gethash hook-name *hooks*)))
|
||||
(dolist (fn fns)
|
||||
(apply fn args))))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-hook-manager
|
||||
:priority 100
|
||||
:trigger (lambda (context) nil)
|
||||
:neuro (lambda (context) nil)
|
||||
:symbolic (lambda (action context) action))
|
||||
#+end_src
|
||||
82
notes/org-skill-inbox-processor.org
Normal file
82
notes/org-skill-inbox-processor.org
Normal file
@@ -0,0 +1,82 @@
|
||||
#+TITLE: SKILL: Enriched Inbox Processor Agent (Universal Literate Note)
|
||||
#+ID: skill-inbox-processor
|
||||
#+STARTUP: content
|
||||
#+FILETAGS: :inbox:processor:workflow:psf:
|
||||
|
||||
* Overview
|
||||
The *Enriched Inbox Processor Agent* is responsible for the daily migration of captured nodes from ~inbox.org~ to the ~daily/~ archive. It enforces a strict privacy wall for ~!personal~ content while providing deep semantic enrichment for public research.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Automate the sorting and enrichment of inbox captures.
|
||||
|
||||
** 2. User Needs
|
||||
- *Privacy Wall:* Headlines tagged ~!personal~ are moved **symbolically only**. No LLM processing allowed.
|
||||
- *Semantic Enrichment:* For public items (non-!personal), generate:
|
||||
1. A **Summary** sub-heading (1 sentence).
|
||||
2. A **Significance** paragraph explaining the PSF use-case.
|
||||
3. A **Full Text** extraction for items tagged ~!archive~.
|
||||
- *Archive-First:* ALL originals are moved to ~daily/YYYY-MM-DD.org~ based on the ~:CREATED:~ property.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Iterate through the inbox. Use System 2 (Symbolic) to identify the tag. If ~!personal~, perform a direct move. If not, trigger System 1 (Neuro) for enrichment.
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Helper: Privacy & Archive Checks
|
||||
#+begin_src lisp :tangle ../projects/org-skill-inbox-processor/src/processor-logic.lisp
|
||||
(defun inbox-is-private-p (tags)
|
||||
(member "!personal" tags :test #'string-equal))
|
||||
|
||||
(defun inbox-is-archive-p (tags)
|
||||
(member "!archive" tags :test #'string-equal))
|
||||
#+end_src
|
||||
|
||||
** Neural Stage (Enrichment)
|
||||
#+begin_src lisp :tangle ../projects/org-skill-inbox-processor/src/processor-logic.lisp
|
||||
(defun neuro-skill-inbox-processor (context)
|
||||
(let* ((payload (getf context :payload))
|
||||
(content (getf payload :content))
|
||||
(tags (getf payload :tags))
|
||||
(is-archive (inbox-is-archive-p tags)))
|
||||
(ask-neuro content :system-prompt
|
||||
(format nil "You are the PSF Librarian. Your goal is to ENRICH this Org-mode capture.
|
||||
RULES:
|
||||
1. Create a '** Summary' sub-heading with a 1-sentence summary.
|
||||
2. Create a '** Significance' sub-heading with a paragraph explaining why this matters to a Sovereign Lisp Machine and how it can be used.
|
||||
3. ~:[~;~* ARCHIVE MODE: Extract the full text of the item into a '** Full Text' sub-heading, preserving Org-mode structure.~]
|
||||
4. Return ONLY a Lisp plist with :summary :significance :full-text.
|
||||
5. NO conversational filler." is-archive))))
|
||||
#+end_src
|
||||
|
||||
** Symbolic Stage (The Physical Move)
|
||||
#+begin_src lisp :tangle ../projects/org-skill-inbox-processor/src/processor-logic.lisp
|
||||
(defun inbox-process-logic (action context)
|
||||
(declare (ignore action))
|
||||
(let* ((payload (getf context :payload))
|
||||
(sensor (getf payload :sensor)))
|
||||
(when (eq sensor :heartbeat)
|
||||
(let* ((base-dir (or (uiop:getenv "MEMEX_DIR") "/home/user/memex/"))
|
||||
(inbox-path (merge-pathnames "inbox.org" base-dir)))
|
||||
(org-agent:kernel-log "INBOX - Scanning ~a for migration..." (uiop:native-namestring inbox-path))
|
||||
;; Physical move logic would go here using Org AST parsing
|
||||
'(:target :system :payload (:action :message :text "Inbox processing complete (Simulation)."))))))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-inbox-processor
|
||||
:priority 100
|
||||
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :heartbeat))
|
||||
:neuro #'neuro-skill-inbox-processor
|
||||
:symbolic #'inbox-process-logic)
|
||||
#+end_src
|
||||
64
notes/org-skill-log-aggregator.org
Normal file
64
notes/org-skill-log-aggregator.org
Normal file
@@ -0,0 +1,64 @@
|
||||
#+TITLE: SKILL: Log Aggregator (Universal Literate Note)
|
||||
#+ID: skill-log-aggregator
|
||||
#+STARTUP: content
|
||||
#+FILETAGS: :logging:observability:system:psf:
|
||||
|
||||
* Overview
|
||||
The *Log Aggregator* monitors and summarizes system logs to provide insights into agent behavior and system health.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Collect and summarize agent logs.
|
||||
|
||||
** 2. User Needs
|
||||
- *Scan:* Retrieve logs from the system.
|
||||
- *Summarize:* Provide a high-level summary of recent activities.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Observability and log analysis system.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun log-scan (&optional (lines 100)) "Scan the last N lines of the log.")
|
||||
(defun log-summarize (logs) "Neural or symbolic summary of LOGS.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
#+begin_src lisp :tangle ../projects/org-skill-log-aggregator/src/log-aggregator.lisp
|
||||
(defun log-scan (&optional (lines 100))
|
||||
"Reads the last LINES lines of the system log file."
|
||||
(let ((log-file (merge-pathnames "logs/agent.log" (uiop:getenv "SYSTEM_DIR"))))
|
||||
(if (uiop:file-exists-p log-file)
|
||||
(uiop:run-program `("tail" "-n" ,(write-to-string lines) ,(namestring log-file)) :output :string)
|
||||
"Log file not found.")))
|
||||
|
||||
(defun log-summarize (logs)
|
||||
"Symbolic summary of LOGS focusing on errors and warnings."
|
||||
(let ((lines (uiop:split-string logs :separator '(#\Newline)))
|
||||
(errors 0)
|
||||
(warnings 0))
|
||||
(dolist (line lines)
|
||||
(cond
|
||||
((cl-ppcre:scan "ERROR" line) (incf errors))
|
||||
((cl-ppcre:scan "WARN" line) (incf warnings))))
|
||||
(format nil "Log Summary: ~a errors, ~a warnings found in scan." errors warnings)))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-log-aggregator
|
||||
:priority 30
|
||||
:trigger (lambda (context) nil)
|
||||
:neuro (lambda (context) nil)
|
||||
:symbolic (lambda (action context) action))
|
||||
#+end_src
|
||||
@@ -20,7 +20,7 @@ The *Gemini Provider Agent* integrates Google's Gemini API as a pluggable System
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Request Execution
|
||||
#+begin_src lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-provider-gemini/src/provider-logic.lisp
|
||||
(defun execute-gemini-request (prompt system-prompt)
|
||||
(let* ((auth (org-agent:get-provider-auth :gemini))
|
||||
(api-key (getf auth :api-key))
|
||||
@@ -37,7 +37,7 @@ The *Gemini Provider Agent* integrates Google's Gemini API as a pluggable System
|
||||
(body (cl-json:encode-json-to-string
|
||||
`((contents . ((parts . ((text . ,(format nil "~a~%~%Prompt: ~a" system-prompt prompt))))))))))
|
||||
(handler-case
|
||||
(let* ((response (dex:post url :headers headers :content body))
|
||||
(let* ((response (dex:post url :headers headers :content body :connect-timeout 10 :read-timeout 30))
|
||||
(json (cl-json:decode-json-from-string response)))
|
||||
(cdr (assoc :text (cdr (assoc :parts (car (cdr (assoc :parts (car (cdr (assoc :candidates json)))))))))))
|
||||
(error (c)
|
||||
|
||||
@@ -40,7 +40,7 @@ Interfaces for executing neural completion requests via the unified OpenRouter g
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Tiered Model Resolution
|
||||
#+begin_src lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-provider-openrouter/src/provider-logic.lisp
|
||||
(defun get-openrouter-tiered-model (tier)
|
||||
(case tier
|
||||
(:powerful "anthropic/claude-3.5-sonnet")
|
||||
@@ -50,7 +50,7 @@ Interfaces for executing neural completion requests via the unified OpenRouter g
|
||||
#+end_src
|
||||
|
||||
** Request Execution
|
||||
#+begin_src lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-provider-openrouter/src/provider-logic.lisp
|
||||
(defun execute-openrouter-request (prompt system-prompt)
|
||||
(let ((api-key (uiop:getenv "OPENROUTER_API_KEY"))
|
||||
(endpoint "https://openrouter.ai/api/v1/chat/completions"))
|
||||
@@ -70,7 +70,7 @@ Interfaces for executing neural completion requests via the unified OpenRouter g
|
||||
( (role . "user") (content . ,prompt) )))))))
|
||||
|
||||
(handler-case
|
||||
(let* ((response (dex:post endpoint :headers headers :content body))
|
||||
(let* ((response (dex:post endpoint :headers headers :content body :connect-timeout 10 :read-timeout 30))
|
||||
(json (cl-json:decode-json-from-string response)))
|
||||
;; Extract content from OpenAI-style response: choices[0].message.content
|
||||
(cdr (assoc :content (cdr (assoc :message (car (cdr (assoc :choices json))))))))
|
||||
|
||||
@@ -79,10 +79,25 @@ Interfaces for AST inspection and intent-driven stimulus injection. Source of tr
|
||||
(t '(:type :LOG :payload (:text "Router failed to classify."))))))
|
||||
#+end_src
|
||||
|
||||
** Routing Logic
|
||||
#+begin_src lisp :tangle ../projects/org-skill-router/src/router-logic.lisp
|
||||
(defun trigger-skill-router (context)
|
||||
"Triggers on :user-command or :chat-message if no other skill handles it."
|
||||
(let* ((payload (getf context :payload))
|
||||
(sensor (getf payload :sensor)))
|
||||
(or (eq sensor :user-command)
|
||||
(eq sensor :chat-message))))
|
||||
|
||||
(defun neuro-skill-router (context)
|
||||
"Neural stage for intent classification."
|
||||
(let ((text (getf (getf context :payload) :text)))
|
||||
(ask-neuro text :system-prompt "You are the PSF Router. Decompose the user's request into atomic sub-agent calls. Return a Lisp plist.")))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-router
|
||||
:priority 90
|
||||
:priority 10
|
||||
:trigger #'trigger-skill-router
|
||||
:neuro #'neuro-skill-router
|
||||
:symbolic #'verify-skill-router)
|
||||
|
||||
@@ -24,23 +24,33 @@ Eliminate speculative debugging through rigorous scientific methodology.
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Scientific Loop
|
||||
#+begin_src lisp :tangle projects/org-skill-scientist/src/scientist-logic.lisp
|
||||
(defun scientist-formulate-hypothesis (failure-log)
|
||||
"Analyzes an error and proposes a 'Theory of Failure'.
|
||||
Then triggers the Self-Fix agent."
|
||||
(let ((hypothesis (org-agent:ask-neuro
|
||||
(format nil "Explain why this failure occurred and propose a surgical fix: ~a" failure-log)
|
||||
:system-prompt "You are a PSF Senior Debugging Scientist. Use formal logic and propose a fix in Lisp.")))
|
||||
(kernel-log "SCIENTIST - Hypothesis formulated. Triggering SELF-FIX...")
|
||||
#+begin_src lisp :tangle ../projects/org-skill-scientist/src/scientist-logic.lisp
|
||||
(defun scientist-hypothesis (context)
|
||||
"Neural stage: Formulates a hypothesis about a failure based on logs."
|
||||
(let* ((payload (getf context :payload))
|
||||
(failure-log (getf payload :text))
|
||||
(project (getf payload :project)))
|
||||
(org-agent:ask-neuro
|
||||
(format nil "Project ~a failed with log: ~a. Formulate a 'Theory of Failure' and suggest a surgical fix." project failure-log)
|
||||
:system-prompt "You are a PSF Senior Debugging Scientist. Return a Lisp plist: (:target :scientist :action :propose :hypothesis \"...\" :failure-log \"...\")")))
|
||||
|
||||
(defun scientist-propose-fix (action context)
|
||||
"Symbolic stage: Triggers the Self-Fix agent with the formulated hypothesis."
|
||||
(declare (ignore context))
|
||||
(let* ((payload (getf action :payload))
|
||||
(hypothesis (getf payload :hypothesis))
|
||||
(failure-log (getf payload :failure-log)))
|
||||
(org-agent:kernel-log "SCIENTIST - Hypothesis formulated. Triggering SELF-FIX...")
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :repair-request :hypothesis ,hypothesis :failure-log ,failure-log)))))
|
||||
`(:type :EVENT :payload (:sensor :repair-request :hypothesis ,hypothesis :failure-log ,failure-log)))
|
||||
(format nil "SUCCESS - Scientist proposed fix for failure.")))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-scientist
|
||||
:priority 90
|
||||
:trigger (lambda (context) (search "ERROR" (getf (getf context :payload) :text)))
|
||||
:neuro #'scientist-formulate-hypothesis
|
||||
:symbolic (lambda (action context) action))
|
||||
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :test-failure))
|
||||
:neuro #'scientist-hypothesis
|
||||
:symbolic #'scientist-propose-fix)
|
||||
#+end_src
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#+FILETAGS: :scribe:distillation:psf:audit:
|
||||
|
||||
* Overview
|
||||
The *Scribe Agent* is the primary custodian of the Institutional Memory. It distills ephemeral daily thoughts into atomic notes and audits foundry projects for compliance with PSF standards.
|
||||
The *Scribe Agent* is the primary custodian of the Institutional Memory. It distills ephemeral daily thoughts into atomic notes, enriches the knowledge graph via Karpathy-style synthesis, and audits foundry projects.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
@@ -12,18 +12,23 @@ The *Scribe Agent* is the primary custodian of the Institutional Memory. It dist
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Define automated distillation and auditing behaviors for the PSF.
|
||||
Define automated distillation, enrichment, and auditing behaviors.
|
||||
|
||||
** 2. User Needs
|
||||
- *Knowledge Distillation:* Extract evergreen concepts from raw dailies.
|
||||
- *Incremental Processing:* Efficient Git-based delta tracking.
|
||||
- *PSF Mandate Audit:* High-integrity check for PRD/PROTOCOL artifacts.
|
||||
- *Autonomous Execution:* Cron-compatible, environment-driven logic.
|
||||
- *Knowledge Distillation:* Weekly scan of ~daily/~ files to extract evergreen concepts.
|
||||
- *Privacy Mandate:* NEVER process subtrees with the ~!personal~ tag. (LLM exclusion).
|
||||
- *Content Enrichment (Karpathy Method):*
|
||||
1. Cross-linking to existing notes.
|
||||
2. Merging redundant concepts.
|
||||
3. Splitting bloated notes.
|
||||
4. Deciding on further self-learning (deep or adjacent).
|
||||
5. Generating project ideas from insights.
|
||||
- *Archive Preservation:* Never delete originals from ~daily/~.
|
||||
|
||||
** 3. Success Criteria
|
||||
*** TODO Distillation Accuracy
|
||||
*** TODO Audit Trigger Verification
|
||||
*** TODO State Persistence (Lisp alist)
|
||||
*** TODO Successful distillation of a week's worth of dailies.
|
||||
*** TODO Automated link suggestion between new and old notes.
|
||||
*** TODO Project idea generation verified by user.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
@@ -31,64 +36,65 @@ Define automated distillation and auditing behaviors for the PSF.
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Interfaces for state-aware knowledge extraction and structural auditing.
|
||||
Uses a weekly heartbeat trigger. Employs a "Compiler" approach: System 1 (Neuro) generates synthesis proposals, System 2 (Symbolic) verifies file-system safety and tag constraints.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun scribe-scan-for-knowledge-gaps ()
|
||||
"Identifies new daily captures via git diff.")
|
||||
(defun scribe-distill-weekly ()
|
||||
"Main entry point for weekly knowledge synthesis.")
|
||||
|
||||
(defun scribe-distill-concept (daily-path concept-meta)
|
||||
"Transforms raw data into a permanent node.")
|
||||
|
||||
(defun scribe-audit-foundry-mandate (project-name)
|
||||
"Checks for mandatory PSF artifacts.")
|
||||
(defun scribe-enrich-concept (note-id)
|
||||
"Triggers neural analysis for linking and project ideas.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** State Perception
|
||||
#+begin_src lisp :tangle projects/org-skill-scribe/src/scribe-engine.lisp
|
||||
(defun scribe-scan-for-knowledge-gaps ()
|
||||
(let* ((state-file (or (uiop:getenv "SCRIBE_STATE") "scribe-state.lisp"))
|
||||
(state (if (uiop:file-exists-p state-file) (with-open-file (in state-file) (read in)) '((:last-commit . "HEAD~1"))))
|
||||
(last-hash (cdr (assoc :last-commit state))))
|
||||
(uiop:run-program (list "git" "diff" "--name-only" last-hash "HEAD" "--" (or (uiop:getenv "MEMEX_DAILY") "daily/")) :output :lines)))
|
||||
#+end_src
|
||||
|
||||
** Concept Distillation
|
||||
#+begin_src lisp :tangle projects/org-skill-scribe/src/scribe-engine.lisp
|
||||
(defun scribe-distill-concept (daily-path concept-meta)
|
||||
(let* ((title (getf concept-meta :title))
|
||||
(content (getf concept-meta :content))
|
||||
(source (getf concept-meta :source))
|
||||
(filename (format nil "~a.org" (cl-ppcre:regex-replace-all " " (string-downcase title) "-")))
|
||||
(target-path (format nil "~a/~a" (or (uiop:getenv "MEMEX_NOTES") "notes") filename)))
|
||||
(with-open-file (out target-path :direction :output :if-exists :supersede)
|
||||
(format out "#+TITLE: ~a~%#+ID: ~a~%~%Source: [[file:~a]]~%~%~a" title (org-id-new) source content))
|
||||
target-path))
|
||||
#+end_src
|
||||
|
||||
** Sensory Logic
|
||||
** Git-based Change Detection
|
||||
#+begin_src lisp :tangle ../projects/org-skill-scribe/src/scribe-engine.lisp
|
||||
(defun scribe-get-changed-dailies ()
|
||||
"Returns list of daily files modified in the last 7 days via git."
|
||||
(uiop:run-program (list "git" "log" "--since='1 week ago'" "--name-only" "--pretty=format:" "--" "daily/") :output :lines))
|
||||
#+end_src
|
||||
|
||||
** Pre-Filtering (The Privacy Wall)
|
||||
#+begin_src lisp :tangle ../projects/org-skill-scribe/src/scribe-engine.lisp
|
||||
(defun scribe-filter-personal (org-ast-node)
|
||||
"Recursively strips out any headline or content tagged with !personal.
|
||||
This runs strictly in System 2 BEFORE any data is passed to System 1."
|
||||
(let ((tags (getf (org-agent:org-object-attributes org-ast-node) :TAGS)))
|
||||
(when (not (member "!personal" tags :test #'string=))
|
||||
org-ast-node)))
|
||||
#+end_src
|
||||
|
||||
** Karpathy-Style Synthesis
|
||||
#+begin_src lisp :tangle ../projects/org-skill-scribe/src/scribe-engine.lisp
|
||||
(defun neuro-skill-scribe-enrich (context)
|
||||
"Neural stage for high-entropy knowledge synthesis.
|
||||
Assumes 'context' has already passed through scribe-filter-personal."
|
||||
(let* ((content (getf context :content))
|
||||
(existing-notes "")) ; Skeletal: would call atomic-notes-scan
|
||||
(ask-neuro content :system-prompt
|
||||
(format nil "You are the PSF Scribe. Your goal is to ENRICH this concept.
|
||||
RULES:
|
||||
1. CROSS-LINK: Suggest links to existing notes.
|
||||
2. MERGE/SPLIT: Identify if this should be combined with another or broken down.
|
||||
3. SELF-LEARNING: Suggest a 'Path to Mastery' (deeper or adjacent).
|
||||
4. PROJECTS: Suggest a PSF-style project based on this.
|
||||
5. NO FILLER: Return a Lisp plist."))))
|
||||
|
||||
(defun trigger-skill-scribe (context)
|
||||
"Triggers on delegation to :scribe or :distill."
|
||||
(let ((payload (getf context :payload)))
|
||||
(and (eq (getf context :type) :EVENT)
|
||||
(eq (getf payload :sensor) :delegation)
|
||||
(member (getf payload :target-skill) '(:scribe :distill)))))
|
||||
|
||||
(defun neuro-skill-scribe (context)
|
||||
"Neural stage for concept distillation."
|
||||
(declare (ignore context))
|
||||
nil)
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-scribe
|
||||
:priority 90
|
||||
:priority 60
|
||||
:trigger #'trigger-skill-scribe
|
||||
:neuro #'neuro-skill-scribe
|
||||
:symbolic #'scribe-scan-for-knowledge-gaps)
|
||||
:neuro #'neuro-skill-scribe-enrich
|
||||
:symbolic #'scribe-get-changed-dailies)
|
||||
#+end_src
|
||||
|
||||
@@ -24,16 +24,38 @@ Enable autonomous, verified code correction without human intervention.
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Repair Logic
|
||||
#+begin_src lisp :tangle projects/org-skill-self-fix/src/repair-logic.lisp
|
||||
(defun self-fix-apply (target-file old-code new-code)
|
||||
"Applies a surgical code fix in a sandboxed environment."
|
||||
(let* ((sandbox-dir "/tmp/org-agent-sandbox/fix/")
|
||||
(target-path (merge-pathnames target-file sandbox-dir)))
|
||||
(ensure-directories-exist sandbox-dir)
|
||||
(kernel-log "SELF-FIX - Applying surgical fix to ~a..." target-file)
|
||||
(with-open-file (out target-path :direction :output :if-exists :supersede)
|
||||
(write-string new-code out))
|
||||
(org-agent:kernel-log "SELF-FIX - Fix applied to sandbox: ~a" target-path)))
|
||||
#+begin_src lisp :tangle ../projects/org-skill-self-fix/src/repair-logic.lisp
|
||||
(defun self-fix-replace-all (string part replacement)
|
||||
(with-output-to-string (out)
|
||||
(loop with part-length = (length part)
|
||||
for old-pos = 0 then (+ pos part-length)
|
||||
for pos = (search part string :start2 old-pos)
|
||||
do (write-string string out :start old-pos :end (or pos (length string)))
|
||||
when pos do (write-string replacement out)
|
||||
while pos)))
|
||||
|
||||
(defun self-fix-apply (action context)
|
||||
"Applies a surgical code fix directly to the target file."
|
||||
(declare (ignore context))
|
||||
(let* ((payload (getf action :payload))
|
||||
(target-file (getf payload :file))
|
||||
(old-code (getf payload :old))
|
||||
(new-code (getf payload :new)))
|
||||
(org-agent:kernel-log "SELF-FIX - Attempting surgical fix on ~a..." target-file)
|
||||
(if (uiop:file-exists-p target-file)
|
||||
(let ((content (uiop:read-file-string target-file)))
|
||||
(if (search old-code content)
|
||||
(let ((new-content (self-fix-replace-all content old-code new-code)))
|
||||
(with-open-file (out target-file :direction :output :if-exists :supersede)
|
||||
(write-string new-content out))
|
||||
(org-agent:kernel-log "SELF-FIX SUCCESS - Applied fix to ~a" target-file)
|
||||
t)
|
||||
(progn
|
||||
(org-agent:kernel-log "SELF-FIX FAILURE - Could not find old code in ~a" target-file)
|
||||
nil)))
|
||||
(progn
|
||||
(org-agent:kernel-log "SELF-FIX FAILURE - File not found: ~a" target-file)
|
||||
nil))))
|
||||
|
||||
(defun neuro-skill-self-fix (context)
|
||||
"Neural stage: Synthesizes a surgical code modification based on the hypothesis."
|
||||
@@ -41,8 +63,10 @@ Enable autonomous, verified code correction without human intervention.
|
||||
(hypothesis (getf payload :hypothesis))
|
||||
(failure-log (getf payload :failure-log)))
|
||||
(org-agent:ask-neuro
|
||||
(format nil "Based on the hypothesis '~a' and failure '~a', provide the exact Lisp code to fix it." hypothesis failure-log)
|
||||
:system-prompt "You are the PSF Repair Actuator. Return a Lisp plist: (:file \"path/to/file.lisp\" :old \"old code\" :new \"new code\")")))
|
||||
(format nil "Based on the hypothesis '~a' and failure '~a', provide the exact Lisp code to fix it.
|
||||
Return a Lisp plist: (:target :self-fix :action :apply :file \"path/to/file.lisp\" :old \"old code\" :new \"new code\")"
|
||||
hypothesis failure-log)
|
||||
:system-prompt "You are the PSF Repair Actuator. You MUST return ONLY a Lisp plist.")))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
@@ -51,9 +75,5 @@ Enable autonomous, verified code correction without human intervention.
|
||||
:priority 95
|
||||
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :repair-request))
|
||||
:neuro #'neuro-skill-self-fix
|
||||
:symbolic (lambda (action context)
|
||||
(let ((p (getf action :payload)))
|
||||
(self-fix-apply (getf p :file) (getf p :old) (getf p :new))
|
||||
(org-agent:kernel-log "SELF-FIX - Logic verified. Merging...")
|
||||
action)))
|
||||
:symbolic #'self-fix-apply)
|
||||
#+end_src
|
||||
|
||||
@@ -46,19 +46,24 @@ Interfaces for background verification and kernel alerting. Source of truth is t
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Test Execution
|
||||
#+begin_src lisp :tangle projects/org-skill-tdd-runner/src/runner-logic.lisp
|
||||
(defun tdd-runner-execute (project-name)
|
||||
#+begin_src lisp :tangle ../projects/org-skill-tdd-runner/src/runner-logic.lisp
|
||||
(defun run-tests-for-project (project-name)
|
||||
"Executes the standard test suite for the given project using SBCL."
|
||||
(let* ((projects-dir (or (uiop:getenv "PROJECTS_DIR") "projects/"))
|
||||
(test-dir (format nil "~aorg-skill-~a/tests/" projects-dir project-name))
|
||||
(lisp-tests (format nil "~atest-suite.lisp" test-dir))
|
||||
(python-tests (format nil "~asimulate_*.py" test-dir)))
|
||||
(kernel-log "CI - Running tests for ~a..." project-name)
|
||||
;; Mock execution: If it fails, send to the Scientist Agent
|
||||
(let ((failure-log "ERROR: Expected T but got NIL in test case 42."))
|
||||
(when failure-log
|
||||
(kernel-log "CI ERROR - Test failed in ~a. Pushing to Scientist Agent..." project-name)
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :test-failure :project ,project-name :text ,failure-log)))))))
|
||||
(project-dir (format nil "~aorg-skill-~a/" projects-dir project-name))
|
||||
(test-file (format nil "~atests/test-suite.lisp" project-dir)))
|
||||
(org-agent:kernel-log "CI - Running tests for ~a..." project-name)
|
||||
(if (uiop:file-exists-p test-file)
|
||||
(multiple-value-bind (output error-output exit-code)
|
||||
(uiop:run-program (list "sbcl" "--batch" "--load" test-file "--eval" "(uiop:quit)")
|
||||
:ignore-error-status t :output :string :error-output :string)
|
||||
(if (= exit-code 0)
|
||||
(org-agent:kernel-log "CI SUCCESS - ~a passed all tests." project-name)
|
||||
(progn
|
||||
(org-agent:kernel-log "CI FAILURE - ~a failed tests with exit code ~a" project-name exit-code)
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :test-failure :project ,project-name :text ,output :stderr ,error-output))))))
|
||||
(org-agent:kernel-log "CI ERROR - No test suite found for ~a at ~a" project-name test-file))))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
@@ -75,5 +80,7 @@ Interfaces for background verification and kernel alerting. Source of truth is t
|
||||
(let ((parts (uiop:split-string file :separator '(#\/))))
|
||||
(when (> (length parts) 2)
|
||||
;; The project name is typically the directory after "projects/"
|
||||
(tdd-runner-execute (nth 1 (member "projects" parts :test #'string=)))))))))
|
||||
(let ((dir (nth 1 (member "projects" parts :test #'string=))))
|
||||
(when (and dir (uiop:string-prefix-p "org-skill-" dir))
|
||||
(run-tests-for-project (subseq dir 10))))))))))
|
||||
#+end_src
|
||||
|
||||
@@ -45,7 +45,7 @@ Interfaces for TDD suite actuation and protocol perception. Source of truth is t
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Protocol Perception
|
||||
#+begin_src lisp :tangle projects/org-skill-tech-analyst/src/analyst-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-tech-analyst/src/analyst-logic.lisp
|
||||
(defun tech-analyst-perceive-signed-protocol (note-path)
|
||||
"Checks if a master note has a SIGNED PROTOCOL and lacks a TDD suite in the material project."
|
||||
(let* ((content (uiop:read-file-string note-path))
|
||||
@@ -69,7 +69,7 @@ Interfaces for TDD suite actuation and protocol perception. Source of truth is t
|
||||
#+end_src
|
||||
|
||||
** Cognitive Trigger
|
||||
#+begin_src lisp :tangle projects/org-skill-tech-analyst/src/analyst-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-tech-analyst/src/analyst-logic.lisp
|
||||
(defun trigger-skill-tech-analyst (context)
|
||||
"Triggers on heartbeat if any master note is in a SIGNED PROTOCOL state."
|
||||
(let ((type (getf context :type))
|
||||
@@ -82,7 +82,7 @@ Interfaces for TDD suite actuation and protocol perception. Source of truth is t
|
||||
#+end_src
|
||||
|
||||
** Neuro-Cognitive Prompt
|
||||
#+begin_src lisp :tangle projects/org-skill-tech-analyst/src/analyst-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-tech-analyst/src/analyst-logic.lisp
|
||||
(defun neuro-skill-tech-analyst (context)
|
||||
(let* ((payload (getf context :payload))
|
||||
(note (car (getf payload :ready-blueprints)))
|
||||
@@ -107,7 +107,7 @@ Interfaces for TDD suite actuation and protocol perception. Source of truth is t
|
||||
#+end_src
|
||||
|
||||
** TDD Suite Actuation
|
||||
#+begin_src lisp :tangle projects/org-skill-tech-analyst/src/analyst-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-tech-analyst/src/analyst-logic.lisp
|
||||
(defun tech-analyst-actuate (action context)
|
||||
(let* ((payload (getf action :payload))
|
||||
(project-name (getf payload :name))
|
||||
@@ -117,7 +117,7 @@ Interfaces for TDD suite actuation and protocol perception. Source of truth is t
|
||||
(test-dir (format nil "~atests/" project-dir))
|
||||
(test-path (format nil "~atests/test-suite.lisp" project-dir)))
|
||||
|
||||
(kernel-log "ANALYST - Actuating TDD Suite for ~a" project-name)
|
||||
(org-agent:kernel-log "ANALYST - Actuating TDD Suite for ~a" project-name)
|
||||
(ensure-directories-exist test-dir)
|
||||
(with-open-file (out test-path :direction :output :if-exists :supersede)
|
||||
(format out ";;; TDD Suite for ~a~%~a" project-name test-content))
|
||||
|
||||
Reference in New Issue
Block a user