;; next/genesis/validators/envelope-shape.sx
;;
;; Validates required envelope fields per design §3.1. Stage 1 of
;; the validation pipeline (Step 6). Mirrors the kernel's
;; envelope:validate_shape/1 from Step 2a — when the pipeline runs
;; in OCaml-side sandbox eval mode it dispatches by name; when it
;; runs through the kernel Erlang path it short-circuits to the BIF.

(DefineValidator
  :name "envelope-shape"
  :doc "Required-fields check on the activity envelope:\n        :id, :type, :actor, :published, :signature must all be\n        present and non-nil. The :signature sub-field needs\n        :key_id, :algorithm, :value."
  :predicate (fn
    (act)
    (and
      (not (nil? (-> act :id)))
      (not (nil? (-> act :type)))
      (not (nil? (-> act :actor)))
      (not (nil? (-> act :published)))
      (not (nil? (-> act :signature)))
      (not (nil? (-> act :signature :key_id)))
      (not (nil? (-> act :signature :algorithm)))
      (not (nil? (-> act :signature :value))))))
