                (merge m (or (atake state-work done-ch)
                             {:status :error :status-info :closed-ch})))))
 
+(defn make-scan-fn [scan-kind result-key get-entry]
+  (fn [actx state-ch m]
+     (let [from (:from m)
+           to (:to m)
+           res-m (dissoc m :status :status-info :partial)
+           res-ch (:res-ch m)
+           work-fn (fn [state kvs]
+                     (act scan-work actx
+                          (let [kc-clean (:clean kvs)]
+                            (doseq [[k v]
+                                    (subseq (into (sorted-map) (scan-kind kc-clean))
+                                            >= from < to)]
+                              (when-let [entry (get-entry kc-clean k v)]
+                                (when (not (:deleted entry))
+                                  (aput scan-work res-ch
+                                        (merge res-m {:partial :ok
+                                                      result-key key
+                                                      :entry entry})))))
+                            (aput scan-work res-ch
+                                  (merge res-m {:status :ok}))))
+                     nil)]
+       (act scan-start actx
+         (aput scan-start state-ch
+               [(kvs-ident-check (:kvs-ident m) work-fn) nil])))))
+
 (def op-handlers
   {:kvs-open
    (fn [actx state-ch m]

    ; Using kvs-mgr-state to avoid atoms, which prevent time-travel.
    (act-loop kvs-mgr-state actx [state { :next-uuid 0 :kvss {} }]
              (if-let [[state-fn done-ch] (atake kvs-mgr-state state-ch)]
                (if-let [[next-state done-res] (state-fn state)]
                  (do (when (and done-ch done-res)
                        (aput-close kvs-mgr-state done-ch done-res))
                      (recur next-state))
                  (println :kvs-mgr-state-fn-exit))
                (println :kvs-mgr-state-ch-exit)))
    cmd-ch))

               [(kvs-ident-check (:kvs-ident m) work-fn) nil]))))

   :scan-keys
   (make-scan-fn :keys :key kc-entry-by-key-sq)

   :scan-changes
   (make-scan-fn :changes :sq (fn [kc sq-key entry] entry))

   :sync
   (fn [actx state-ch m]
