     state
     (permute (mapcat (fn [i] (map (fn [j] (conj i j)) head)) state) tail)))
 
+
+(deftest test-permute
+  (is (= 
+       [[:a1 :b1 :c1] [:a1 :b2 :c1] [:a1 :b3 :c1] [:a2 :b1 :c1] [:a2 :b2 :c1] [:a2 :b3 :c1]]
+       (permute [[]] [[:a1 :a2][:b1 :b2 :b3][:c1]]))))
+
 ;;--------------------------------------------------------------------------------
 ;; this layer encapsulates access to lhs index
 

      (fn [lhs-index lhs-fk-key] (assoc-in lhs-index [(lhs-fk-key lhs) lhs-pk] lhs))
      (first indeces)
      lhs-fk-keys))))

;;--------------------------------------------------------------------------------
;; this layer encapsulates access to rhs indeces

(deftest test-join-abc
  (is (= (->ABC [:a1 :b1 :c1] [0 0 0] "b-data" "c-data") 
	 (join-abc (->A :a1 0 :b :c)(->B :b1 0 :b "b-data")(->C :c1 0 :c "c-data")))))

(deftest test-join-model
  (let [as (versioned-optimistic-map-model (str :as) :name :version >)
