From 22726047a1083fbd5a9fc8987161e03035df31b0 Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Sun, 19 Apr 2026 15:23:08 -0400 Subject: [PATCH] fix(kernel): Allow approved logs and events to pass act-gate without being flagged as blocked --- literate/act.org | 7 +++++-- literate/reason.org | 17 +++++++++-------- src/act.lisp | 7 +++++-- src/reason.lisp | 17 +++++++++-------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/literate/act.org b/literate/act.org index fa13612..8e82c6c 100644 --- a/literate/act.org +++ b/literate/act.org @@ -103,8 +103,11 @@ The final stage of the metabolic loop. It performs a "last-mile" safety check be ;; 1. Last-Mile Safety Check (The Bouncer & Deterministic Gates) (when approved - (let ((verified (deterministic-verify approved signal))) - (if (and (listp verified) (member (getf verified :type) '(:LOG :EVENT :log :event))) + (let* ((original-type (getf approved :type)) + (verified (deterministic-verify approved signal))) + (if (and (listp verified) + (member (getf verified :type) '(:LOG :EVENT :log :event)) + (not (member original-type '(:LOG :EVENT :log :event)))) (progn (harness-log "ACT BLOCKED: Action failed last-mile deterministic check.") (setf (getf signal :approved-action) nil) diff --git a/literate/reason.org b/literate/reason.org index 7b7e815..cf31d16 100644 --- a/literate/reason.org +++ b/literate/reason.org @@ -97,14 +97,15 @@ Once a proposal is generated, it MUST pass through the deterministic gates. Ever (gate (skill-deterministic-fn skill))) (when (or (null trigger) (ignore-errors (funcall trigger context))) (let ((next-action (funcall gate current-action context))) - ;; Interception occurs if the gate returns a signal (LOG/EVENT) AND either: - ;; 1. The original action was NOT a signal (e.g. it was a REQUEST). - ;; 2. The gate returned a DIFFERENT signal than it was given. - (when (and (listp next-action) - (member (getf next-action :type) '(:LOG :EVENT :log :event)) - (not (eq next-action current-action))) - (harness-log "DETERMINISTIC: Intercepted by skill '~a'" (skill-name skill)) - (return-from deterministic-verify next-action)) + ;; Interception occurs if the gate returns a signal (LOG/EVENT) AND the original was a REQUEST. + ;; If the original was already a LOG/EVENT, we only intercept if the gate returns a NEW signal object. + (let ((original-type (getf current-action :type))) + (when (and (listp next-action) + (member (getf next-action :type) '(:LOG :EVENT :log :event)) + (or (not (member original-type '(:LOG :EVENT :log :event))) + (not (eq next-action current-action)))) + (harness-log "DETERMINISTIC: Intercepted by skill '~a'" (skill-name skill)) + (return-from deterministic-verify next-action))) (setf current-action next-action))))) current-action)) #+end_src diff --git a/src/act.lisp b/src/act.lisp index 65f24d1..d5bd53f 100644 --- a/src/act.lisp +++ b/src/act.lisp @@ -70,8 +70,11 @@ ;; 1. Last-Mile Safety Check (The Bouncer & Deterministic Gates) (when approved - (let ((verified (deterministic-verify approved signal))) - (if (and (listp verified) (member (getf verified :type) '(:LOG :EVENT :log :event))) + (let* ((original-type (getf approved :type)) + (verified (deterministic-verify approved signal))) + (if (and (listp verified) + (member (getf verified :type) '(:LOG :EVENT :log :event)) + (not (member original-type '(:LOG :EVENT :log :event)))) (progn (harness-log "ACT BLOCKED: Action failed last-mile deterministic check.") (setf (getf signal :approved-action) nil) diff --git a/src/reason.lisp b/src/reason.lisp index 5986727..78bdaf7 100644 --- a/src/reason.lisp +++ b/src/reason.lisp @@ -67,14 +67,15 @@ (gate (skill-deterministic-fn skill))) (when (or (null trigger) (ignore-errors (funcall trigger context))) (let ((next-action (funcall gate current-action context))) - ;; Interception occurs if the gate returns a signal (LOG/EVENT) AND either: - ;; 1. The original action was NOT a signal (e.g. it was a REQUEST). - ;; 2. The gate returned a DIFFERENT signal than it was given. - (when (and (listp next-action) - (member (getf next-action :type) '(:LOG :EVENT :log :event)) - (not (eq next-action current-action))) - (harness-log "DETERMINISTIC: Intercepted by skill '~a'" (skill-name skill)) - (return-from deterministic-verify next-action)) + ;; Interception occurs if the gate returns a signal (LOG/EVENT) AND the original was a REQUEST. + ;; If the original was already a LOG/EVENT, we only intercept if the gate returns a NEW signal object. + (let ((original-type (getf current-action :type))) + (when (and (listp next-action) + (member (getf next-action :type) '(:LOG :EVENT :log :event)) + (or (not (member original-type '(:LOG :EVENT :log :event))) + (not (eq next-action current-action)))) + (harness-log "DETERMINISTIC: Intercepted by skill '~a'" (skill-name skill)) + (return-from deterministic-verify next-action))) (setf current-action next-action))))) current-action))