anchor.diff:              %% Assume a race condition we can ignore. Maybe.
               ok
       end;
  -%% Can be success or failure; we don't care which. Tuple with result
  -%% code and whatever useful message the compilation process can
  -%% provide
  -compiling(Completion, #state{supervisor=Sup}=State) ->
  -    notify_supervisor(Sup, Completion),
  -    {stop, Completion, State#state{compiler=undefined}}.
  -
  -%% This is used strictly when we're ready to stop
  +compiling({done, FullPath}=Success, #state{supervisor=Sup}=State) ->
  +    notify_supervisor(Sup, Success),
  +    {next_state, compiled, State#state{compiler=undefined, beam_file=FullPath}, ?CMD_UPDATE};
  +compiling({failed, _Reason}=Error, #state{supervisor=Sup}=State) ->
  +    notify_supervisor(Sup, Error),
  +    {next_state, failed, State#state{compiler=undefined}, ?CMD_UPDATE}.
  +
  +
  +compiled(timeout, #state{supervisor=Sup, bucket_type=Type, ddl=OldDDL}=State) ->
  +    case check_activated(Type) of
  +        true ->
  +            notify_supervisor(Sup, {activated, Type}),
  +            {stop, {activated, Type}, State};
  +        false ->
  +            try_updated_build(OldDDL, retrieve_ddl(Type), compiled, State)
  +    end.
  +
  +failed(timeout, #state{bucket_type=Type, ddl=OldDDL}=State) ->
  +    try_updated_build(OldDDL, retrieve_ddl(Type), failed, State).
  +
   notify_supervisor(Supervisor, Status) ->
       gen_server:cast(Supervisor, Status).
   
  
positive.code: -include_lib("riak_core/include/riak_core_bucket_type.hrl").
  
  %% API
  -export([start_link/3, waiting/2, compiling/2]).
  
  %% gen_fsm callbacks
  -export([init/1, handle_event/3,
           handle_sync_event/4, handle_info/3, terminate/3, code_change/4]).
  
  -define(SERVER, ?MODULE).
  -define(CMD_RETRY, 2000). %% How long to wait for CMD to propagate
  -define(COMPILE_WAIT, 30000). %% How long to wait for the compilation mechanism to succeed before giving up
  
  -record(state, {
            bucket_type :: binary(),
            supervisor :: pid(),
            compiler = undefined :: 'undefined' | pid(),
            beam_dir :: file:filename()
           }).
  
  
  
negative.code: %% -------------------------------------------------------------------
  %%
  %% riak_kv_ts_watch_fsm: Polls for completion of DDL activities for bucket
  %% type activation
  %%
  %% Copyright (c) 2015 Basho Technologies, Inc.  All Rights Reserved.
  