fix(audit): Ensure Chat Skill is Merkle-compliant and secure (Component IV)

This commit is contained in:
2026-04-17 16:30:41 -04:00
parent a04d8415f3
commit 5b6f4c18d1

View File

@@ -54,14 +54,18 @@ Interfaces for conversational event handling and UI integration. Source of truth
(defun chat-archive-message (text &key (role :user) channel chat-id)
"Archives a chat message into the persistent Memory and triggers a snapshot."
(let* ((msg-id (org-id-new))
(attributes `(:role ,role :channel ,channel :chat-id ,chat-id :timestamp ,(get-universal-time)))
(hash (compute-merkle-hash msg-id :CHAT-MESSAGE attributes text nil))
(obj (make-org-object
:id msg-id
:type :CHAT-MESSAGE
:attributes `(:role ,role :channel ,channel :chat-id ,chat-id :timestamp ,(get-universal-time))
:attributes attributes
:content text
:hash hash
:version (get-universal-time))))
(setf (gethash hash *history-store*) obj)
(setf (gethash msg-id *memory*) obj)
(harness-log "CHAT - Message archived: ~a (~a)" msg-id role)
(harness-log "CHAT - Message archived: ~a (~a) [Hash: ~a]" msg-id role (subseq hash 0 8))
(snapshot-memory)
msg-id))