; Follow-up — verb-aware (smart) dedupe. (feed-test name got expected)

; reactions (like/follow) collapse cross-actor; posts stay distinct per actor
(define
  M
  (feed/stream
    (list
      (feed/activity "alice" "like" "X" 1 (list))
      (feed/activity "bob" "like" "X" 2 (list))
      (feed/activity "alice" "post" "P" 3 (list))
      (feed/activity "bob" "post" "P" 4 (list))
      (feed/activity "alice" "follow" "C" 5 (list))
      (feed/activity "bob" "follow" "C" 6 (list))))) ; collapses

(feed-test
  "smart dedupe total"
  (feed/count (feed/dedupe-smart M))
  4)
(feed-test
  "smart keeps both posts"
  (feed/count (feed/by-verb (feed/dedupe-smart M) "post"))
  2)
(feed-test
  "smart collapses likes to one"
  (feed/count (feed/by-verb (feed/dedupe-smart M) "like"))
  1)
(feed-test
  "smart collapses follows to one"
  (feed/count (feed/by-verb (feed/dedupe-smart M) "follow"))
  1)
(feed-test
  "collapsed like keeps first actor"
  (map feed/actor (feed/items (feed/by-verb (feed/dedupe-smart M) "like")))
  (list "alice"))

; contrast: plain activity dedupe keeps cross-actor likes distinct
(feed-test
  "activity dedupe keeps both likes"
  (feed/count (feed/by-verb (feed/dedupe-activities M) "like"))
  2)

; contrast: blanket collapse folds the two posts (same verb+object) too
(feed-test
  "collapse dedupe folds posts"
  (feed/count (feed/by-verb (feed/dedupe-collapse M) "post"))
  1)

; smart-key dispatch
(feed-test
  "smart-key reaction -> (verb object)"
  (feed/smart-key (feed/activity "alice" "like" "X" 0 (list)))
  (list "like" "X"))
(feed-test
  "smart-key post -> (actor verb object)"
  (feed/smart-key (feed/activity "alice" "post" "P" 0 (list)))
  (list "alice" "post" "P"))
