:PROPERTIES: :ID: 98923a43-2be0-423c-8509-22592cfe9c9e :CREATED: [2026-04-08 Wed 18:30] :END: #+TITLE: SKILL: IPFS Checkpointing (Universal Literate Note) #+STARTUP: content #+FILETAGS: :memory:persistence:ipfs:sovereignty: #+DEPENDS_ON: id:e8b500e2-3f26-4c8e-8558-528061e178ca * Overview The *IPFS Checkpointing* skill provides decentralized, immutable snapshots of the agent's knowledge graph. It leverages the local IPFS daemon to achieve "Sovereignty Above All," ensuring that memory state is preserved across space and time without reliance on a single physical machine. * Implementation #+begin_src lisp (in-package :org-agent) (defun org-object-to-alist (obj) "Converts an org-object struct to an alist for JSON serialization." `((:id . ,(org-object-id obj)) (:type . ,(format nil "~s" (org-object-type obj))) (:attributes . ,(loop for (k v) on (org-object-attributes obj) by #'cddr collect (cons (format nil "~a" k) (format nil "~a" v)))) (:content . ,(org-object-content obj)) (:parent-id . ,(org-object-parent-id obj)) (:children . ,(org-object-children obj)) (:version . ,(org-object-version obj)) (:last-sync . ,(org-object-last-sync obj)) (:hash . ,(org-object-hash obj)))) (defun ipfs-checkpoint-memory () "Serializes the object-store and pushes it to IPFS." (let ((objects nil)) (maphash (lambda (id obj) (declare (ignore id)) (push (org-object-to-alist obj) objects)) *object-store*) (let* ((json-payload (cl-json:encode-json-to-string objects)) (ipfs-url "http://127.0.0.1:5001/api/v0/add")) (handler-case (let* ((response (dex:post ipfs-url :content `(("file" . ,json-payload)) :headers '(("Content-Type" . "multipart/form-data")))) (result (cl-json:decode-json-from-string response)) (cid (cdr (assoc :hash result)))) (kernel-log "IPFS - Memory checkpointed. CID: ~a" cid) `(:target :system :payload (:action :message :text ,(format nil "IPFS Checkpoint created: ~a" cid)))) (error (c) (kernel-log "IPFS ERROR - Checkpoint failed: ~a" c) `(:target :system :payload (:action :message :text "IPFS Checkpoint failed. Is the daemon running?"))))))) (def-cognitive-tool :ipfs-checkpoint "Creates an immutable snapshot of the current knowledge graph on IPFS." :parameters nil :body (lambda (args) (declare (ignore args)) (ipfs-checkpoint-memory))) (defskill :skill-ipfs :priority 90 :trigger (lambda (ctx) (eq (getf (getf ctx :payload) :command) :checkpoint-ipfs)) :neuro (lambda (ctx) "Propose an IPFS checkpoint if the user wants to backup or preserve current state.") :symbolic (lambda (action ctx) (ipfs-checkpoint-memory))) #+end_src