anchor.diff:            ;;FIXME: why null? should be zero?
             ((null vv) (positive-evidence :iid iid :author author :modifiers modifiers))
             (t (warn "Unhandled statements-evidence flag")))))
  -(defun negative-evidence (&key iid author modifiers)
  -  (when-let ((balbox (scss:flag-core nil :con iid author modifiers)))
  -    (dolist (ref (wf/ipfs:opinion-references (warflagger:opinion-by-id iid)))
  -      (warflagger:cast-vote! balbox :wrong iid author ref))))
  -(defun positive-evidence (&key iid author modifiers)
  -  (when-let ((balbox (scss:flag-core nil :pro iid author modifiers)))
  -    (dolist (ref (wf/ipfs:opinion-references (warflagger:opinion-by-id iid)))
  -      (warflagger:cast-vote! balbox :right iid author ref))))
  -(defun custodial-redundant (&key iid author modifiers)
  -  (scss:flag-core :redundant nil iid author modifiers))
  -(defun custodial-out-of-date (&key iid author modifiers)
  -  (scss:flag-core :out-of-date nil iid author modifiers))
  -(defun custodial-retraction (&key iid author modifiers)
  -  (if (equal author scss:*target-author*)
  -      (progn
  -        (scss:flag-core nil nil iid author modifiers)
  -        (setf (gethash :retraction scss:*warstat*) t))
  -      (warn "Retraction applied to target not by author")))
  -(defun custodial-correction (&key iid author modifiers)
  -  (warn "Correction flag not implemented")
  -  (scss:flag-core nil nil iid author modifiers))
  -(defun custodial-incorrect-flag (&key iid author modifiers)
  -  (scss:flag-core :incorrect-flag nil iid author modifiers))
  -(defun custodial-flag-abuse (&key iid author modifiers)
  -  (if (length1 (assoc-cdr :tree-address (warflagger:opinion-by-id iid)))
  -      (warn "Flag-Abuse applied to root URL")
  -      (progn
  -        ;;FIXME: Dirty hack. Need to rethink system to make this less ugly
  -        (scss:flag-core :flag-abuse nil iid author modifiers)
  -        (when (gethash :flag-abuse scss:*warstat*)
  -          (setf scss:*direction* :neutral)
  -          (setf scss:*other-flag* nil)))))
  -(defun custodial-offtopic (&key iid author modifiers)
  -  (scss:flag-core :offtopic nil iid author modifiers))
  -(defun custodial-arcane (&key iid author modifiers)
  -  (scss:flag-core :arcane nil iid author modifiers))
  -(defun custodial-same-thing (&key iid author modifiers)
  -  (warn "Same-thing flag not implemented")
  -  (scss:flag-core nil nil iid author modifiers))
  -(defun custodial-blank (&key iid author modifiers)
  -  (if (wf/ipfs:opinion-can-apply-dircs-to-parent (warflagger:opinion-by-id iid))
  -      ;;Will this work?
  -      (and modifiers (funcall modifiers))
  -      (scss:flag-core nil nil iid author modifiers)))
  -
  -;;FIXME: add a general unknown-flag handler
  -(defun statements-am-qualified (&key iid author modifiers)
  -  (warn "Deprecated flag")
  -  (scss:flag-core nil nil iid author modifiers))
  -(defun negative-already-answered (&key iid author modifiers)
  -  (warn "Deprecated flag")
  -  (scss:flag-core nil nil iid author modifiers))
  -
  -;;FIXME: something should be set in warstats for suggest.
  +
  +(defflag scsc::negative-evidence
  +  (set-direction :con)
  +  (set-tree-freshness (get-opinion-created))
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag)
  +  (when (enabledp)
  +    (dolist (ref (wf/ipfs:opinion-references (get-opinion)))
  +      (vote-right ref))))
  +
  +(defflag scsc::positive-evidence
  +  (set-direction :pro)
  +  (set-tree-freshness (get-opinion-created))
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag)
  +  (when (enabledp)
  +    (dolist (ref (wf/ipfs:opinion-references (get-opinion)))
  +      (vote-wrong ref))))
  +
  +(defflag scsc::custodial-redundant
  +  (set-other-flag :redundant)
  +  (set-tree-freshness (get-opinion-created))
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag))
  +
  +(defflag scsc::custodial-out-of-date
  +  (set-other-flag :out-of-date)
  +  (set-tree-freshness (get-opinion-created))
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag))
  +
  +(defflag scsc::custodial-flag-abuse
  +  (set-other-flag :flag-abuse)
  +  (set-tree-freshness (get-opinion-created))
  +  (run-modifiers)
  +  (save-flag)
  +  (when (parent-is-root-p)
  +      (post-error "Target is not an opinion"))
  +  (post-flag)
  +  (when (approvedp)
  +    (disable-parent)))
  +
  +(defflag scsc::custodial-offtopic
  +  (set-other-flag :offtopic)
  +  (set-tree-freshness (get-opinion-created))
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag))
  +
  +(defflag scsc::custodial-arcane
  +  (set-other-flag :arcane)
  +  (set-tree-freshness (get-opinion-created))
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag))
  +
  +(defflag scsc::custodial-blank
  +  (set-other-flag :blank)
  +  (dont-flag)
  +  (set-tree-freshness (get-opinion-created))
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag))
  +
  +(defflag scsc::statements-am-qualified
  +  (set-tree-freshness (get-opinion-created))
  +  (post-error "Deprecated flag")
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag))
  +
  +(defflag scsc::negative-already-answered
  +  (set-tree-freshness (get-opinion-created))
  +  (post-error "Deprecated flag")
  +  (run-modifiers)
  +  (save-flag)
  +  (post-flag))
  +
   ;;FIXME: only one of these should be used at a time. Add a check. Or prime position?
  -(defun target-text (&key iid author)
  +(defun scsc::target-text (&key iid author)
     (declare (ignore author))
  -  (if (not (length1 scss:*tree-address*))
  -      (warn "Can't target the text of a non-rooturl target")
  -      (progn
  -        (scss:add-side-opinion iid)
  -        (scss:apply-to :text iid))))
  -(defun suggest-target-text (&key iid author)
  +  (set-apply-to :text))
  +(defun scsc::suggest-target-text (&key iid author)
     (declare (ignore author))
  -  (if (not (length1 scss:*tree-address*))
  -      (warn "Can't target the text of a non-rooturl target")
  -      (progn
  -        (scss:add-alternative iid)
  -        (scss:apply-to :text iid))))
  -(defun target-title (&key iid author)
  +  (cond
  +    ((not (parent-is-root-p))
  +     (post-error "Can't suggest text for non-root target"))
  +    ((not (blank-flag-p))
  +     (post-error "Text suggestions must be made with Custodial:Blank flag type"))
  +    (t
  +     (on-post
  +       (when (enabledp)
  +         (add-alternative iid))))))
  +(defun scsc::target-title (&key iid author)
     (declare (ignore author))
  -  (scss:add-side-opinion iid)
  -  (scss:apply-to :title iid))
  -(defun suggest-target-title (&key iid author)
  +  (set-apply-to :title))
  +(defun scsc::suggest-target-title (&key iid author)
     (declare (ignore author))
  -  (scss:add-alternative iid)
  -  (scss:apply-to :title iid))
  -
  -(defun vote-value (value &key iid author)
  +  (if (not (blank-flag-p))
  +      (post-error "Title suggestions must be made with Custodial:Blank flag type")
  +      (on-post
  +        (when (enabledp)
  +          (add-alternative iid)))))
  +
  +(defun scsc::vote-value (value &key iid author)
     (declare (ignore iid author))
     (if (eql value 0)
  -      (setf scss:*direction* :neutral)
  -      (warn "Vote-value: only support setting to 0")))
  -
  -(defun no-cascade (&key iid author)
  +      (set-direction :neutral)
  +      (post-error "#(vote-value): can only set to 0")))
  +
  +(defun scsc::no-cascade (&key iid author)
     (declare (ignore iid author))
  -  ;;FIXME: this might not work...
  -  (setf scss:*direction* :neutral))
  +  (set-direction :neutral))
  +
  +
  
positive.code:    #:prep-scsc-for-execution
     #:*warstats*
     #:*text-warstats*
     #:*title-warstats*
     #:*tree-address*
     #:*text-ballot-box*
     #:*title-ballot-box*
     #:*warstat*
     #:*text-warstat*
     #:*title-warstat*
     #:*apply-to*
     #:*cascade*
     #:*other-flag*
     #:*direction*
     #:*target-author*
     #:stick-other-flag-on-target
     #:add-to-replies-count
     #:set-direction
     #:set-tree-freshness
     #:apply-to
     #:applied-to
     #:collect-warstats
     #:flag-core
     #:*ballot-box*
     #:*side-opinions*
     #:add-alternative
     #:add-side-opinion))
  
  (defpackage #:score-script
    (:use #:cl #:gadgets #:alexandria)
  
negative.code:       (scss:collect-warstats rooturl scss:*title-warstat* :title))
      (values scss:*warstats* scss:*text-warstats* scss:*title-warstats* scss:*side-opinions*)))
  
  (defun execute-score-script (scsc rooturl opinion-store)
    (declare (type score-script scsc))
    (let* ((warflagger:*opinion-store* opinion-store)
           (*score-data* (make-hash-table))
           ;; tree-address?
           (*dispatch* (scsc-dispatch rooturl nil nil)))
      (mapc #'eval (prep-scsc-for-execution (scsc-safety-symbols scsc)))
      *score-data*))
  
  (defun scsc-dispatch (key parent-dispatch info)
    "key is iid or rooturl"
    (let ((ballot-box (warflagger:make-ballot-box))
          (text-ballot-box (warflagger:make-ballot-box))
          (title-ballot-box (warflagger:make-ballot-box))
          (tree-freshness nil)
          (apply-to nil)
          (replies-immediate 0)
          (replies-total 0)
          (other-flag nil)
          (post-other-flag t)
          (other-flags (make-hash-table))
          (direction nil)
          (alternatives nil)
          (delayed-procedures nil)
          (enabled t))
      (labels ((which-bb (applied-to)
                 (case applied-to
                   (:text text-ballot-box)
                   (:title title-ballot-box)
                   (otherwise ballot-box))))
        (lambda (cmd param &rest params)
          (case cmd
            (:direction
             (setf direction (or param :neutral)))
            (:info
             (case param
               (:parent parent-dispatch)
               (:enabled enabled)
               (:direction direction)
               (:ballot-box ballot-box)
               (:other-flag other-flag)
               (otherwise (getf info param))))
            (:apply-to
             (setf apply-to param))
            (:tree-freshness
             (if tree-freshness
                 (when (string< (warflagger:js-compatible-utcstamp tree-freshness)
                                (warflagger:js-compatible-utcstamp param))
                   (setf tree-freshness param))
                 (setf tree-freshness param)))
            (:replies
             (incf replies-immediate)
             (incf replies-total (1+ param)))
            (:merge-ballots
             (warflagger:merge-ballot-boxes! (which-bb (getf params :applied-to)) param))
            (:merge-ballots-inverted
             (warflagger:merge-with-inverted-ballot-boxes! (which-bb (getf params :applied-to)) param))
            (:merge-other-flag-ballots
             (if-let ((bb (gethash param other-flags)))
               (warflagger:merge-ballot-boxes! bb (getf params :ballot-box))
               (setf (gethash param other-flags)
                     (warflagger:copy-ballot-box (getf params :ballot-box)))))
            (:cast-own-vote
             (warflagger:cast-vote! (which-bb (getf params :applied-to)) param
                                    (getf params :iid) (getf params :author) (getf params :reference)))
            (:cast-own-other-vote
             (let ((bb (gethash param other-flags)))
               (warflagger:cast-vote! bb :up (getf params :iid) (getf params :author))))
            (:cast-vote
             (funcall parent-dispatch :cast-own-vote param :iid (getf info :iid)
                      :author (getf info :author) :reference (getf params :reference)
                      :applied-to apply-to))
            (:other-flag
             (setf other-flag param))
            (:post-other-flag
             (setf post-other-flag param))
            (:add-alternative
             (push param alternatives))
            (:add-delayed-procedure
             (push param delayed-procedures))
            (:disable
             (setf enabled nil))
            (:save
             (let ((data (hu:hash
                          (:ballot-box ballot-box) (:text-ballot-box text-ballot-box)
                          (:title-ballot-box title-ballot-box) (:tree-freshness tree-freshness)
                          (:direction direction) (:replies-total replies-total)
                          (:replies-immediate replies-immediate) (:other-flags other-flags)
                          (:alternatives alternatives))))
               (setf (gethash key score-script-support::*score-data*) data)))
            (:post
             (mapcan #'funcall delayed-procedures)
             (funcall parent-dispatch :replies replies-total)
             (funcall parent-dispatch :tree-freshness tree-freshness)
             (cond
               ((null enabled) nil)
               ((and other-flag (not post-other-flag)) nil)
               (other-flag
                (funcall parent-dispatch :merge-other-flag-ballots other-flag :ballob-box ballot-box)
                ;; Auto-vote for other flag
                (funcall parent-dispatch :cast-own-other-vote
                         other-flag :up :iid (getf info :iid) :author (getf info :author)))
               ((eq direction :pro)
                (funcall parent-dispatch :merge-ballots ballot-box :applied-to apply-to))
               ((eq direction :con)
                (funcall parent-dispatch :merge-ballots-inverted ballot-box :applied-to apply-to)))))))))
  
  (defun scsc-safety-symbols (code &optional (package (find-package :score-script)))
    (proto:tree-search-replace
  