anchor.diff:  %% Errors:
   %%   ill_formed_name
   %%   inappropriate_scoped_name
  +-spec parse_scoped_name(binary(), boolean(), #context{}) -> #sname{} | {atom(), binary()}.
   parse_scoped_name(Name, ScopedOk, Context) ->
       Pattern = make_regex(),
       maybe_parse_scoped_name(Name, Pattern, ScopedOk, Context).
  
positive.code:                       #{}, L),
      maps:to_list(Map).
  
  
  %%
  %%
  make_sql_callback() ->
      fun chef_sql:select_rows/1.
  
  
  %%
  %% Helper function for working with unscoped names
  %%
  make_scoped_names(OrgName, Names) ->
      [{OrgName, Name} || Name <- Names].
  
  %%
  %%
  %%
  fetch_authz_ids(Type, ScopedNames) ->
      NamesByOrg = group_by_key(ScopedNames),
      case fetch_ids_rec(Type, NamesByOrg, {[], []}) of
          [Found, []] ->
              Found;
          [_, Missing] ->
              throw({invalid, Type, Missing})
      end.
  
  
  %%
  %%
  %%
  fetch_ids_rec(_type, [], {Found, Missing}) ->
      {lists:flatten(Found), Missing};
  fetch_ids_rec(Type, [{OrgId, Names} | Remainder], {Found, Missing}) ->
      Records = oc_chef_authz_db:authz_records_by_name(Type, OrgId, Names),
      FoundNames = lists:sort(names_from_records(Records)), % Investigate if this sort is redundant (db may already sort)
      Remaining = Names -- FoundNames, % --/++ on very large lists might be slow.
      Missing1 = case Remaining of
                    [] ->
                        [{OrgId, Remaining} | Missing];
                    _ ->
                        Missing
                end,
      fetch_ids_rec(Type, Remainder, {[FoundNames | Found], Missing1}).
  
  
  %%
  %% Expansion of authz ids into scoped names
  %% Takes {OrgName, Name} pairs in ScopedNames and returns
  %% list of names with scoping metacharacter inserted
  render_names_in_context(OrgId, ScopedNames, Context) ->
      GroupedScopedNames = group_by_key(ScopedNames),
      {Expanded, _Cache} = lists:foldl(fun(E, A) -> render_names_in_context_f(OrgId, E, A) end,
  
negative.code: -define(SCOPE_SEPARATOR, <<"::">>).
  -define(SCOPED_NAME_REGEX, "^(?:(" ?NAME "+)|(?:(" ?NAME "*)\\:\\:(" ?NAME "+)))$").
  
  -type db_callback() :: fun().
  
  -record(context, {org_id :: binary(),
                    db_context :: any() | undefined,
                    db_callback_fun :: db_callback()
                   }).
  
  -record(sname, {full :: binary(),
                  base :: binary() | undefined,
                  org  :: binary() | 'global_org' | undefined,
                  org_id :: binary() | undefined,
                  authz_id :: binary() | undefined
                 }).
  
  -type lookup_type() :: 'actor' | 'user' | 'client' | 'group'.
  
  %%
  %% Context is used to thread external state information through the system
  %%
  %% Dialyzer is grouchy unless undefined is included in types.
  -spec initialize_context(binary() | undefined) -> #context{}.
  initialize_context(OrgId) ->
      initialize_context(OrgId, make_sql_callback()).
  
  -spec initialize_context(binary() | undefined , db_callback() | undefined) -> #context{}.
  initialize_context(OrgId, CallBackFun) ->
      initialize_context(OrgId, undefined, CallBackFun).
  
  %-spec initialize_context(binary(), tuple(), db_callback()) -> #context{}.
  initialize_context(OrgId, DbContext, CallBackFun) ->
      #context{org_id = OrgId,
               db_context = DbContext,
               db_callback_fun = CallBackFun}.
  
  %%
  %% Takes scoped names to authz ids
  