anchor.diff:      receive
           {Pid,Job} ->
               Pid ! ok,
  -            Worker = find_worker(Job),
  +            Worker = erligig_db:available_worker(Job),
               case Worker of
                   null -> wakeup_loop();
                   _ ->
  
positive.code:     [A|_] = string:tokens(binary_to_list(Data),"\0"),
      ID = list_to_binary(A),
  
      % the worker is available to do work again
      WorkerRec = #worker{sock=Worker,state=ready},
      mnesia:transaction(fun() -> mnesia:write(WorkerRec) end),
  
      % find the job just completed
      [Job|_] = dbq(qlc:q([J || J <- mnesia:table(work),
                                J#work.id =:= ID])),
      mnesia:transaction(fun() -> mnesia:delete({work,Job#work.id}) end),
  
      if Job#work.client =/= null ->
              ?DEBUG("<== client: ~p WORK_COMPLETE~n", [Job#work.client]),
              send_response(Job#work.client, ?WORK_COMPLETE, Data);
         true -> noop
      end;
  
  % this ones goes last to alert us something didnt get handled properly
  
negative.code: -module(erligig).
  -export([start/0]).
  
  -include("records.hrl").
  
  -define(REQ,<<"\0REQ">>).
  -define(RES,<<"\0RES">>).
  