 
 (s/def ::delta/operation (s/multi-spec operation-spec (fn [o _] o)))
 
-(defn unconform-operation
-  ""
+(defn- unconform-operation
+  "Given `conformed-operation`, the result of of conforming a value to
+  `::delta/operation`, returns a raw operation.
+  "
   [conformed-operation]
   (if (::delta/insert conformed-operation)
     (update conformed-operation ::delta/insert val)
     conformed-operation))
 
+(defn- conformed-operation-length
+  "Given `conformed-operation`, the result of of conforming a value to
+  `::delta/operation`, returns the operation’s length in characters.
+  "
+  [conformed-operation]
+  (-> conformed-operation
+      unconform-operation
+      operation/length))
+
 (s/def ::delta/delta (s/coll-of ::delta/operation))
 
 (s/fdef operation/length

            [plumula.delta :as delta]
            [plumula.delta.operation :as operation]))

(s/def ::delta/text (s/and string? #(-> % count pos?)))
(s/def ::delta/embed (s/map-of keyword? any? :kind #(= (count %) 1)))

(s/def ::delta/insert (s/or :text ::delta/text :embed ::delta/embed))
(s/def ::delta/delete pos-int?)
(s/def ::delta/retain pos-int?)

(s/def ::delta/attributes (s/map-of keyword? any? :kind seq))

(defmulti operation-spec #(when (map? %) (operation/type %)))


  :ret #{::delta/insert ::delta/delete ::delta/retain})

(defn- operation-type-preserved?
  "True if the instrumented function returned an operation with the
  same type as its `operation` argument.
  "
  [{:keys [args ret]}]
  (= (-> ret operation/type)
     (-> args :operation operation/type)))

(defn- attributes-preserved?
  "True if the instrumented function returned an operation with the
  same attributes as its `operation` argument.
  "
  [{:keys [args ret]}]
  (= (-> ret ::delta/attributes)
     (-> args :operation ::delta/attributes)))

(defn- operation-shortenend-to-n?
  "True if the instrumented function shortened its `operation` argument
  to `n` characters (`n` is also an argument).
  "
  [{:keys [args ret]}]
  (= (-> ret conformed-operation-length)
     (min (:n args) (-> args :operation conformed-operation-length))))

(defn- text-preserved?
  "True the text of the result operation of the instrumented function
  stands in `relation` to the text of its `operation` argument.
  "
  [relation {:keys [args ret]}]
  (let [insert-text (some->> args :operation ::delta/insert (apply hash-map) :text)]
    (or (nil? insert-text)
