                         insert-response))
 
                live-ref? (if-not owned?
-                           (re/select-one session
+                           (r/select-one session
                                           (get-in model [:primary-table :name])
                                           (get-in model [:primary-table :key])
                                           (t/extract-uber-key-value

               deleted? (m/return (applied? delete-result))]
              (m/return
               (cond
                 deleted? [:ok :deleted]
                 :else    [:ok :stale]))))))

(defn acquire-singular-unique-key
  "attempt to acquire a singular unique key, returning a
   Deferred[Right[[:ok key info]]] or a Deferred[Right[[:fail key reason]]]"
  [session ^Model model unique-key-table owner-record]
  (let [uber-key-value (t/extract-uber-key-value model owner-record)
        key-value (k/extract-key-value (:key unique-key-table) owner-record)]
    (acquire-unique-key session model unique-key-table uber-key-value key-value)))

(defn acquire-unique-key-collection
  "attempt to acquire a set of unique keys. returns a
   Deferred[Right[[ [:ok key info] | [:fail key reason] ]]]"
  [session ^Model model unique-key-table owner-record]
  (let [uber-key-value (t/extract-uber-key-value model owner-record)
        key-value-coll (k/extract-key-value-collection
                        (:key unique-key-table)
                        owner-record)
        responses (mapv (partial acquire-unique-key
                                 session
                                 model
                                 unique-key-table
                                 uber-key-value)
                        key-value-coll)]
    (combine-responses responses)))


(defn acquire-unique-keys
  "attempts to acquire unique keys for an owner... returns
   a Deferred[Right[[:ok updated-owner-record :failed-keys]]] with an updated
   owner record containing only the keys that could be acquired"
  [session ^Model model owner-record]
  (m/with-monad dm/either-deferred-monad
    (m/mlet [r owner-record]
            (m/return r))))

                 :else     [:fail key-desc :notunique] ;; someone else won
                 ))))))

(defn release-unique-key
  "remove a single unique key"
  [session ^Model model unique-key-table uber-key-value key-value]
  (let [uber-key (t/uber-key model)
        key (:key unique-key-table)
        key-desc {:uber-key uber-key :uber-key-value uber-key-value
                  :key key :key-value key-value}]
    (m/with-monad dm/either-deferred-monad
      (m/mlet [delete-result (r/delete session
                                        (:name unique-key-table)
                                        key
                                        key-value
