       (throw (Exception. (format "No transition for tuple: %s" tuple)))
       res)))
 
-(defn add-transition-record [state step1 decision-result step2]
-  (let [existing-trace (:status-trace state) tuple [step1 decision-result step2]]
-    (assoc state :status-trace
-           (if (nil? existing-trace) (list tuple)
-               (conj existing-trace tuple))))
-)
-
 ;; Returns [next-step new-state]
-;; TODO: Simplify.
 (defn perform-step [step decision-map state]
   (let [decision (lookup-decision decision-map step)]
     (cond

       (cond
        (bool? decision-result)
        (let [next (lookup-next [step decision-result])]
          [next (add-transition-record state step decision-result next)])

        (vector? decision-result)
        (let [next (lookup-next [step (first decision-result)])]
          [next (add-transition-record (merge state (second decision-result)) step decision-result next)]
          )

        :otherwise (throw (IllegalStateException. (format "Step %s. Function %s must result in a boolean" step decision-result)))))

     (bool? decision)
     (let [next (lookup-next [step decision])] [next (add-transition-record state step decision next)])

     :otherwise (throw (IllegalStateException.)))))



;; Ultimately returns [status state]
(defn get-status-with-state [decision-map state]
  (let [[status new-state]
        (trampoline flow-step :B1 decision-map state)]
    [status new-state]
    ))

(defn get-status [decision-map state]
  (let [[status _] (get-status-with-state decision-map state)]
    status))
