;; next/genesis/projections/by-actor.sx
;;
;; Index of activity CIDs grouped by :actor. Maps actor-id to a
;; list of CIDs in append order. Powers the per-actor outbox
;; listing (Step 8) without re-scanning the full log.

(DefineProjection
  :name "by-actor"
  :doc "Actor-id -> list of activity CIDs (append order)."
  :initial-state {}
  :fold (fn
    (state act)
    (let
      ((a (-> act :actor)) (cid (-> act :cid)))
      (assoc state a (append (or (get state a) (list)) (list cid))))))
