     
     ret))
 
-
-
 ;; TODO: remove children as they are no longer needed ?
 (defn- make-pair-stub2 [subsuming-sp left-sp right-stub]
   (let [ret (traits/reify-traits


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;      Watches      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defprotocol Watched
  (add-watcher! [s w] "Add a watcher to be notified of all outputs to this.
                       A watcher is just a fn of new-subproblem.")
  (add-output!  [sw o]    "O is a subproblem")
  (get-outputs  [sw]  "List current outputs"))

(def *out-count* (atom 1))

                        (summaries/summary-changed! s)))    
     summaries/Summarizable (summarize [s] (summaries/or-summary s @tdb-atom)))))

(defn init-tree-summarizer! [ts inner-sp subsuming-sp]
  (connect-and-watch! ts inner-sp
    (fn [child-sp]
      (summaries/connect! ts (tree-summarizer child-sp) false)
      (add-top-down-bound! (tree-summarizer child-sp) (top-down-bound ts))
      (summaries/summary-changed! ts))) ;; TODO: speedup by checking child reward? 
  (connect-subsuming! ts subsuming-sp))

(defn get-inner-sp [ts]
  (->> (summaries/node-ordinary-children ts)
