         action
       (SDH-Action-HLA hierarchy [:!A (env/action-name action)] action
                       ((:ancestor-var-set hierarchy) effect-var)
-                      (for [[pvar pval] reduced-em]
-                        (make-leaf-precond-hla hierarchy pvar pval))))))
+                      (vec (for [[pvar pval] reduced-em] (make-inactive-leaf-precond-hla hierarchy pvar pval))) nil))))
 
 ;; TODO: 
 

;; TODO: fire more than one greedy action at once ...
; ;TODO: how do we keep track of preconditions moved up front ?

; Am I greedy, or do I have a 
(declare make-action-hla)

(deftype SDH-Action-HLA [hierarchy name action precond-var-set precond-hlas] :as this
  SDH-HLA
    (active-var-set []  (apply clojure.set/union (map active-var-set precond-hlas)))
    (leaf-var-set   []  (apply clojure.set/union (map leaf-var-set precond-hlas)))
    (greedy?        [s v av] 
      (or (every? #(and (satisfied? % s) (or (active? %) (not (av (:var %))))) precond-hlas)
          (some #(greedy? % s v av) (util/make-safe (seq (filter #(contains? (leaf-var-set %) v) precond-hlas))))
          ))
    (do-refinement  [s v av lv]
      (if (every? #(and (satisfied? % s) (or (active? %) (not (av (:var %))))) precond-hlas) 
          (do (println "GREED2") [[[action] nil]])
        (let [possible-vals  (filter #(contains? (leaf-var-set %) v) precond-hlas)
              [deep shallow] (util/separate active? possible-vals)
              val-options    (or (and (:greedy-optimization? hierarchy) 
                                      (when-first [x (filter #(greedy? % s v av) deep)] [x])) 
                                 (seq deep) 
                                 (seq shallow))]
;          (println "refining at " v "with options" val-options)
            (assert (seq val-options))
            (assert (<= (count shallow) 1))
        
            (for [precond-hla val-options
                  [prefix remaining] (do-refinement precond-hla s v av lv)]
              [prefix 
               (let [new-precond-hlas
                      (for [hla precond-hlas]
                        (if (identical? hla precond-hla) remaining hla))]
                 (SDH-Action-HLA. hierarchy
                   [:!A* (env/action-name action) (map env/action-name new-precond-hlas)]
                   action precond-var-set new-precond-hlas))]))))
  env/Action
    (action-name     [] name)
    (primitive?      [] false)

(defprotocol SDH-HLA
  (active-var-set  [a])
  (leaf-var-set    [a])
  (needs-expand?   [a])
  (expand          [a lv])           ; returns [[action-seq new-hla]]
  (greedy-select?  [a s v av])    ; Has a descendent that can be done greedily.
  (select-leaf     [a s v av]) ; returns new-hlas. av is active-var set, lv is leaf-var set
  ) 


