Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
mod/decision-diff compares one report's action under two rule sets; mod/policy-impact batches a set and returns only the reports whose decision flips; mod/impact-count / mod/impact-report summarize. Lets a mod team measure a policy change's blast radius before shipping (e.g. removing spam-hide flips r1 hide→keep). Pure SX over decide-report. +13 tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
57 lines
1.5 KiB
Plaintext
57 lines
1.5 KiB
Plaintext
;; lib/mod/whatif.sx — policy what-if / impact analysis.
|
|
;;
|
|
;; Before shipping a policy change, a moderation team needs to know which past or
|
|
;; pending reports would decide differently. mod/decision-diff compares one
|
|
;; report's action under two rule sets; mod/policy-impact runs a whole batch and
|
|
;; returns only the reports whose decision flips. Pure SX over decide-report.
|
|
|
|
(define
|
|
mod/decision-diff
|
|
(fn
|
|
(r reports rules-a rules-b)
|
|
(let
|
|
((a (get (mod/decide-report r reports rules-a) :action))
|
|
(b (get (mod/decide-report r reports rules-b) :action)))
|
|
{:after b :changed (if (= a b) false true) :report-id (mod/report-id r) :before a})))
|
|
|
|
(define
|
|
mod/policy-impact
|
|
(fn
|
|
(reports rules-a rules-b)
|
|
(reduce
|
|
(fn
|
|
(acc r)
|
|
(let
|
|
((d (mod/decision-diff r reports rules-a rules-b)))
|
|
(if (get d :changed) (append acc (list d)) acc)))
|
|
(list)
|
|
reports)))
|
|
|
|
(define
|
|
mod/impact-count
|
|
(fn
|
|
(reports rules-a rules-b)
|
|
(len (mod/policy-impact reports rules-a rules-b))))
|
|
|
|
(define
|
|
mod/impact-report
|
|
(fn
|
|
(reports rules-a rules-b)
|
|
(let
|
|
((changed (mod/policy-impact reports rules-a rules-b)))
|
|
(if
|
|
(empty? changed)
|
|
"No decisions change."
|
|
(mod/join-with
|
|
"\n"
|
|
(map
|
|
(fn
|
|
(d)
|
|
(str
|
|
(get d :report-id)
|
|
": "
|
|
(get d :before)
|
|
" → "
|
|
(get d :after)))
|
|
changed))))))
|