build: dynamically tangle to INSTALL_DIR without copying .org files
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 2s
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 2s
- Updated all 150+ :tangle headers across harness/ and skills/ to use elisp (expand-file-name) to target INSTALL_DIR dynamically. - Cleaned up environment/ directory depth by moving memory-image.lisp to state/. - Moved test scripts to tests/ and deleted redundant chat scripts.
This commit is contained in:
@@ -38,7 +38,7 @@ When something is blocked, the logs clearly show which layer blocked it and why.
|
||||
|
||||
* Package Context
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-bouncer.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-bouncer.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
@@ -58,7 +58,7 @@ The Bouncer implements the 5-Vector security model:
|
||||
|
||||
The vault stores sensitive credentials. This check scans action text for vault secrets to prevent accidental exposure.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-bouncer.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-bouncer.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun bouncer-scan-secrets (text)
|
||||
"Scans TEXT for known secrets from the vault.
|
||||
|
||||
@@ -91,7 +91,7 @@ The vault stores sensitive credentials. This check scans action text for vault s
|
||||
|
||||
Detects when shell commands try to send data to untrusted network destinations.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-bouncer.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-bouncer.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *bouncer-network-whitelist*
|
||||
'("api.telegram.org" "matrix.org" "googleapis.com" "openai.com" "anthropic.com")
|
||||
"Domains that the Bouncer considers safe for outbound connections.
|
||||
@@ -129,7 +129,7 @@ Detects when shell commands try to send data to untrusted network destinations.
|
||||
|
||||
** bouncer-check: Main Security Gate
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-bouncer.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-bouncer.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun bouncer-check (action context)
|
||||
"The 5-Vector security gate for high-risk actions.
|
||||
|
||||
@@ -213,7 +213,7 @@ Detects when shell commands try to send data to untrusted network destinations.
|
||||
|
||||
When a flight plan is approved in Emacs, the Bouncer detects it and re-injects the action.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-bouncer.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-bouncer.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun bouncer-process-approvals ()
|
||||
"Scans the object store for APPROVED flight plans and re-injects them.
|
||||
|
||||
@@ -269,7 +269,7 @@ When a flight plan is approved in Emacs, the Bouncer detects it and re-injects t
|
||||
|
||||
When the Bouncer intercepts a high-risk action, it creates a flight plan node for manual approval.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-bouncer.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-bouncer.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun bouncer-create-flight-plan (blocked-action)
|
||||
"Creates an Org node representing a pending flight plan for manual approval.
|
||||
|
||||
@@ -306,7 +306,7 @@ When the Bouncer intercepts a high-risk action, it creates a flight plan node fo
|
||||
|
||||
** Main Gate Function
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-bouncer.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-bouncer.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun bouncer-deterministic-gate (action context)
|
||||
"Main deterministic gate for the Bouncer skill.
|
||||
|
||||
@@ -345,7 +345,7 @@ When the Bouncer intercepts a high-risk action, it creates a flight plan node fo
|
||||
|
||||
** Skill Registration
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-bouncer.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-bouncer.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-bouncer
|
||||
:priority 150
|
||||
:trigger (lambda (ctx) (declare (ignore ctx)) t)
|
||||
|
||||
@@ -11,7 +11,7 @@ The *CLI Gateway* is the primary sensory and actuating interface for human inter
|
||||
|
||||
* Implementation
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-cli-gateway.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-cli-gateway.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
|
||||
(defvar *cli-port* 9105)
|
||||
(defvar *cli-server-socket* nil)
|
||||
|
||||
@@ -33,7 +33,7 @@ Securely manage all authentication tokens required for the opencortex to operate
|
||||
The vault provides a secure lookup table in RAM, backed by the persistent Memory. Access is restricted to internal kernel requests and explicitly authorized deterministic gates.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun vault-get-secret (provider &key type)
|
||||
"Retrieves a secret (api-key or session) for a provider.")
|
||||
|
||||
@@ -61,13 +61,13 @@ Tests in `tests/vault-tests.lisp` will verify:
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Package Context
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
#+end_src
|
||||
|
||||
** Vault State
|
||||
We maintain an in-memory hash table for secrets, which is hydrated from and persisted to the Memory.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar opencortex::*vault-memory* (make-hash-table :test 'equal)
|
||||
"In-memory cache of sensitive credentials.")
|
||||
#+end_src
|
||||
@@ -75,7 +75,7 @@ We maintain an in-memory hash table for secrets, which is hydrated from and pers
|
||||
** Helper: Secret Masking
|
||||
The `vault-mask-string` function ensures that diagnostic output never contains the full plaintext of a sensitive token.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun vault-mask-string (str)
|
||||
"Returns a masked version of a sensitive string."
|
||||
(if (and str (> (length str) 8))
|
||||
@@ -86,7 +86,7 @@ The `vault-mask-string` function ensures that diagnostic output never contains t
|
||||
** Retrieval (vault-get-secret)
|
||||
This function is the secure getter for all system secrets. It prioritizes the Vault (Memory) and falls back to environment variables for legacy compatibility.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun vault-get-secret (provider &key (type :api-key))
|
||||
"Retrieves a credential. Type can be :api-key or :session."
|
||||
(let* ((key (format nil "~a-~a" provider type))
|
||||
@@ -112,7 +112,7 @@ This function is the secure getter for all system secrets. It prioritizes the Va
|
||||
** Persistence (vault-set-secret)
|
||||
When a secret is updated, we immediately snapshot the Memory to ensure the credential change is versioned and durable.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun vault-set-secret (provider secret &key (type :api-key))
|
||||
"Securely stores a secret and triggers a Merkle snapshot."
|
||||
(let ((key (format nil "~a-~a" provider type)))
|
||||
@@ -125,7 +125,7 @@ When a secret is updated, we immediately snapshot the Memory to ensure the crede
|
||||
** Onboarding Logic
|
||||
Retained from the legacy Google skill, this provides the instructions for the autonomous cookie handshake.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun vault-onboard-gemini-web ()
|
||||
"Instructions for the Autonomous Cookie Handshake."
|
||||
(harness-log "--- GEMINI WEB ONBOARDING ---")
|
||||
@@ -137,7 +137,7 @@ Retained from the legacy Google skill, this provides the instructions for the au
|
||||
#+end_src
|
||||
|
||||
** Registration
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(progn
|
||||
(defskill :skill-credentials-vault
|
||||
:priority 200 ; High priority, foundational
|
||||
@@ -153,7 +153,7 @@ Retained from the legacy Google skill, this provides the instructions for the au
|
||||
Note: Tests disabled in jail load.
|
||||
|
||||
** 1. Unit Tests (FiveAM)
|
||||
#+begin_src lisp :tangle ./org-skill-credentials-vault.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-credentials-vault.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
#|
|
||||
(defpackage :opencortex-vault-tests
|
||||
(:use :cl :fiveam :opencortex))
|
||||
|
||||
@@ -58,14 +58,14 @@ Single entry point `emacs-edit-modify` takes a file path, operation, and paramet
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Package Context
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
** ID Generation
|
||||
Generate unique IDs for headlines.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun emacs-edit-generate-id ()
|
||||
"Generates a unique ID for org-mode headlines.
|
||||
Format: 8-char hex + timestamp for uniqueness."
|
||||
@@ -84,7 +84,7 @@ Format: 8-char hex + timestamp for uniqueness."
|
||||
** Org Printer (AST → Org Format)
|
||||
Converts AST back to org format, preserving structure.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun emacs-edit-print-headline (ast &key indent-level)
|
||||
"Converts a HEADLINE AST node to org text.
|
||||
INDENT-LEVEL is number of leading asterisks."
|
||||
@@ -154,7 +154,7 @@ Preserves structure including #+begin_src blocks."
|
||||
** Read Operation
|
||||
Parse org file to AST.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *org-parser-cache* (make-hash-table :test 'equal)
|
||||
"Cache for parsed org files.")
|
||||
|
||||
@@ -180,7 +180,7 @@ Returns the parsed AST. Uses cache for performance."
|
||||
** Write Operation
|
||||
Write AST back to file preserving structure.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun emacs-edit-write-file (file-path ast)
|
||||
"Writes AST back to FILE-PATH, preserving org structure.
|
||||
Clears cache after write."
|
||||
@@ -194,7 +194,7 @@ Clears cache after write."
|
||||
** Add Headline Operation
|
||||
Add a new headline to an existing AST.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun emacs-edit-add-headline (ast title &key todo properties)
|
||||
"Adds a new headline to AST.
|
||||
Returns modified AST."
|
||||
@@ -223,7 +223,7 @@ Returns modified AST."
|
||||
** Set Property Operation
|
||||
Set a property on an existing headline (by ID or TITLE).
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun emacs-edit-find-headline-by-id (ast target-id)
|
||||
"Recursively finds headline with matching :ID: property."
|
||||
(when (eq (getf ast :type) :headline)
|
||||
@@ -267,7 +267,7 @@ Returns modified AST."
|
||||
** Set TODO State Operation
|
||||
Change TODO state (TODO → DONE → etc).
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun emacs-edit-set-todo (ast target new-state)
|
||||
"Sets TODO state on headline matching TARGET.
|
||||
NEW-STATE should be 'TODO', 'DONE', 'IN-PROGRESS', etc."
|
||||
@@ -278,7 +278,7 @@ NEW-STATE should be 'TODO', 'DONE', 'IN-PROGRESS', etc."
|
||||
** Unified Entry Point
|
||||
Main operation dispatcher.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun emacs-edit-modify (file-path operation &key params)
|
||||
"Main entry point for org-mode file manipulation.
|
||||
OPERATIONS:
|
||||
@@ -321,7 +321,7 @@ OPERATIONS:
|
||||
** Cognitive Tools
|
||||
Exposes operations to the Probabilistic Engine.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-emacs-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-emacs-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(def-cognitive-tool :org-read
|
||||
"Reads an org-mode file and parses it to structured AST.
|
||||
Use this BEFORE modifying org files to understand their structure."
|
||||
@@ -388,7 +388,7 @@ Use this AFTER modifications to save changes."
|
||||
#+end_src
|
||||
|
||||
* Phase E: Chaos (Verification)
|
||||
#+begin_src lisp :tangle ./tests/emacs-edit-tests.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "tests/emacs-edit-tests.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defpackage :opencortex-emacs-edit-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:emacs-edit-suite))
|
||||
|
||||
@@ -107,7 +107,7 @@ The engineering standards skill is a HARD BLOCK gate. Violations are rejected, n
|
||||
|
||||
** Pre-Task Enforcement (Blocking)
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-engineering-standards.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-engineering-standards.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
|
||||
(defvar *engineering-std-*project-root* nil
|
||||
@@ -137,7 +137,7 @@ The engineering standards skill is a HARD BLOCK gate. Violations are rejected, n
|
||||
|
||||
** Git Clean Check (Blocking)
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-engineering-standards.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-engineering-standards.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun verify-git-clean-p (&optional (dir *engineering-std-*project-root*))
|
||||
"Returns T if the git repository at DIR has no uncommitted changes."
|
||||
(when dir
|
||||
@@ -162,7 +162,7 @@ The engineering standards skill is a HARD BLOCK gate. Violations are rejected, n
|
||||
These tests verify the enforcement logic. Run with:
|
||||
~(fiveam:run! 'engineering-standards-suite)~
|
||||
|
||||
#+begin_src lisp :tangle ./tests/engineering-standards-tests.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "tests/engineering-standards-tests.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defpackage :opencortex-engineering-standards-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:engineering-standards-suite))
|
||||
@@ -229,7 +229,7 @@ These tests verify the enforcement logic. Run with:
|
||||
|
||||
** Blocking Gate (Hard Enforcement)
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-engineering-standards.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-engineering-standards.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun engineering-standards-gate (action context)
|
||||
"The deterministic HARD BLOCK gate for Engineering Standards.
|
||||
|
||||
@@ -262,7 +262,7 @@ These tests verify the enforcement logic. Run with:
|
||||
|
||||
The skill runs at highest priority (1000) to block violations before any other skill.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-engineering-standards.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-engineering-standards.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-engineering-standards
|
||||
:priority 1000
|
||||
:trigger (lambda (ctx)
|
||||
@@ -274,7 +274,7 @@ The skill runs at highest priority (1000) to block violations before any other s
|
||||
|
||||
** Initialize Project Root
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-engineering-standards.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-engineering-standards.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *engineering-std-initialized* nil)
|
||||
|
||||
(defun engineering-std-init ()
|
||||
|
||||
@@ -37,14 +37,14 @@ The Gardener runs on a low-priority heartbeat. It performs a "Deep Audit" of the
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Package Context
|
||||
#+begin_src lisp :tangle ./org-skill-gardener.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-gardener.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
** State: Maintenance Cycle
|
||||
We track the last audit time to ensure the Gardener doesn't over-consume resources.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-gardener.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-gardener.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *gardener-last-audit* 0
|
||||
"The universal-time of the last full Memex audit.")
|
||||
#+end_src
|
||||
@@ -52,7 +52,7 @@ We track the last audit time to ensure the Gardener doesn't over-consume resourc
|
||||
** Audit: Broken Links
|
||||
Scans the content of all objects for `id:` links and verifies the targets exist.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-gardener.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-gardener.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun gardener-find-broken-links ()
|
||||
"Returns a list of broken ID links found in the Memex."
|
||||
(let ((broken nil))
|
||||
@@ -69,7 +69,7 @@ Scans the content of all objects for `id:` links and verifies the targets exist.
|
||||
** Audit: Orphaned Nodes
|
||||
Identifies nodes that are not linked to and do not link to anything else.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-gardener.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-gardener.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun gardener-find-orphans ()
|
||||
"Returns a list of IDs for headlines that are structurally isolated."
|
||||
(let ((inbound (make-hash-table :test 'equal))
|
||||
@@ -95,7 +95,7 @@ Identifies nodes that are not linked to and do not link to anything else.
|
||||
** Skill Logic: The Audit Pass
|
||||
The Gardener's deterministic gate performs the actual analysis and logs the results. In future versions, it will generate probabilistic repair proposals.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-gardener.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-gardener.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun gardener-deterministic-gate (action context)
|
||||
"Main gate for the Gardener skill. Audits graph integrity."
|
||||
(declare (ignore action context))
|
||||
@@ -118,7 +118,7 @@ The Gardener's deterministic gate performs the actual analysis and logs the resu
|
||||
#+end_src
|
||||
|
||||
** Skill Registration
|
||||
#+begin_src lisp :tangle ./org-skill-gardener.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-gardener.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-gardener
|
||||
:priority 40
|
||||
:trigger (lambda (ctx)
|
||||
|
||||
@@ -11,7 +11,7 @@ The *Homoiconic Memory* skill provides the core persistence layer for OpenCortex
|
||||
|
||||
* Implementation
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-homoiconic-memory.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-homoiconic-memory.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
|
||||
(defun memory-org-to-json (source)
|
||||
"Converts Org-mode source to JSON AST."
|
||||
|
||||
@@ -61,14 +61,14 @@ Separate repair functions that can be called independently.
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Package Context
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
** Character & String Utilities
|
||||
General-purpose utilities for string manipulation.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun count-char (char string)
|
||||
"Counts occurrences of CHAR in STRING.
|
||||
Returns an integer count."
|
||||
@@ -83,7 +83,7 @@ Returns an integer count."
|
||||
Attempts instant fixes on broken Lisp code (e.g., balancing parens).
|
||||
This is the fast path - used for simple syntax errors.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun deterministic-repair (code)
|
||||
"Attempts instant fixes on broken Lisp code (e.g., balancing parens).
|
||||
Returns the fixed code string."
|
||||
@@ -99,7 +99,7 @@ Returns the fixed code string."
|
||||
Uses the LLM to deeply repair syntax structure when deterministic fails.
|
||||
This is the slow path - used for complex errors.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun neural-repair (code error-message)
|
||||
"Uses the Probabilistic Engine to deeply repair the syntax structure.
|
||||
Returns the fixed code string."
|
||||
@@ -117,7 +117,7 @@ MANDATE: Output EXACTLY ONE valid Common Lisp list. Do not explain. Do not use m
|
||||
Scans the raw string character-by-character, tracking open/close pairs.
|
||||
This is O(n) and does not invoke the Lisp reader.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun lisp-utils-check-structural (code-string)
|
||||
"Checks for balanced parens, brackets, and terminated strings.
|
||||
Returns (VALUES t nil) if clean, or (VALUES nil reason-string line col)."
|
||||
@@ -173,7 +173,7 @@ Returns (VALUES t nil) if clean, or (VALUES nil reason-string line col)."
|
||||
** Check 2: Syntactic Validation (Reader Check)
|
||||
Wraps the code and attempts to read with *read-eval* disabled.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun lisp-utils-check-syntactic (code-string)
|
||||
"Checks if the code can be read by SBCL with *read-eval* nil.
|
||||
Returns (VALUES t nil) if clean, or (VALUES nil error-message nil nil)."
|
||||
@@ -190,7 +190,7 @@ Returns (VALUES t nil) if clean, or (VALUES nil error-message nil nil)."
|
||||
** Check 3: Semantic Validation (Whitelist AST Walk)
|
||||
Recursively walks the parsed AST and verifies whitelisted symbols.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defparameter *lisp-utils-whitelist*
|
||||
'(;; Math & Logic
|
||||
+ - * / = < > <= >= 1+ 1- min max mod abs floor ceiling round
|
||||
@@ -272,7 +272,7 @@ Returns (VALUES t nil) if clean, or (VALUES nil reason-string nil nil)."
|
||||
** Unified Entry Point
|
||||
Orchestrates the three validation checks.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun lisp-utils-validate (code-string &key strict)
|
||||
"Validates Lisp code through structural, syntactic, and optional semantic checks.
|
||||
Returns a plist:
|
||||
@@ -310,7 +310,7 @@ When STRICT is non-nil, the semantic whitelist check is enforced."
|
||||
** Cognitive Tools
|
||||
Exposes utilities to the Probabilistic Engine.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(def-cognitive-tool :validate-lisp
|
||||
"Deterministically validates Lisp code for structural, syntactic, and semantic correctness.
|
||||
Use this BEFORE declaring any Lisp code edit complete."
|
||||
@@ -348,7 +348,7 @@ Use this BEFORE declaring any Lisp code edit complete."
|
||||
** Skill Definition: Lisp Repair
|
||||
Intercepts :syntax-error events and repairs the code.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-lisp-repair
|
||||
:priority 90
|
||||
:trigger (lambda (ctx) (eq (getf (getf ctx :payload) :sensor) :syntax-error))
|
||||
@@ -379,7 +379,7 @@ Intercepts :syntax-error events and repairs the code.
|
||||
** Skill Definition: Lisp Validator
|
||||
Validates all Lisp code before execution.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-utils.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-utils.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-lisp-validator
|
||||
:priority 900
|
||||
:trigger (lambda (ctx)
|
||||
@@ -407,7 +407,7 @@ Validates all Lisp code before execution.
|
||||
#+end_src
|
||||
|
||||
* Phase E: Chaos (Verification)
|
||||
#+begin_src lisp :tangle ./tests/lisp-utils-tests.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "tests/lisp-utils-tests.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defpackage :opencortex-lisp-utils-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:lisp-utils-suite))
|
||||
@@ -511,7 +511,7 @@ Validates all Lisp code before execution.
|
||||
These tests verify the Lisp Validator gate. Run with:
|
||||
~(fiveam:run! 'lisp-validator-suite)~
|
||||
|
||||
#+begin_src lisp :tangle ./tests/lisp-validator-tests.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "tests/lisp-validator-tests.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defpackage :opencortex-lisp-validator-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:lisp-validator-suite))
|
||||
|
||||
@@ -33,11 +33,11 @@ Define a high-integrity, recursive security sandbox for Lisp execution.
|
||||
* Implementation
|
||||
|
||||
** Package
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-validator.lisp :tangle ./org-skill-lisp-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills")) :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
#+end_src
|
||||
|
||||
** Whitelist Definition
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-validator.lisp :tangle ./org-skill-lisp-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills")) :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defparameter *lisp-validator-whitelist*
|
||||
'(;; Math & Logic
|
||||
+ - * / = < > <= >= 1+ 1- min max
|
||||
@@ -83,7 +83,7 @@ Define a high-integrity, recursive security sandbox for Lisp execution.
|
||||
** Dynamic Symbol Registration
|
||||
We allow other skills to register safe symbols for the validator.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *lisp-validator-registry* nil
|
||||
"List of dynamically registered safe symbols.")
|
||||
|
||||
@@ -99,7 +99,7 @@ We allow other skills to register safe symbols for the validator.
|
||||
#+end_src
|
||||
|
||||
** Recursive AST Walker
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun lisp-validator-ast-walk (form)
|
||||
"Recursively walks the Lisp AST. Returns T if safe, NIL if unsafe."
|
||||
(cond
|
||||
@@ -124,7 +124,7 @@ We allow other skills to register safe symbols for the validator.
|
||||
#+end_src
|
||||
|
||||
** Cognitive Tools
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(opencortex:def-cognitive-tool :lisp-validator-status "Returns validator-related telemetry, including blocked actions and harness status."
|
||||
nil
|
||||
:body (lambda (args)
|
||||
@@ -139,7 +139,7 @@ We allow other skills to register safe symbols for the validator.
|
||||
#+end_src
|
||||
|
||||
** Skill Definition
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(opencortex:defskill :skill-lisp-validator
|
||||
:priority 900 ; High priority, before most skills
|
||||
:trigger (lambda (ctx)
|
||||
@@ -156,7 +156,7 @@ We allow other skills to register safe symbols for the validator.
|
||||
|
||||
|
||||
* Phase E: Chaos (Verification)
|
||||
#+begin_src lisp :tangle ./org-skill-lisp-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-lisp-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defpackage :opencortex-lisp-validator-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:lisp-validator-suite))
|
||||
|
||||
@@ -57,7 +57,7 @@ Code without surrounding prose is a bug report waiting to happen.
|
||||
|
||||
** Block Balance Checker
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-literate-programming.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-literate-programming.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
|
||||
(defun literate-check-block-balance (code-string)
|
||||
@@ -94,7 +94,7 @@ Code without surrounding prose is a bug report waiting to happen.
|
||||
|
||||
** File-Level Balance Audit
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-literate-programming.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-literate-programming.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun literate-audit-org-file (filepath)
|
||||
"Audits all tangled lisp blocks in an Org file for structural balance.
|
||||
|
||||
@@ -113,7 +113,7 @@ Code without surrounding prose is a bug report waiting to happen.
|
||||
(header (subseq content pos eol))
|
||||
(header-lower (string-downcase header))
|
||||
(tangle-p (and (search ".lisp" header-lower)
|
||||
(not (search ":tangle no" header-lower)))))
|
||||
(not (search ":tangle (expand-file-name "no"" (concat (or (getenv "INSTALL_DIR") ".") "/skills")) header-lower)))))
|
||||
(if (not tangle-p)
|
||||
(setf idx (1+ eol))
|
||||
(let ((end-pos (search "#+end_src" content :start2 eol :test #'string-equal)))
|
||||
@@ -145,7 +145,7 @@ Code without surrounding prose is a bug report waiting to happen.
|
||||
|
||||
Verifies that tangled `.lisp` files are in sync with their Org source. Violation: edited .lisp directly instead of through Org.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-literate-programming.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-literate-programming.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *tangle-targets*
|
||||
'(("skills/org-skill-engineering-standards.org" . "library/gen/org-skill-engineering-standards.lisp")
|
||||
("skills/org-skill-literate-programming.org" . "library/gen/org-skill-literate-programming.lisp")
|
||||
@@ -184,7 +184,7 @@ This detects direct .lisp edits (which violate the LP workflow)."
|
||||
|
||||
The LP skill runs at priority 1100 (just below engineering-standards at 1000).
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-literate-programming.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-literate-programming.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-literate-programming
|
||||
:priority 1100
|
||||
:trigger (lambda (ctx)
|
||||
@@ -218,7 +218,7 @@ The LP skill runs at priority 1100 (just below engineering-standards at 1000).
|
||||
|
||||
** Initialize Project Root
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-literate-programming.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-literate-programming.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *lp-initialized* nil)
|
||||
|
||||
(defun lp-init ()
|
||||
@@ -240,7 +240,7 @@ The LP skill runs at priority 1100 (just below engineering-standards at 1000).
|
||||
These tests verify the LP enforcement logic. Run with:
|
||||
~(fiveam:run! 'literate-programming-suite)~
|
||||
|
||||
#+begin_src lisp :tangle ./tests/literate-programming-tests.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "tests/literate-programming-tests.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defpackage :opencortex-literate-programming-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:literate-programming-suite))
|
||||
|
||||
@@ -21,12 +21,12 @@ This skill acts as a proxy between the OpenCortex kernel and the Lisp-agnostic `
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Package Context
|
||||
#+begin_src lisp :tangle ./org-skill-llama-backend.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-llama-backend.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
** The Inference Engine (llama-inference)
|
||||
#+begin_src lisp :tangle ./org-skill-llama-backend.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-llama-backend.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun llama-inference (prompt system-prompt &key (model "local-model"))
|
||||
"Sends a completion request to the local llama.cpp server."
|
||||
(let ((endpoint (uiop:getenv "LLAMACPP_ENDPOINT")))
|
||||
@@ -51,7 +51,7 @@ This skill acts as a proxy between the OpenCortex kernel and the Lisp-agnostic `
|
||||
#+end_src
|
||||
|
||||
** Registration
|
||||
#+begin_src lisp :tangle ./org-skill-llama-backend.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-llama-backend.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(progn
|
||||
(register-probabilistic-backend :llama #'llama-inference)
|
||||
(harness-log "LLAMA: Local backend registered and active."))
|
||||
|
||||
@@ -19,7 +19,7 @@ The gateway utilizes a functional dispatch pattern. A single entry point, `execu
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Implementation
|
||||
#+begin_src lisp :tangle ./org-skill-llm-gateway.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-llm-gateway.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
|
||||
(defun get-nested (alist &rest keys)
|
||||
"Recursively extracts nested values from an alist, handling both objects and arrays."
|
||||
|
||||
@@ -37,7 +37,7 @@ Move context pruning and rendering logic out of `context.lisp` to allow for more
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-peripheral-vision.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-peripheral-vision.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun context-render-to-org (obj &key depth foveal-id semantic-threshold foveal-vector)
|
||||
"Recursively renders an org-object with foveal-peripheral pruning.")
|
||||
|
||||
@@ -48,7 +48,7 @@ Move context pruning and rendering logic out of `context.lisp` to allow for more
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Foveal-Peripheral Pruning
|
||||
#+begin_src lisp :tangle ./org-skill-peripheral-vision.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-peripheral-vision.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
|
||||
(defun context-render-to-org (obj &key (depth 1) (foveal-id nil) (semantic-threshold 0.75) (foveal-vector nil))
|
||||
"Recursively renders an org-object and its children to an Org string using a Foveal-Peripheral Hybrid model."
|
||||
@@ -112,7 +112,7 @@ Move context pruning and rendering logic out of `context.lisp` to allow for more
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp :tangle ./org-skill-peripheral-vision.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-peripheral-vision.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-peripheral-vision
|
||||
:priority 90
|
||||
:dependencies ("org-skill-embedding")
|
||||
|
||||
@@ -44,7 +44,7 @@ Therefore, Policy encodes not just rules, but *values*:
|
||||
|
||||
Every skill executes within its own jailed package namespace, inheriting core harness symbols while maintaining isolation from other skills.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
@@ -61,7 +61,7 @@ When two invariants conflict, resolution follows a strict priority order. This p
|
||||
| 200 | Mentorship | Teaching increases capability; doing removes it |
|
||||
| 100 | Sustainability | Offline capability today enables 100-year survival |
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *policy-invariant-priorities*
|
||||
'((:transparency . 500)
|
||||
(:autonomy . 400)
|
||||
@@ -91,7 +91,7 @@ At the gate:
|
||||
- Every user-facing action must carry an `:explanation`
|
||||
- Log messages must include the triggering invariant
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun policy-check-transparency (action context)
|
||||
"Ensures the action is inspectable and user-facing actions carry an explanation.
|
||||
|
||||
@@ -137,7 +137,7 @@ At the gate:
|
||||
|
||||
Every action should increase the user's independence from centralized, proprietary platforms. When the system uses a proprietary API, it's logged as "autonomy debt"—acceptable tactically, but flagged for eventual replacement.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *proprietary-domain-watchlist*
|
||||
'("googleapis.com" "api.openai.com" "anthropic.com" "api.groq.com" "openrouter.ai")
|
||||
"Domains representing centralized, proprietary control.
|
||||
@@ -204,7 +204,7 @@ Every action should increase the user's independence from centralized, proprieta
|
||||
|
||||
The system harness must remain minimalist. "Just-in-case" code is a security vulnerability. Complexity must be earned through demonstrated need, not anticipation of future use.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *policy-max-skill-size-chars* 50000
|
||||
"Maximum recommended size for a skill file tangled from an Org note.
|
||||
|
||||
@@ -255,7 +255,7 @@ This is the most important invariant for system stability. If the harness grows
|
||||
- Harder to debug when things go wrong
|
||||
- Harder to maintain across versions
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *modularity-protected-paths*
|
||||
'("harness/" "opencortex.asd")
|
||||
"Paths that constitute the unbreakable core of the system.
|
||||
@@ -322,7 +322,7 @@ This is the most important invariant for system stability. If the harness grows
|
||||
|
||||
The agent's goal is not to "do it for the user," but to "empower the user." Every autonomous action must be explained at a level that increases the user's technical understanding.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *mentorship-required-actions*
|
||||
'(:create-skill :eval :modify-file :write-file :replace
|
||||
:rename-file :delete-file :shell :create-note)
|
||||
@@ -379,7 +379,7 @@ The Memex should be functional even when:
|
||||
|
||||
This means preferring local, energy-efficient architectures over cloud-dependent ones.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *cloud-only-backends* '(:openrouter :openai :anthropic :groq :gemini-api)
|
||||
"Backends requiring internet connection and external infrastructure.
|
||||
|
||||
@@ -416,7 +416,7 @@ This means preferring local, energy-efficient architectures over cloud-dependent
|
||||
|
||||
When the policy gate blocks or modifies an action, it must tell the user *why*. This creates an auditable log of every policy decision.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun policy-explain (invariant-key message &optional original-action)
|
||||
"Formats a policy decision into an auditable explanation plist.
|
||||
|
||||
@@ -445,7 +445,7 @@ When the policy gate blocks or modifies an action, it must tell the user *why*.
|
||||
|
||||
** Running Invariant Checks
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun policy-run-invariant-checks (action context)
|
||||
"Runs all invariant checks in priority order.
|
||||
|
||||
@@ -492,7 +492,7 @@ When the policy gate blocks or modifies an action, it must tell the user *why*.
|
||||
|
||||
** Finding Engineering Standards
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun policy-find-engineering-standards-gate ()
|
||||
"Searches for the Engineering Standards gate across known jailed package names.
|
||||
|
||||
@@ -515,7 +515,7 @@ When the policy gate blocks or modifies an action, it must tell the user *why*.
|
||||
|
||||
** Main Policy Gate
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun policy-deterministic-gate (action context)
|
||||
"The main policy gate entry point.
|
||||
|
||||
@@ -547,7 +547,7 @@ When the policy gate blocks or modifies an action, it must tell the user *why*.
|
||||
|
||||
* Skill Registration
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-policy.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-policy.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-policy
|
||||
:priority 500
|
||||
:trigger (lambda (ctx) (declare (ignore ctx)) t)
|
||||
|
||||
@@ -45,7 +45,7 @@ Decouple protocol parsing (framing/unframing) from semantic validation.
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Schema Enforcement
|
||||
#+begin_src lisp :tangle ./org-skill-protocol-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-protocol-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
|
||||
(defun validate-communication-protocol-schema (msg)
|
||||
@@ -84,7 +84,7 @@ Decouple protocol parsing (framing/unframing) from semantic validation.
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp :tangle ./org-skill-protocol-validator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-protocol-validator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-communication-protocol-validator
|
||||
:priority 95
|
||||
:trigger (lambda (ctx) (member (getf (getf ctx :payload) :sensor) '(:protocol-received)))
|
||||
|
||||
@@ -41,14 +41,14 @@ The Scribe reacts to the `:heartbeat` sensor. It maintains a state file (`scribe
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Package Context
|
||||
#+begin_src lisp :tangle ./org-skill-scribe.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-scribe.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
** State: Checkpoint Management
|
||||
We track the last processed universal time to avoid redundant distillation.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-scribe.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-scribe.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *scribe-last-checkpoint* 0
|
||||
"The universal-time of the last successful distillation run.")
|
||||
|
||||
@@ -70,7 +70,7 @@ We track the last processed universal time to avoid redundant distillation.
|
||||
** Filtering: Privacy & Relevance
|
||||
The Scribe only cares about non-personal, non-distilled headlines.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-scribe.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-scribe.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun scribe-get-distillable-nodes ()
|
||||
"Returns a list of org-objects from the daily/ folder that require distillation."
|
||||
(let ((results nil))
|
||||
@@ -91,7 +91,7 @@ The Scribe only cares about non-personal, non-distilled headlines.
|
||||
** Probabilistic: Extraction Prompt
|
||||
The LLM is tasked with identifying atomic concepts within the raw text.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-scribe.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-scribe.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun probabilistic-skill-scribe (context)
|
||||
"Generates the extraction prompt for the Scribe."
|
||||
(let* ((payload (getf context :payload))
|
||||
@@ -122,7 +122,7 @@ TEXT:
|
||||
** Deterministic: Note Committal
|
||||
The deterministic gate receives the list of proposed notes and writes them to the filesystem.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-scribe.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-scribe.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun scribe-commit-notes (proposals)
|
||||
"Writes proposed atomic notes to the notes/ directory. Appends if the note exists."
|
||||
(let ((notes-dir (uiop:merge-pathnames* "notes/" (asdf:system-source-directory :opencortex))))
|
||||
@@ -159,7 +159,7 @@ The deterministic gate receives the list of proposed notes and writes them to th
|
||||
#+end_src
|
||||
|
||||
** Skill Registration
|
||||
#+begin_src lisp :tangle ./org-skill-scribe.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-scribe.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-scribe
|
||||
:priority 50
|
||||
:trigger (lambda (ctx)
|
||||
@@ -174,6 +174,6 @@ The deterministic gate receives the list of proposed notes and writes them to th
|
||||
#+end_src
|
||||
|
||||
** Initialization
|
||||
#+begin_src lisp :tangle ./org-skill-scribe.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-scribe.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(scribe-load-state)
|
||||
#+end_src
|
||||
|
||||
@@ -14,14 +14,14 @@ The *Self-Edit Agent* enables the agent to modify its own code and files with sa
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Package Context
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
** Deterministic Paren Repair
|
||||
Fast paren balancing for syntax errors.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun self-edit-count-char (char string)
|
||||
"Counts occurrences of CHAR in STRING."
|
||||
(loop for c across string count (char= c char)))
|
||||
@@ -41,7 +41,7 @@ Fast paren balancing for syntax errors.
|
||||
** Parse Target Location
|
||||
Extract file and line info from error context.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun self-edit-parse-location (context)
|
||||
"Extracts file and line from error context payload."
|
||||
(let* ((payload (getf context :payload))
|
||||
@@ -58,7 +58,7 @@ Extract file and line info from error context.
|
||||
** Apply Surgical Edit
|
||||
Apply a find/replace to a file with rollback on failure.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun self-edit-apply (target-file old-code new-code)
|
||||
"Applies surgical edit to TARGET-FILE: replace OLD-CODE with NEW-CODE.
|
||||
Returns list with :status and :message keys."
|
||||
@@ -90,7 +90,7 @@ Returns list with :status and :message keys."
|
||||
#+end_src
|
||||
|
||||
** Cognitive Tool: Edit File
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(def-cognitive-tool :self-edit
|
||||
"Applies a surgical code modification to a file with automatic rollback on failure."
|
||||
((:file :type :string :description "Path to the target file")
|
||||
@@ -106,7 +106,7 @@ Returns list with :status and :message keys."
|
||||
** Skill Definition
|
||||
Hooks into syntax-error events for self-repair.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-self-edit
|
||||
:priority 95
|
||||
:trigger (lambda (ctx)
|
||||
@@ -146,7 +146,7 @@ Provide a fixed version of the code as a lisp form.")
|
||||
#+end_src
|
||||
|
||||
** Tool: Quick Paren Fix
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(def-cognitive-tool :balance-parens
|
||||
"Balances parentheses in a code string."
|
||||
((:code :type :string :description "The code to balance"))
|
||||
@@ -164,7 +164,7 @@ Provide a fixed version of the code as a lisp form.")
|
||||
** Skill Hot-Reload
|
||||
Swap compiled skill files without breaking active sockets.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defvar *self-edit-skills-backup* nil
|
||||
"Backup of skill registry before hot-reload.")
|
||||
|
||||
@@ -217,7 +217,7 @@ Swap compiled skill files without breaking active sockets.
|
||||
|
||||
** Cognitive Tool: Reload Skill
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-self-edit.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-edit.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(def-cognitive-tool :reload-skill
|
||||
"Hot-reloads a skill from its compiled source file without restarting the system."
|
||||
((:skill-name :type :string :description "Name of the skill to reload (e.g. :skill-engineering-standards)")
|
||||
@@ -231,7 +231,7 @@ Swap compiled skill files without breaking active sockets.
|
||||
|
||||
* Phase E: Verification
|
||||
|
||||
#+begin_src lisp :tangle ./tests/self-edit-tests.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "tests/self-edit-tests.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defpackage :opencortex-self-edit-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:self-edit-suite))
|
||||
|
||||
@@ -15,11 +15,11 @@ This skill enables self-editing by applying surgical fixes to files (including s
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Repair Logic
|
||||
#+begin_src lisp :tangle ./org-skill-self-fix.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-fix.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
#+end_src
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-self-fix.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-fix.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defun self-fix-apply (action context)
|
||||
"Applies a surgical code fix and reloads the modified skill."
|
||||
(declare (ignore context))
|
||||
@@ -66,7 +66,7 @@ This skill enables self-editing by applying surgical fixes to files (including s
|
||||
#+end_src
|
||||
|
||||
** Cognitive Tool
|
||||
#+begin_src lisp :tangle ./org-skill-self-fix.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-fix.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(def-cognitive-tool :repair-file
|
||||
"Applies a surgical code modification to a file and reloads the skill if applicable."
|
||||
((:file :type :string :description "Path to the target file")
|
||||
@@ -79,7 +79,7 @@ This skill enables self-editing by applying surgical fixes to files (including s
|
||||
#+end_src
|
||||
|
||||
** Skill Definition
|
||||
#+begin_src lisp :tangle ./org-skill-self-fix.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-self-fix.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defskill :skill-self-fix
|
||||
:priority 95
|
||||
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :repair-request))
|
||||
|
||||
@@ -11,7 +11,7 @@ The *Shell Actuator* provides a controlled interface for the OpenCortex to execu
|
||||
|
||||
* Implementation
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-shell-actuator.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-shell-actuator.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
|
||||
(defparameter *allowed-commands* '("ls" "git" "rg" "grep" "date" "echo" "cat" "node" "python3" "sbcl"))
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ Also provides vector embeddings via Ollama or llama.cpp.
|
||||
* Implementation
|
||||
Tool permissions and embedding generation via multiple providers.
|
||||
|
||||
#+begin_src lisp :tangle ./org-skill-tool-permissions.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "org-skill-tool-permissions.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(in-package :opencortex)
|
||||
|
||||
(defvar *tool-permissions* (make-hash-table :test 'equal)
|
||||
@@ -122,7 +122,7 @@ Tool permissions and embedding generation via multiple providers.
|
||||
These tests verify tool permissions. Run with:
|
||||
~(fiveam:run! 'tool-permissions-suite)~
|
||||
|
||||
#+begin_src lisp :tangle ./tests/tool-permissions-tests.lisp
|
||||
#+begin_src lisp :tangle (expand-file-name "tests/tool-permissions-tests.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/skills"))
|
||||
(defpackage :opencortex-tool-permissions-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:tool-permissions-suite))
|
||||
|
||||
Reference in New Issue
Block a user