fix(kernel): Hardened actuator registry and dispatch (case-insensitive, forced keywords)
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 2s

This commit is contained in:
2026-04-19 16:34:31 -04:00
parent 31f963243d
commit 92fd3cda14
2 changed files with 8 additions and 4 deletions

View File

@@ -21,11 +21,14 @@
(defun dispatch-action (action context) (defun dispatch-action (action context)
"Routes an approved action to its registered physical actuator." "Routes an approved action to its registered physical actuator."
(when (and action (listp action)) (when (and action (listp action))
(let* ((target (or (ignore-errors (getf action :target)) *default-actuator*)) (let* ((raw-target (or (ignore-errors (getf action :target))
(ignore-errors (getf action :TARGET))
*default-actuator*))
(target (if (keywordp raw-target) raw-target (intern (string-upcase (string raw-target)) :keyword)))
(actuator-fn (gethash target *actuator-registry*))) (actuator-fn (gethash target *actuator-registry*)))
(if actuator-fn (if actuator-fn
(funcall actuator-fn action context) (funcall actuator-fn action context)
(harness-log "ACT ERROR: No actuator for ~a" target))))) (harness-log "ACT ERROR: No actuator for ~s (from ~s)" target raw-target)))))
(defun execute-system-action (action context) (defun execute-system-action (action context)
"Processes internal harness commands. (ACTUATOR)" "Processes internal harness commands. (ACTUATOR)"

View File

@@ -1,11 +1,12 @@
(in-package :opencortex) (in-package :opencortex)
(defvar *actuator-registry* (make-hash-table :test 'equal) (defvar *actuator-registry* (make-hash-table :test 'equalp)
"Global registry mapping target keywords to their physical actuator functions.") "Global registry mapping target keywords to their physical actuator functions.")
(defun register-actuator (name fn) (defun register-actuator (name fn)
"Registers an actuator function. Actuators receive: (ACTION CONTEXT)." "Registers an actuator function. Actuators receive: (ACTION CONTEXT)."
(setf (gethash name *actuator-registry*) fn)) (let ((key (if (keywordp name) name (intern (string-upcase (string name)) :keyword))))
(setf (gethash key *actuator-registry*) fn)))
(defun frame-message (msg-string) (defun frame-message (msg-string)
"Prefixes MSG-STRING with a 6-character hex length. "Prefixes MSG-STRING with a 6-character hex length.