anchor.diff:      Puts2 = ordsets:del_element(Pid, S#state.put_fsm),
       S#state{put_fsm = Puts2}.
   
  -
  -postcondition(S, {call, _Mod, put_fsm_started, _Args}, Res) ->
  -    check_state(S#state{put_fsm = [Res | S#state.put_fsm]});
  -
  -postcondition(S, {call, _Mod, get_fsm_started, _Args}, Res) ->
  -    check_state(S#state{get_fsm = [Res | S#state.get_fsm]});
  -
  -postcondition(S, {call, _Mod, put_fsm_noproc, _Args}, _Res) ->
  -    check_state(S);
  -
  -postcondition(S, {call, _Mod, get_fsm_noproc, _Args}, _Res) ->
  -    check_state(S);
  -
  -postcondition(S, {call, _Mod, put_fsm_exit_error, _Args}, Res) ->
  -    S2 = S#state{
  -        put_fsm = ordsets:del_element(Res, S#state.put_fsm),
  -        put_errors = S#state.put_errors + 1
  -    },
  -    check_state(S2);
  -
  -postcondition(S, {call, _Mod, get_fsm_exit_error, _Args}, Res) ->
  -    S2 = S#state{
  -        get_fsm = ordsets:del_element(Res, S#state.get_fsm),
  -        get_errors = S#state.get_errors + 1
  -    },
  -    check_state(S2);
  -
  -postcondition(S, {call, _Mod, _NiceShutdown, [put, _]}, Res) ->
  -    S2 = S#state{
  -        put_fsm = ordsets:del_element(Res, S#state.put_fsm)
  -    },
  -    check_state(S2);
  -
  -postcondition(S, {call, _Mod, _NiceShutdown, [get, _]}, Res) ->
  -    S2 = S#state{
  -        get_fsm = ordsets:del_element(Res, S#state.get_fsm)
  -    },
  -    check_state(S2).
  -
  -
  -check_state(S) ->
  +postcondition(_, _, _) ->
  +    true.
  +
  +invariant(S) ->
       #state{put_errors = PutErrCount, get_errors = GetErrCount,
           put_fsm = PutList, get_fsm = GetList} = S,
  -    % wait for folsom stats to settle; if we check too quick, folsom won't have
  -    % finished updating. Timers suck, so maybe something better will come along
  -    timer:sleep(10),
   
       % with a timetrap of 60 seconds, the spiral will never have values slide off
       MetricExpects = [
  -        {{riak_kv, node, puts, fsm, active}, length(PutList)},
  -        {{riak_kv, node, gets, fsm, active}, length(GetList)},
  -        {{riak_kv, node, puts, fsm, errors}, [{count, PutErrCount}, {one, PutErrCount}]},
  -        {{riak_kv, node, gets, fsm, errors}, [{count, GetErrCount}, {one, GetErrCount}]}
  +        {?PUTS_ACTIVE, length(PutList)},
  +        {?GETS_ACTIVE, length(GetList)},
  +        {?PUTS_ERRORS, [{count, PutErrCount}, {one, PutErrCount}]},
  +        {?GETS_ERRORS, [{count, GetErrCount}, {one, GetErrCount}]}
       ],
   
       [ begin
  -        ?assertEqual(Expected, folsom_metrics:get_metric_value(Metric))
  -    end || {Metric, Expected} <- MetricExpects],
  +        Val = folsom_metrics:get_metric_value(Metric),
  +        case Val of 
  +            Expected -> ok;
  +            _ -> io:format(user, "Failed Metric = ~p~n", [Metric])
  +        end,
  +        ?assertEqual(Expected, Val)
  +      end || {Metric, Expected} <- MetricExpects],
   
       true.
  +
  +poll_stat_change(Metric, OriginalValue) ->
  +    case folsom_metrics:get_metric_value(Metric) of
  +        OriginalValue -> 
  +            poll_stat_change(Metric, OriginalValue);
  +        _ ->
  +            ok
  +    end.
   
   %% wait for all fake fsms to finish, so the monitors
   %% get to finish before folsom is stopped.
  
positive.code:         aggregate(command_names(Cmds), Res == ok)
      end).
  
  %% ====================================================================
  %% eqc_statem callbacks
  %% ====================================================================
  
  initial_state() ->
      [maybe_stop_and_wait(Server) || Server <- [riak_core_stat_cache, riak_kv_stat]],
      application:start(folsom),
      {ok, Cache} = riak_core_stat_cache:start_link(),
      {ok, Pid} = riak_kv_stat:start_link(),
      unlink(Pid),
      unlink(Cache),
      #state{}.
  
  command(S) ->
  
negative.code:     end.
  
  end_and_wait(Pid, Cause) ->
      Monref = erlang:monitor(process, Pid),
      Pid ! Cause,
      receive
          {'DOWN', Monref, process, Pid, _} ->
              ok
  