 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Plans ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-; TODO: available splits must contribute to live status.
 
 (defrecord PlanNode [sub-output-set-pointer excluded-child-set output-constraint
-                     summary-bound output-set output-summary])
+                     reward-bound output-set output-summary])
 
 (defn compute-plan-node-output-set [input-set sub-output-set-pointer output-constraint]
   (state-set/constrain (state/transfer-effects input-set (osp-output-set sub-output-set-pointer))

          new-summary     (osp-summary sub-output-set-pointer new-ecs)]
      (concat
       (when (viable-summary? new-summary) [(assoc pn :excluded-child-set new-ecs :output-summary new-summary)])
       (for [child split-children] (make-plan-node input-set input-summary child nil {} +best-summary+))))))

(defn patch-pn-summary-tuple- [pn new-input-summary]
  (let [{:keys [sub-output-set-pointer excluded-child-set summary-bound output-set]} pn
        new-output-summary (compute-plan-node-output-summary new-input-summary sub-output-set-pointer excluded-child-set summary-bound)]
    (when (viable-summary? new-output-summary)
      [[false output-set new-output-summary] (assoc pn :output-summary new-output-summary)])))


(defn update-pn-input [[set-changed? new-input-set new-input-summary] pn]
  (let [{:keys [sub-output-set-pointer output-constraint summary-bound output-set]} pn]
    (if set-changed?
      (let [new-osp (refine-osp-input sub-output-set-pointer new-input-set)]
        (if (identical? new-osp sub-output-set-pointer)
          (patch-pn-summary-tuple- pn new-input-summary)
          (let [new-pn (make-plan-node new-input-set new-input-summary new-osp nil
                                (osp-output-set sub-output-set-pointer)
                                (make-blocked-summary (max-reward (full-osp-summary sub-output-set-pointer)))) ;; This is just the bound, equal to the initial thing.                
                new-output-pair (plan-node-output-set-and-summary new-pn)]
            (when (viable-output-set-and-summary? new-output-pair)
              [(cons (not (= (:output-set new-pn) output-set)) new-output-pair) new-pn]))))      

  (live?            [s] (= status :live))
  (optimal-solution [s] (when (= status :solved) (assert opt-sol) opt-sol)))

(defn make-live-summary [max-reward plan] (SimpleSummary. max-reward :live plan))
(defn make-blocked-summary [max-reward plan] (SimpleSummary. max-reward :blocked plan))
(defn make-solved-summary [max-reward opt-sol] (SimpleSummary. max-reward :solved opt-sol))

(defn blocked? [summary]
