anchor.diff:              TargetCount >= SourceCount ->
                   % Executing this move would create a local imbalance in the DB
                   true;
  -            Total >= TargetLevel ->
  -                % The candidate has already achieved the target level
  +            TotalTarget > TargetLevel ->
  +                % The candidate has already exceeded the target level
  +                true;
  +            (TotalSource - TotalTarget) < 2 ->
  +                % Donating here is wasted work
                   true;
               true ->
                   false
  
positive.code:     fun(A, B) -> sort_by_count(A, B, Global) =< 0 end.
  
  sort_by_count({NodeA, SA}, {NodeB, SB}, Global) when length(SA) =:= length(SB) ->
      CountA = couch_util:get_value(couch_util:to_binary(NodeA), Global, 0),
      CountB = couch_util:get_value(couch_util:to_binary(NodeB), Global, 0),
      cmp(CountA, CountB);
  sort_by_count({_, A}, {_, B}, _) ->
      cmp(length(A), length(B)).
  
negative.code:         lists:member(Node, TargetNodes)
      end, shard_count_by_node(LocalOps)),
      TotalCount = lists:foldl(fun({_, C}, Sum) -> Sum + C end, 0, CountByNode),
      TargetLevel = TotalCount div length(TargetNodes),
      FoldFun = fun
          (_, Acc) when length(Acc) >= Limit ->
              % We've already accumulated the max number of shard ops.
  