;; next/genesis/projections/audience-graph.sx
;;
;; Per-actor follow / follower graph and audience caches. Folded
;; from Follow / Accept / Reject / Undo{Follow}. Used by the
;; activity router to expand :to / :cc audiences (Public,
;; Followers, Direct) into concrete recipient sets. Per design §16.

(DefineProjection
  :name "audience-graph"
  :doc "Actor-id -> {following, followers, pending} sets.\n        Updated by Follow / Accept / Reject / Undo. Federation\n        (m2) wires this projection to the delivery queue."
  :initial-state {}
  :fold (fn
    (state act)
    (let
      ((t (-> act :type)))
      (cond
        (= t "Follow")
        state
        (= t "Accept")
        state
        (= t "Reject")
        state
        (= t "Undo")
        state
        :else state))))
