 ;;               already been executed as their dependencies have been met
 (defonce dep-state* (agent {:satisfied #{}
                             :todo      []
-                            :done      []}))
+                            :done      []
+                            :history   []}))
+
+(defn- now
+  []
+  (System/currentTimeMillis))
 
 (defn- process-handler
   "Returns a new deps map containing either processed handler or it

  (let [replacer-fn #(if (= key (first %))
                       [key deps task]
                       %)]
    {:satisfied (dep-state :satisfied)
     :todo      (map replacer-fn (dep-state :todo))
     :done      (map replacer-fn (dep-state :done))}))

(defn- key-known?
  "Returns true or false depending on whether this key is associated

                                  (log/error (format "Exception in dependency handler: %s\n%s"
                                                     key
                                                     (with-out-str (.printStackTrace e))))))
                              [(conj final-done [key deps task]) final-todo (conj new-history {:ts (now)
                                                                                               :action :satisfied-and-processed
                                                                                               :key key
                                                                                               :deps deps})])
                            [final-done (conj final-todo [key deps task]) new-history]))
        [t-done t-todo new-history] (reduce execute-tasks [done [] []] todo)]
    (log/info "deps-satisfied: " satisfied)
    {:satisfied satisfied
     :done      t-done
     :todo      t-todo
     :history (concat (:history dep-state)
                      new-history)}))

(defn- deps->set
  "Converts deps to a deps-set. Deals with single elements or
