     (do (summaries/connect! p c false)
         (add-watcher! c f))))
 
+(defn make-wrapping-stub [[name in-set] inner-stub sp-fn]
+  (let [ret (traits/reify-traits [summaries/or-summarizable (simple-stub name in-set)])]
+    (connect-and-watch-stub! ret inner-stub #(set-stub-output! ret (sp-fn ret %)))
+    ret))
+
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                     (when (and (not @left-done?)
                                (not (summary/live? (summaries/summary left-sp)))
                                (not (= Double/NEGATIVE_INFINITY (summary/max-reward (summaries/summary left-sp))))) ;; TODO:??
                       (reset! left-done? true) #_(println "BOO" pair-stub left-sp right-sp (class right-sp))
                       (summaries/disconnect! s ss)
                       (add-watcher! left-sp (fn [o] (def *sum* [s left-sp o])
                                               (throw (RuntimeException. "Solved and children."))))
                       ;; TODO: do more efficiently?
                       (connect-and-watch-stub! s (make-pair-stub2 subsuming-sp left-sp (stub right-sp))
                                           (fn [os] (connect-and-watch! s os #(add-sp-child! s %))))
 ;                       (add-sp-child! s (make-pair-subproblem subsuming-sp pair-stub left-sp right-sp))
                       )
                     (summaries/or-summary s b))))             
             (fn [s ri] (make-pair-stub1 s (refine-input left-sp ri)
                          (subproblem-name right-sp) #(refine-input right-sp %)))

;; TODO: tail caching?
;; TODO: cache refine-inputs and/or other SPs.
;; TODO: encapsulate stub/sp behaviors somehow.
;; TODO: garbage collect dead stuff

;; TODO: remove extra stub indirection step when not needed?
;; (i.e., either reverse directions, or just have get-stub-output when known..)
