ARCH: Clean Core Refactor & Terminology Alignment
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
(in-package :org-agent)
|
||||
|
||||
(defun ask-neuro (prompt &key (system-prompt "You are the System 1 engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
|
||||
(defun ask-neuro (prompt &key (system-prompt "You are the Probabilistic Engine engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
|
||||
"Dispatches a neural request through the provider cascade.
|
||||
If CASCADE is a function, it is called with CONTEXT to determine backends."
|
||||
(let ((backends (cond
|
||||
@@ -11,7 +11,7 @@
|
||||
(dolist (backend backends)
|
||||
(let ((backend-fn (gethash backend *neuro-backends*)))
|
||||
(when backend-fn
|
||||
(kernel-log "SYSTEM 1: Attempting backend ~a..." backend)
|
||||
(kernel-log "PROBABILISTIC ENGINE: Attempting backend ~a..." backend)
|
||||
(let* (;; Consult the Economist for the model ID if the skill is available
|
||||
(model (ignore-errors
|
||||
(uiop:symbol-call :org-agent.skills.org-skill-economist :economist-get-model-for-provider backend)))
|
||||
@@ -19,7 +19,7 @@
|
||||
(funcall backend-fn prompt system-prompt :model model)
|
||||
(funcall backend-fn prompt system-prompt))))
|
||||
(if (and (stringp result) (search ":LOG" result) (or (search "Failure" result) (search "missing" result)))
|
||||
(kernel-log "SYSTEM 1: Backend ~a failed. Falling back..." backend)
|
||||
(kernel-log "PROBABILISTIC ENGINE: Backend ~a failed. Falling back..." backend)
|
||||
(return-from ask-neuro result))))))
|
||||
"(:type :LOG :payload (:text \"Neural Cascade Failure\"))"))
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(in-package :org-agent)
|
||||
|
||||
(defun ask-neuro (prompt &key (system-prompt "You are the System 1 engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
|
||||
(defun ask-neuro (prompt &key (system-prompt "You are the Probabilistic Engine engine of a Neurosymbolic Lisp Machine.") (cascade nil) (context nil))
|
||||
(let ((backends (cond
|
||||
((listp cascade) cascade)
|
||||
((functionp cascade) (funcall cascade context))
|
||||
@@ -9,14 +9,14 @@
|
||||
(dolist (backend backends)
|
||||
(let ((backend-fn (gethash backend *neuro-backends*)))
|
||||
(when backend-fn
|
||||
(kernel-log "SYSTEM 1: Attempting backend ~a..." backend)
|
||||
(kernel-log "PROBABILISTIC ENGINE: Attempting backend ~a..." backend)
|
||||
(let* ((model (ignore-errors
|
||||
(uiop:symbol-call :org-agent.skills.org-skill-economist :economist-get-model-for-provider backend)))
|
||||
(result (if model
|
||||
(funcall backend-fn prompt system-prompt :model model)
|
||||
(funcall backend-fn prompt system-prompt))))
|
||||
(kernel-log "SYSTEM 1: Backend ~a returned: ~a" backend (if (stringp result) (subseq result 0 (min 50 (length result))) result))
|
||||
(kernel-log "PROBABILISTIC ENGINE: Backend ~a returned: ~a" backend (if (stringp result) (subseq result 0 (min 50 (length result))) result))
|
||||
(if (and (stringp result) (search ":LOG" result) (or (search "Failure" result) (search "missing" result)))
|
||||
(kernel-log "SYSTEM 1: Backend ~a failed. Falling back..." backend)
|
||||
(kernel-log "PROBABILISTIC ENGINE: Backend ~a failed. Falling back..." backend)
|
||||
(return-from ask-neuro result))))))
|
||||
"(:type :LOG :payload (:text \"Neural Cascade Failure\"))"))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
(let ((active-skill (find-triggered-skill context)))
|
||||
(if active-skill
|
||||
(progn
|
||||
(kernel-log "SYSTEM 1: Engaging skill '~a'~%" (skill-name active-skill))
|
||||
(kernel-log "PROBABILISTIC ENGINE: Engaging skill '~a'~%" (skill-name active-skill))
|
||||
(let* ((prompt-generator (skill-neuro-prompt active-skill))
|
||||
(prompt (when prompt-generator (funcall prompt-generator context))))
|
||||
(if prompt
|
||||
@@ -17,17 +17,17 @@
|
||||
(if (and regs (> (length regs) 0)) (elt regs 0) thought))
|
||||
(string-trim '(#\Space #\Newline #\Tab) thought))))
|
||||
(suggestion (ignore-errors (read-from-string cleaned-thought))))
|
||||
(kernel-log "SYSTEM 1 Suggestion: ~a~%" cleaned-thought)
|
||||
(kernel-log "PROBABILISTIC ENGINE Suggestion: ~a~%" cleaned-thought)
|
||||
(cond
|
||||
((and suggestion (listp suggestion)) suggestion)
|
||||
;; SALVAGE: If LLM returned plain text or a non-list symbol
|
||||
((and (let ((p (getf context :payload))) (eq (getf p :sensor) :chat-message))
|
||||
(> (length cleaned-thought) 0))
|
||||
(kernel-log "SYSTEM 1: SALVAGING plain-text response.~%")
|
||||
(kernel-log "PROBABILISTIC ENGINE: SALVAGING plain-text response.~%")
|
||||
(let* ((no-prefix (cl-ppcre:regex-replace "(?i)^(okay,? |sure,? |i will |i've |i have |here is |got it\\.? |understood\\.? |done\\.? |yes,? )+" cleaned-thought "")))
|
||||
`(:target :emacs :payload (:action :insert-at-end :buffer "*org-agent-chat*" :text ,no-prefix))))
|
||||
(t
|
||||
(kernel-log "SYSTEM 1 ERROR: Could not parse response as Lisp plist.~%")
|
||||
(kernel-log "PROBABILISTIC ENGINE ERROR: Could not parse response as Lisp plist.~%")
|
||||
nil)))
|
||||
nil)))
|
||||
nil)))
|
||||
|
||||
@@ -37,7 +37,7 @@ To handle code modifications safely and beautifully:
|
||||
- *Interactive Acceptance*: The user can press a key (e.g., `C-c C-y`) on the diff to accept and apply the patch, realizing the "Active Approval Mode" pattern in Emacs.
|
||||
|
||||
** 4. The Reasoning Stream Integration
|
||||
- Instead of a separate right-side window that clutters the workspace, the reasoning stream (System 1 thoughts, tool calls) will be integrated directly into the main `*org-agent-chat*` buffer.
|
||||
- Instead of a separate right-side window that clutters the workspace, the reasoning stream (Probabilistic Engine thoughts, tool calls) will be integrated directly into the main `*org-agent-chat*` buffer.
|
||||
- It will be presented as a collapsible Org-mode drawer (e.g., `:REASONING:`) or formatted as dimmed, transient text that provides transparency without overwhelming the primary conversation.
|
||||
|
||||
* Phase C: Tester (Verification Strategy)
|
||||
|
||||
@@ -7,13 +7,13 @@ The `cognitive-loop` pipeline (Consolidation V) established the functional gates
|
||||
|
||||
* Scope & Impact
|
||||
- *Target Files:* `projects/org-agent/src/core.lisp`, `projects/org-agent/src/neuro.lisp`, `projects/org-agent/src/symbolic.lisp`.
|
||||
- *Impact:* The System 1 layer will spawn multiple threads to query providers simultaneously. System 2 will enforce GTD state integrity and manage sub-agent delegation.
|
||||
- *Impact:* The Probabilistic Engine layer will spawn multiple threads to query providers simultaneously. Deterministic Engine will enforce GTD state integrity and manage sub-agent delegation.
|
||||
- *Dependencies:* Requires `bordeaux-threads` for sub-agent management and the existing `org-gtd` v4.0 DAG.
|
||||
|
||||
* Proposed Solution
|
||||
1. **Parallel System 1 (`neuro.lisp`):** Modify `ask-neuro` to dispatch asynchronous requests to the `*provider-cascade*` using `bt:make-thread`.
|
||||
2. **Deliberate Consensus (`core.lisp`):** Implement `consensus-gate` to wait for all parallel System 1 proposals. If they match, select the candidate. If they differ, query a fast, deterministic model (e.g., `groq`) to judge and select the safest Lisp `(:REQUEST ...)` form.
|
||||
3. **Task Integrity (`symbolic.lisp`):** Add `task-integrity-check` inside `decide-gate`. If a task transition (e.g., `TODO` -> `DONE`) violates semantic rules (e.g., active children exist), reject the action and return an error stimulus to System 1.
|
||||
1. **Parallel Probabilistic Engine (`neuro.lisp`):** Modify `ask-neuro` to dispatch asynchronous requests to the `*provider-cascade*` using `bt:make-thread`.
|
||||
2. **Deterministic Consensus (`core.lisp`):** Implement `consensus-gate` to wait for all parallel Probabilistic Engine proposals. If they match, select the candidate. If they differ, query a fast, deterministic model (e.g., `groq`) to judge and select the safest Lisp `(:REQUEST ...)` form.
|
||||
3. **Task Integrity (`symbolic.lisp`):** Add `task-integrity-check` inside `decide-gate`. If a task transition (e.g., `TODO` -> `DONE`) violates semantic rules (e.g., active children exist), reject the action and return an error stimulus to Probabilistic Engine.
|
||||
4. **Delegation Hooks:** Define the `delegate-task` action type within the `dispatch-gate`, allowing the core to spawn isolated Lisp environments for long-running sub-agents.
|
||||
|
||||
* Alternatives Considered
|
||||
|
||||
82
system/scripts/repair_inbox_metadata.py
Normal file
82
system/scripts/repair_inbox_metadata.py
Normal file
@@ -0,0 +1,82 @@
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
def get_git_creation_date(file_path, line_number):
|
||||
try:
|
||||
# Use git blame to find the timestamp of the line
|
||||
cmd = ["git", "blame", "-L", f"{line_number},{line_number}", "--porcelain", file_path]
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if result.returncode == 0:
|
||||
for line in result.stdout.split('\n'):
|
||||
if line.startswith('author-time '):
|
||||
timestamp = int(line.split(' ')[1])
|
||||
return datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d")
|
||||
except Exception as e:
|
||||
pass
|
||||
return None
|
||||
|
||||
def repair_file(file_path):
|
||||
print(f"Repairing {file_path}...")
|
||||
with open(file_path, 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
new_lines = []
|
||||
modified = False
|
||||
|
||||
i = 0
|
||||
while i < len(lines):
|
||||
line = lines[i]
|
||||
new_lines.append(line)
|
||||
|
||||
# Look for headline
|
||||
if line.startswith('*'):
|
||||
# Find the PROPERTIES drawer
|
||||
j = i + 1
|
||||
has_properties = False
|
||||
has_created = False
|
||||
properties_line_idx = -1
|
||||
|
||||
# Check up to 10 lines ahead for performance
|
||||
while j < len(lines) and j < i + 10 and not lines[j].startswith('*'):
|
||||
if ":PROPERTIES:" in lines[j]:
|
||||
has_properties = True
|
||||
properties_line_idx = j
|
||||
if ":CREATED:" in lines[j]:
|
||||
has_created = True
|
||||
break
|
||||
if ":END:" in lines[j]:
|
||||
break
|
||||
j += 1
|
||||
|
||||
if has_properties and not has_created:
|
||||
# Use git blame on the headline line
|
||||
creation_date = get_git_creation_date(file_path, i + 1)
|
||||
|
||||
if creation_date:
|
||||
dt = datetime.strptime(creation_date, "%Y-%m-%d")
|
||||
org_date = dt.strftime("[%Y-%m-%d %a]")
|
||||
|
||||
# Advance and append original lines until :PROPERTIES:
|
||||
while i < properties_line_idx:
|
||||
i += 1
|
||||
new_lines.append(lines[i])
|
||||
|
||||
new_lines.append(f":CREATED: {org_date}\n")
|
||||
modified = True
|
||||
i += 1
|
||||
|
||||
if modified:
|
||||
with open(file_path, 'w') as f:
|
||||
f.writelines(new_lines)
|
||||
print(f"DONE: Repaired {file_path}")
|
||||
else:
|
||||
print(f"SKIP: No changes needed for {file_path}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Test on a small portion first if needed, but here we go
|
||||
files = ["inbox-atoms.org", "inbox-emacs.org", "inbox-posts.org"]
|
||||
for f in files:
|
||||
if os.path.exists(f):
|
||||
repair_file(f)
|
||||
Reference in New Issue
Block a user