Adds *scope-resolver* hook in core-loop-perceive that the context-manager
skill sets at load time. The perceive gate now passes the active scope
to ingest-ast, tagging all ingested objects with the current context scope.
Implementation:
- core-loop-perceive: *scope-resolver* defvar (default nil → :memex),
two ingest-ast calls now pass (if *scope-resolver* (funcall it) :memex)
- core-defpackage: export *scope-resolver* and context-query
- system-context-manager: auto-init sets *scope-resolver* to #'current-scope
This completes the Memory Scope Segmentation feature: all three scopes
(:memex, :session, :project) are supported, scope-aware retrieval
(context-query :scope / context-scoped-query) was already implemented,
and ingested objects now correctly carry the active scope.
Adds prose sections before every code block to satisfy the
prose-before-code discipline. Each backward-compatibility alias
(process-signal, perceive-gate, reason-gate, act-gate, inject-stimulus)
now has its own subsection explaining why it exists and what new code
should use instead.
Also:
- Fixes double #+end_src in core-loop-perceive.org
- Renames inject-stimulus → stimulus-inject in heartbeat-start and
client-handle-connection (both already had aliases)
- Adds HITL interception prose to gateway-manager.org telegram/signal
sections
- Splits Pre-Reason Handler Registry into two code blocks (defvar + defun)
for one-per-block compliance
REPL tool:
- ~/.opencode/bin/repl — connects to running daemon, evaluates Lisp forms,
returns results. Usage: repl '(+ 1 2)' or via stdin.
- Server-side handler in programming-repl skill registers for :repl-eval
sensor, bypasses LLM pipeline, writes result back through reply-stream.
- Core provides pre-reason-handler registry (register-pre-reason-handler)
for skills to register custom sensors without modifying core code.
HITL gateway integration:
- hitl-handle-message: TUI, Telegram, and Signal gateways intercept
approval/deny commands before they reach the LLM.
- hitl-create/hitl-approve/hitl-deny: in-memory HITL store with correlation
tokens for gateway-agnostic approval.
- loop-gate-perceive detects HITL commands and blocks LLM processing.
Naming drift fixes (the complete batch):
- register-actuator vs actuator-register — fixed to register-actuator
- process-signal vs loop-process — alias added
- perceive-gate/reason-gate/act-gate vs loop-gate-* — aliases added
- initialize-actuators vs actuator-initialize — fixed to actuator-initialize
- initialize-all-skills vs skill-initialize-all — fixed to skill-initialize-all
- inject-stimulus alias added for backward compatibility
- All original gateway-manager inject-stimulus → stimulus-inject + HITL check
(setf (getf signal :approved t)) → (setf (getf signal :approved) t)
Caught during system compilation. This is exactly the class of bug that
the REPL-first discipline would have caught instantly.
- dispatcher-check: add :level :approval-required to network/high-impact returns
- cognitive-verify: distinguish approval-required from hard rejection; pass
approval requests through to act gate instead of returning early
- loop-gate-reason: don't retry approval requests; pass them as approved-action
with :status :requires-approval
- loop-gate-act: detect approval-required, create Flight Plan, dispatch HITL
message to user's client, don't execute original action
- loop-gate-perceive: handle re-injected approved signals from
dispatcher-approvals-process; set :approved-action on signal
- dispatcher-approvals-process: fix function name (stimulus-inject) and wrap
action in proper signal envelope with :sensor :approval-required
- Fix: list-objects-with-attribute → memory-objects-by-attribute
- Fix: org-id-new → org-id-generate
- Fix: inject-stimulus → stimulus-inject (correct function name)
Flow:
1. LLM proposes high-risk action → dispatcher returns approval-required
2. cognitive-verify collects approval request → passes to reason as :requires-approval
3. loop-gate-act creates Flight Plan → dispatches HITL message to client → exits
4. Human approves in Emacs → heartbeat re-injects with :approved t
5. Re-injected signal flows through pipeline → dispatcher passes through
6. Action executed normally
- New system-event-orchestrator skill with hook registry, cron registry, and tier classifier
- Three dispatch tiers: :reflex (no LLM), :cognition (light), :reasoning (full)
- Org-mode timestamp parsing for repeat patterns (+1w, +1d, +1m)
- Registers on heartbeat via defskill, dispatches due cron jobs
- Fix all remaining harness-log → log-message references across org files