 
 (comment (util/singleton? (get effect-cluster-map v)))
 
-;; TODO: where do happy belong?
 ;; TODO: better choice of unhappy child?
+;; (NOTE -- if we're choosing on behalf of auxiliary, and all actions are happy with p's value,
+;;   we MUST treat all actions as concerned -- ignoring greedy.  Just do that by default for now)
+;;   TODO: investigate sometimes re-grouping happy with indifferent.
 (defn bottom-up-expand-actions [s p unhappy-children child-map prevail-map auxiliary-map possible-actions-fn]
   (let [children                (possible-children s p child-map prevail-map auxiliary-map)
         c                       (first (util/intersection (set children) (set unhappy-children)))
         _ (util/assert-is (identity c) "%s" [s p unhappy-children children (do (clojure.inspector/inspect-tree (sort-by key s)) nil)])
         actions (state/get-var s (possible-actions-var c))
         [concerned indifferent] (util/separate #(contains? (:precond-map %) p) actions)
-        [happy unhappy]         (util/separate #(can-greedily-use? s % p c) concerned)
-        lazy-set                (set (concat happy indifferent))]
+;        [happy unhappy]         (util/separate #(can-greedily-use? s % p c) concerned)
+;        lazy-set                (set (concat happy indifferent))
+        unhappy concerned
+        lazy-set (set indifferent) ;; TODO
+        ]
     (assert (= :wait (state/get-var s (possible-actions-var p))))
     (when-let [cur-c (state/get-var s (child-var p))] (assert (= cur-c c)))
-    (assert (seq unhappy))
+;    (assert (seq unhappy)) -- can't assert with aux
     (concat
      (when (seq lazy-set)
        [(make-set-actions-action c lazy-set)])

  [(asplan-solution-name sol) rew])





;; (do (use 'angelic.env 'angelic.hierarchy 'angelic.search.textbook 'angelic.domains.taxi-infinite 'angelic.domains.sas-problems 'angelic.sas 'angelic.sas.analysis 'angelic.util 'angelic.sas.hm-heuristic 'angelic.search.interactive) (require '[angelic.search.action-set.gasplan2 :as gap2] '[angelic.search.action-set.asplan-r :as rap]))

                  (seq (get sources-by-type :greedy))
                  (greedy-fire-actions s (first sources) possible-actions-fn)

                  (seq (canonicalize s (get sources-by-type :bottom-up)))
                  (let [[p-var children] (apply max-key (comp tsi first) sources)] 
                    (bottom-up-expand-actions s p-var children child-var-map prevail-cvm auxiliary-map possible-actions-fn)) 
               
                  :else (do (util/assert-is (empty? (:other sources-by-type))
                                            "%s" [(do (print-state s) (inspect-state s)
                                                      s)])
                            (util/print-debug 1 "Pruning since nothing to do?!"))))
               
               (util/print-debug 1 "Pruning due to deadlock")))))
