                        (summaries/or-summary s))))]    
        (summaries/connect! ret ss)
        (connect-and-watch! ss left-sp
-         (fn left-output []
-           (connect-and-watch-ts! ss @right-sp 
-             (fn [] (set-output-set! ret (get-output-set! @right-sp))))
+         (fn left-output [_]
+           (connect-and-watch-ts! ss @right-sp (fn [o] (set-output-set! ret o)))
            (schedule-decrease! ss))
          (fn left-child [left-child]
            (add-sp-child! ret (make-pair-subproblem left-child right-name #(refine-input @right-sp %)) true))) 


;; TODO: tests ! 

;; TODO: SP has hash table from (state-abstracted context) input set to stub (?).


;; TODO first: propagate subsumption links.
;; TODO second: add pessimistic variant. (primitives shared!)

;; TODO: bounding of pessimistic descriptions ? (assume consistency for now).

;; One basic kinds of subsumption propagation:
;;   X --> Y ==> for all child keys k, child(X, k) --> child(Y, k)
;;   This taken into account for atomic, not pairs now.

;; --> TODO: every SP should watch all subsuming SPs for children with matching
;;     names, add these as subsumption parents.
;; (Except any direct parents)

;; TODO: investigate plan seq  normalization. (flattening)
;; TODO: don't release children until they have lower reward or are primitive? \


;; TODO: smarter choose-leaf?
;; TODO: don't always split-left?
;; TODO: smarter output-collector (semantic) -- problems here though.

;;;;; Summaries and solving 
;; TODO: lazy/pseudo-solve (regular seems impossible; bounds mean apparent decrease may be increase.
;;    I.e., live decrease -50 to -49, now blocked sibling becomes best; above is -50 TDB;
;; TODO: smarter summary updates (i.e., pass child)

;;;;; SP caching
;; TODO: tail (i.e., pair) caching? -- Only help for >2 len refs...
;; TODO: cache refine-inputs?
;; TODO: cache children of output-collector? ~15 examples >1 in dm 4-3...

;;;;; Misc
;; TODO: make sure dead stuff can be GC'd


(set! *warn-on-reflection* true)

           (set-output-set! s out-set)
           (if-let [subsuming-sps (seq (filter #(not (terminal? %)) (subsuming-sps s)))]
             (connect-and-watch! s (apply min-key (comp summaries/get-bound sp-ts) subsuming-sps)
               (fn ignore-output [_] nil)
               (fn [sub-out] (add-sp-child! s (refine-input sub-out inp-set) true))) 
             (doseq [ref-name (refinement-names fs inp-set)] #_ (println fs ref-name)
               (add-sp-child! s (get-subproblem ref-name inp-set) false))) 
