               [onyx.types :refer [->Route ->Ack ->Results ->Result ->MonitorEvent dec-count! inc-count! map->Event]]
               [clj-tuple :as t]
               [onyx.interop]
-              [onyx.state.log.atom]
               [onyx.state.log.bookkeeper]
               [onyx.state.filter.set]
               [onyx.state.core :as state]

               replayed-state))))
  event)

(defn assign-windows
  [{:keys [onyx.core/monitoring onyx.core/replica onyx.core/state onyx.core/messenger
           onyx.core/windows onyx.core/task-map onyx.core/window-state onyx.core/state-log onyx.core/results] :as event}]
  (when (seq windows)
    (let [id-key (:onyx/uniqueness-key task-map)] 
      (doall
        (map 
          (fn [leaf fused-ack]

                    (when-not seen?
                      (inc-count! fused-ack)
                      (->> windows
                           (map (partial assign-window segment window-state))
                           doall
                           (cons unique-id) ;; store the id at the head of the log entry
                           (state-extensions/store-log-entry state-log event ack-fn))
                      (doseq [t triggers]
                        (triggers/fire-trigger! event window-state t {:segment segment :context :new-segment}))
                      (swap! window-state update :filter state-extensions/apply-filter-id event unique-id))))
                (:leaves leaf))))
          (:tree results)
