 
 (defn all-jobs-have-coordinator
   [replica]
-  (every? (fn [[job _]]
-            (get-in replica [:coordinators job])) 
+  (every? (fn [[job job-allocations]]
+            ;; if no peers allocated, no coordinator should be allocated
+            (or (and (empty? (apply concat (vals job-allocations)))
+                     (nil? (get-in replica [:coordinators job])))
+                ;; if peers are allocated, a coordinator should be allocated
+                (get-in replica [:coordinators job]))) 
           (:allocations replica)))
 
 (defn no-extra-coordinators

(defn all-coordinators-exist 
  [replica]
  (every? (fn [coord]
            (some #{coord} (:peers replica)))
          (vals (:coordinators replica))))

(defn active-job-invariant

  (let [slot-id-peers (mapcat keys (vals (reduce merge (vals task-slot-ids))))]
    (and (= slot-id-peers (distinct slot-id-peers))
         (empty? (remove (set peers) slot-id-peers)))))

(defn all-groups-invariant
  [{:keys [groups prepared accepted pairs] 
