refactor: moved org-agent to its own repository as a submodule
This commit is contained in:
101
notes/skill-task-integrity.org
Normal file
101
notes/skill-task-integrity.org
Normal file
@@ -0,0 +1,101 @@
|
||||
#+TITLE - Task Integrity Skill
|
||||
#+AUTHOR - org-agent
|
||||
#+SKILL_NAME - skill-task-integrity
|
||||
|
||||
This skill handles automated GTD state transitions and integrity.
|
||||
|
||||
* Trigger
|
||||
Triggers only on buffer updates where the AST contains TODO states.
|
||||
|
||||
#+begin_src lisp
|
||||
(defun trigger-skill-task-integrity (context)
|
||||
(let ((type (getf context :type))
|
||||
(payload (getf context :payload)))
|
||||
(and (eq type :EVENT)
|
||||
(eq (getf payload :sensor) :buffer-update))))
|
||||
#+end_src
|
||||
|
||||
* Neuro Prompt
|
||||
System 1 asks for suggestions on the next action. It uses the Context API
|
||||
to provide the LLM with "peripheral vision" of the user's workload.
|
||||
|
||||
#+begin_src lisp
|
||||
(defun neuro-skill-task-integrity (context)
|
||||
"Generate a System 1 prompt by gathering relevant facts from the Object Store."
|
||||
(let ((recent-wins (org-agent:context-get-recent-completed-tasks))
|
||||
(projects (org-agent:context-get-active-projects)))
|
||||
;; We construct a rich, human-readable prompt that describes the user's
|
||||
;; current reality, momentum, and the latest event.
|
||||
(format nil "
|
||||
You are the user's Executive Assistant managing their Org-mode GTD system.
|
||||
CURRENT MOMENTUM (Recently DONE) - ~a
|
||||
ACTIVE PROJECTS - ~a
|
||||
|
||||
NEW EVENT - ~a
|
||||
|
||||
Suggest the next logical Org-mode action.
|
||||
Provide concise, high-fidelity suggestions in Lisp plist format.
|
||||
You MUST include :target :emacs in your top-level plist if you intend to execute an action.
|
||||
" recent-wins projects context)))
|
||||
#+end_src
|
||||
|
||||
* Symbolic Verification
|
||||
System 2 enforces GTD integrity using deterministic Lisp logic compatible
|
||||
with org-gtd v4.0. It ensures that a task cannot be closed (resolved)
|
||||
if it has active dependencies or children.
|
||||
|
||||
#+begin_src lisp
|
||||
(defun semantic-state-category (state)
|
||||
"Map a keyword state to its org-gtd v4.0 semantic category."
|
||||
(let ((s (string-upcase (or state ""))))
|
||||
(cond
|
||||
((member s '("TODO" "NEXT" "WAIT") :test #'string=) :active)
|
||||
((member s '("DONE" "CNCL" "CANCELED") :test #'string=) :resolved)
|
||||
(t :unknown))))
|
||||
|
||||
(defun has-active-children-p (parent-id)
|
||||
"Recursively check if a node has any children in an :active semantic state."
|
||||
(let ((parent (org-agent:lookup-object parent-id)))
|
||||
(when parent
|
||||
(cl:some (lambda (child-id)
|
||||
(let* ((child (org-agent:lookup-object child-id))
|
||||
(state (getf (org-agent:org-object-attributes child) :TODO-STATE)))
|
||||
(or (eq (semantic-state-category state) :active)
|
||||
(has-active-children-p child-id))))
|
||||
(org-agent:org-object-children parent)))))
|
||||
|
||||
(defun verify-skill-task-integrity (proposed-action context)
|
||||
"The System 2 gatekeeper for task consistency.
|
||||
Ensures parent tasks cannot be closed if children are still active."
|
||||
(let* ((payload (getf proposed-action :payload))
|
||||
(action (getf payload :action))
|
||||
(target-id (getf payload :target-id))
|
||||
(props (getf payload :properties))
|
||||
(new-state (cdr (assoc :TODO-STATE props))))
|
||||
|
||||
;; If the proposal attempts to transition a node to a :resolved state
|
||||
(if (and (eq action :refactor-subtree)
|
||||
target-id
|
||||
(eq (semantic-state-category new-state) :resolved))
|
||||
|
||||
;; Verify that all hierarchical dependencies are met
|
||||
(if (has-active-children-p target-id)
|
||||
(progn
|
||||
(format t "System 2 [skill-task-integrity] - BLOCKED transition of ~a to ~a. Active children remain.~%" target-id new-state)
|
||||
nil) ; Return NIL to block the illegal state change
|
||||
proposed-action)
|
||||
|
||||
;; Allow all other actions (e.g., TODO -> NEXT, or simple property updates)
|
||||
proposed-action)))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
Register the skill.
|
||||
|
||||
#+begin_src lisp
|
||||
(defskill :skill-task-integrity
|
||||
:priority 50
|
||||
:trigger #'trigger-skill-task-integrity
|
||||
:neuro #'neuro-skill-task-integrity
|
||||
:symbolic #'verify-skill-task-integrity)
|
||||
#+end_src
|
||||
Reference in New Issue
Block a user