MingaEditor.Shell.Registry (Minga v0.1.0)

Copy Markdown View Source

Serialized source-owned registry for workspace shells.

One GenServer validates every duplicate decision, source-owned removal, generation assignment, and cleanup transition. It publishes the complete validated snapshot through one persistent_term key so input and render hot paths never observe separately updated module and source metadata.

Summary

Functions

Returns true when the id is currently registered.

Returns a specification to start this module under a supervisor.

Returns the default shell entry, falling back to Traditional when the registry is empty.

Returns a shell entry by id.

Returns the shell id registered for a module, or nil.

Returns registered shells in deterministic display order.

Returns the registered module for an id, or nil.

Registers a shell contribution.

Resets registry state. Intended for tests that need isolated registry setup.

Resolves an id or implementation module from one coherent snapshot.

Registers the built-in shell contributions. Safe to call more than once.

Returns one coherent registry publication.

Starts the sole shell-registry publisher.

Returns true when the shell supports a capability atom.

Unregisters a shell by id. Built-in shells are preserved and extension shells require their source.

Unregisters a shell owned by the given source.

Unregisters all shells owned by a source as one publication.

Types

register_attrs()

@type register_attrs() :: keyword() | map()

register_error()

@type register_error() ::
  MingaEditor.Shell.Registry.Snapshot.register_error()
  | {:missing_default, term()}
  | {:invalid_entry, term()}
  | :source_required
  | :not_owner

server()

@type server() :: GenServer.server()

shell_id()

@type shell_id() :: atom()

snapshot()

source()

Functions

available?(id)

@spec available?(shell_id()) :: boolean()

Returns true when the id is currently registered.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

default()

@spec default() :: MingaEditor.Shell.Entry.t()

Returns the default shell entry, falling back to Traditional when the registry is empty.

get(id)

@spec get(shell_id()) :: MingaEditor.Shell.Entry.t() | nil

Returns a shell entry by id.

id_for_module(module)

@spec id_for_module(module()) :: shell_id() | nil

Returns the shell id registered for a module, or nil.

list()

@spec list() :: [MingaEditor.Shell.Entry.t()]

Returns registered shells in deterministic display order.

module_for(id)

@spec module_for(shell_id()) :: module() | nil

Returns the registered module for an id, or nil.

register(source, attrs)

@spec register(source(), register_attrs()) :: :ok | {:error, register_error()}

Registers a shell contribution.

reset_for_test(entries \\ [])

@spec reset_for_test([MingaEditor.Shell.Entry.t()]) :: :ok

Resets registry state. Intended for tests that need isolated registry setup.

resolve(id_or_module)

@spec resolve(shell_id() | module()) :: MingaEditor.Shell.Entry.t() | nil

Resolves an id or implementation module from one coherent snapshot.

seed_builtin()

@spec seed_builtin() :: :ok

Registers the built-in shell contributions. Safe to call more than once.

snapshot()

@spec snapshot() :: snapshot()

Returns one coherent registry publication.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the sole shell-registry publisher.

supports?(id, capability)

@spec supports?(shell_id(), atom()) :: boolean()

Returns true when the shell supports a capability atom.

unregister(id)

@spec unregister(shell_id()) :: :ok | {:error, :builtin_shell | :source_required}

Unregisters a shell by id. Built-in shells are preserved and extension shells require their source.

unregister(source, id)

@spec unregister(source(), shell_id()) :: :ok | {:error, :builtin_shell | :not_owner}

Unregisters a shell owned by the given source.

unregister_source(source)

@spec unregister_source(source()) :: :ok

Unregisters all shells owned by a source as one publication.