PSF: Stabilizing workspace after crash. Valid kernel/skill fixes.

This commit is contained in:
2026-04-04 20:27:39 -04:00
parent 65a14784d3
commit 7ac10d1f95
47 changed files with 25388 additions and 3235 deletions

View File

@@ -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)))))