OapiCodemode.Registry (oapi_codemode v0.1.0)

Copy Markdown View Source

Holds ingested artifacts and per-API config in ETS. No persistence: hosts re-register at boot from wherever they keep specs.

Reads pay one GenServer.call to fetch the table ref — deliberate: lookups happen a handful of times per LLM tool call, so the hop is noise next to the LLM turn and the upstream HTTP request, and it keeps unnamed per-test registries isolated (a :named_table would not).

Summary

Functions

Returns a specification to start this module under a supervisor.

Register an ingested artifact under api_name.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

list(server)

@spec list(GenServer.server()) :: [
  {String.t(), %OapiCodemode.Registry.Entry{artifact: term(), config: term()}}
]

lookup(server, api_name)

@spec lookup(GenServer.server(), String.t()) ::
  {:ok, %OapiCodemode.Registry.Entry{artifact: term(), config: term()}}
  | {:error, :unknown_api}

register(server, api_name, artifact, config)

@spec register(
  GenServer.server(),
  String.t(),
  OapiCodemode.Artifact.t(),
  OapiCodemode.ApiConfig.t()
) ::
  :ok | {:error, {:invalid_api_name, term()} | :no_base_url}

Register an ingested artifact under api_name.

api_name must be a valid JS identifier — it becomes a property name on the sandbox globals. Returns {:error, {:invalid_api_name, name}} otherwise, or {:error, :no_base_url} when neither the config nor the spec supplies a server URL.

start_link(opts)