 ; TODO: Cannot use atoms because they prevent time travel.
 ; TODO: Add snapshot ability.
 ; TODO: Readers not blocked by writers.
+; TODO: Mutations shadow old values.
 
 (defn make-kc [] ; A kc is a keys / changes map.
   {:keys (sorted-map)      ; key -> sq

                                                   (assoc :dirty (make-kc))))
                                     {:status :ok :status-info :synced}]))))})

(defn make-kvs-mgr [actx & op-handlers-in]
  (let [cmd-ch (achan actx)
        state-ch (achan actx)]
    (act-loop kvs-mgr-in actx [tot-ops 0]
              (if-let [m (atake kvs-mgr-in cmd-ch)]
                (if-let [op-handler (get (or op-handlers-in op-handlers) (:op m))]


(defn make-scan-fn [scan-kind result-key get-entry]
  (fn [actx state-ch m]
     (let [{:keys [from to res-ch]} m
           res-m (dissoc m :status :status-info :partial)
           work-fn (fn [state kvs]
                     (act scan-work actx
                          (let [kc-clean (:clean kvs)]
