   (let [ret (traits/reify-traits [simple-watched cache-trait summaries/simple-node]  
               summaries/Summarizable
               (summarize [s] 
-                 (summary/max ;; Mxa here prevents infinite loop from s in s
+                 (summary/max ;; Max here prevents infinite loop from s in s
                   (summary/+ (summaries/summary left-sp) (summaries/summary right-stub) s)
                   (summary/or-combine                   
                    (map summaries/summary (summaries/node-ordinary-children s))

       (apply make-simple-atomic-subproblem nil)
       subproblem/pseudo-solve)))




(comment
  

(defprotocol FancyNode
  (remove-child! [s child])
  (remove-parent! [s parent]))

(defn disconnect! [parent child]
  (remove-child! parent child)
  (remove-parent! child parent))


(traits/deftrait fancy-node [] [children (atom nil) parents  (atom nil)] []
  summaries/Node
  (node-ordinary-children [n] (map second (remove first @children)))
  (node-subsuming-children [n] (map second (filter first @children)))
  (node-ordinary-parents [n] (map second (remove first @parents)))
  (node-subsumed-parents [n] (map second (filter first @parents)))    
  (add-child!    [n child subsuming?] (swap! children conj [subsuming? child]))
  (add-parent!   [n parent subsuming?] (swap! parents conj [subsuming? parent]))

  FancyNode
  (remove-child! [s child]
    (let [new-children (remove #(identical? (second %) child) @children)]
      (assert (= (count new-children) (dec (count @children))))
      (reset! children new-children)))
  (remove-parent! [s parent]
    (let [new-parents (remove #(identical? (second %) parent) @parents)]
      (assert (= (count new-parents) (dec (count @parents))))
      (reset! parents new-parents))))
)


(comment
  (defn- make-atomic-subproblem [stub subsuming-sp inp-set function-set out-set reward status]
  (let [children (when (= status :live)
                   (or #_ (refined-children subsuming-as inp-set) ;; TODO!!
                       (map #(make-fs-seq-stub inp-set %)
                            (fs/child-seqs function-set inp-set))))]
    (make-simple-subproblem
     [::Atomic (fs/fs-name function-set) inp-set]
     inp-set out-set
     (if (= status :live)
       (fn [s]
         (assert (empty? (summaries/node-subsuming-children s)))
         (assert (= (count children) (count (summaries/node-ordinary-children s))))
         (summary/or-combine (map summaries/summary children) s reward))
       (fn [s] (summary/make-simple-summary reward status s)))     
     children children identity
     (fn [s ref-inp-set] (make-atomic-stub s ref-inp-set function-set))))))
    ret))

;; TODO: figure out if transient increases can be solved (is there better semantics for inner)?
;; Stub to wait for left to be evaluated
;; Left-stub will always be atomic stub, which always has a single output.
;; TODO: this seems to not always be true -- someitmes get multiple outputs for left-stub !
