               (k/extract-key-value k record))
          (upsert-record session entity t record))))))
 
-(defn stale-lookup-key-values
-  [^Entity entity old-record new-record lookup-key-table]
+(s/defn stale-lookup-key-values
+  [entity :- Entity
+   old-record :- t/MaybeRecordSchema
+   new-record :- t/MaybeRecordSchema
+   lookup-key-table :- t/LookupTableSchema]
   (let [key (:key lookup-key-table)
         col-colls (:collections lookup-key-table)]
 

      (return
       [:ok record :upserted]))))

(defn stale-secondary-key-value
  [^Entity entity old-record new-record secondary-table]
  (let [key (:key secondary-table)
        old-key-value (k/extract-key-value key old-record)
        new-key-value (k/extract-key-value key new-record)]

        (for [kv stale-kvs]
          (delete-record session entity t kv)))))))

(s/defn lookup-record-seq
  "returns a seq of tuples [table lookup-record]"
  [model :- Entity
   old-record :- t/MaybeRecordSchema
   record :- t/MaybeRecordSchema]
  (mapcat
   identity
   (for [t (t/mutable-lookup-tables model)]
