                                     (terminal?       [s] false)
                                     (refine-input    [s ni] (refine-input inner-sp ni)))
         child-watch (fn child-watch [o]
-                      (if (= (output-set inner-sp) (output-set o))
+                      (if (=-state-sets (output-set inner-sp) (output-set o))
                         (do (connect-and-watch! ret o child-watch)
                             (summaries/summary-changed! ret))
-                        (do (util/assert-is (= (first (stub-name (stub o))) :OS))
-                            (util/assert-is (= (state/current-context (output-set inner-sp))
-                                               (state/current-context (output-set o))) "%s" [stb inner-sp])
+                        (do (util/assert-is (#{:OS :SA} (first (stub-name (stub o)))))
                             (add-sp-child! ret o))))]
     (connect-and-watch! ret inner-sp child-watch)    
     ret))


(declare make-fs-seq-stub get-atomic-stub)

;; TODO: getting multi-levels of wrapping...

(defn- make-atomic-subproblem [stub function-set subsuming-sp out-set reward status]
  (let [inp-set  (input-set stub)

              (simple-stub [:OS (stub-name inner-stub) in-set] in-set)])]
    (connect-and-watch! ret inner-stub #(set-stub-output! ret (make-output-collecting-subproblem ret %)))
    ret))


(defn =-state-sets [s1 s2]
  (util/assert-is (= (state/current-context s1)
                     (state/current-context s2)) "%s" [s1 s2])
  (= s1 s2))

;; TODO: check out set equality issues...
;; TODO: remove extra layers here ?  Don't actually seem to help.
