         [meta features] (json-reader/features-from-stream stream)]
     [meta features]))
 
+(defn- inserted-features [extracts dataset collection extract-type features]
+  (doseq [f features]
+    (let [max-row-id (if (empty? @extracts)
+                       0
+                       (reduce max (map first @extracts)))]
+          (swap! extracts assoc (inc max-row-id) f))))
+
+
+(defn- filter-collection [item-to-filter collection] 
+  (some #(= % item-to-filter) collection))
+
+(defn- deleted-versions [extracts dataset collection extract-type versions-to-delete]
+  (let [rows-to-delete (map first (filter #(filter-collection (:_version (second %)) versions-to-delete) @extracts))]
+    (doseq [row-id rows-to-delete]
+      (swap! extracts dissoc row-id))))
+
+;(defn- deleted-versions [extracts dataset collection extract-type versions-to-delete]
+;  (println "do nothing"))
+
+
 (defn process-feature-permutation [meta feature-permutation]
   (println "  " (map #(into [] (map :action %1)) feature-permutation))
-  (apply merge-with (fn [a b] (if (seq? a) (conj a b) (+ a b)))
-         (map (fn [features]
+  (let [extracts (atom {})]
+    (with-bindings
+      {#'e/*process-insert-extract* (partial inserted-features extracts)
+       #'e/*process-delete-extract* (partial deleted-versions extracts)
+       #'e/*initialized-collection?* (constantly true)}
+      {:stats (apply merge-with (fn [a b] (if (seq? a) (conj a b) (+ a b)))
+            (map (fn [features]
                 (let [persistence (config/persistence)
                       projectors (conj (config/projectors persistence) (config/timeline persistence))
                       processor (processor/create meta "regression-set" persistence projectors)]
                   (dorun (processor/consume processor features))
+                  (e/fill-extract "regression-set" nil)
+                  (e/flush-changelog "regression-set")
                   (:statistics (processor/shutdown processor))))
-              feature-permutation)))
+              feature-permutation)) 
+      :extracts extracts})))
 
 (defn replay []
   (println "  Replaying")

  (with-test-out
    (println ">>"(-> m :var meta :name))))

(defmacro defregressiontest* [name permutated? file stats-var & body]
  `(deftest ~name
     (with-bindings
       {#'dc/*persistence-schema-prefix* :featured_regression

  (testing "!>>> Timeline"
    (is (= (:n timeline-current) (count (query "timeline_current" {:collection collection :feature_id feature-id}))))
    (is (= (:n timeline) (count (query "timeline" {:collection collection :feature_id feature-id}))))
    ;(is (= (or (:n-new timeline-changelog) 0)
    ;       (count (query "timeline_changelog" {:collection collection :action "new"}))))
    ;(is (= (or (:n-change timeline-changelog) 0)    
    ;       (count (query "timeline_changelog" {:collection collection :action "change"}))))
    ;(is (= (or (:n-close timeline-changelog) 0)
    ;       (count (query "timeline_changelog" {:collection collection :action "close"}))))
    ;(is (= (or (:n-delete timeline-changelog) 0)
    ;       (count (query "timeline_changelog" {:collection collection :action "delete"}))))
    ))

(defn- test-timeline->extract [extracts n-extracts]
  (is (= n-extracts (count @extracts))))

(defn- query-geoserver [table]
  (if-not (pg/table-exists? test-db "regression-set" table)
