Minga.Extension.ContributionCleanup (Minga v0.1.0)

Copy Markdown View Source

Source-owned contribution cleanup coordinator.

The extension supervisor lives in the core Minga.* layer, so it cannot depend on editor presentation modules directly. Editor-layer registries register cleanup callbacks here when they accept source-owned contributions. The supervisor calls this module with a source, and the coordinator cleans core registries plus any registered higher-layer callbacks without creating compile-time upward dependencies.

Summary

Types

Cleanup failure reported for one family.

Cleanup callback invoked with a source identifier.

Cleanup options with injectable test registries.

Targeted lifecycle callback invoked with source-specific authority.

Source that contributed registry entries.

Functions

Runs one targeted source finalizer before runtime termination.

Registers a cleanup callback for a contribution family.

Registers a targeted lifecycle callback that requires explicit authority context.

Unregisters a cleanup callback. Mostly useful for tests.

Removes all contributions owned by a source.

Types

cleanup_failure()

@type cleanup_failure() :: %{
  family: atom(),
  source: contribution_source(),
  reason: term()
}

Cleanup failure reported for one family.

cleanup_fun()

@type cleanup_fun() :: (contribution_source() -> :ok | {:error, term()})

Cleanup callback invoked with a source identifier.

cleanup_opts()

@type cleanup_opts() :: [
  command_registry: GenServer.server(),
  keymap: GenServer.server(),
  callbacks: %{required(atom()) => registered_cleanup_fun()},
  context: term()
]

Cleanup options with injectable test registries.

contextual_cleanup_fun()

@type contextual_cleanup_fun() :: (contribution_source(), context :: term() ->
                               :ok | {:error, term()})

Targeted lifecycle callback invoked with source-specific authority.

contribution_source()

@type contribution_source() ::
  :builtin | :config | {:bundle, atom()} | {:extension, atom()}

Source that contributed registry entries.

Functions

finalize_source(source, family, opts \\ [])

@spec finalize_source(contribution_source(), atom(), cleanup_opts()) ::
  :ok | {:error, cleanup_failure()}

Runs one targeted source finalizer before runtime termination.

register(name, fun)

@spec register(atom(), cleanup_fun()) :: :ok

Registers a cleanup callback for a contribution family.

register_contextual(name, fun)

@spec register_contextual(atom(), contextual_cleanup_fun()) :: :ok

Registers a targeted lifecycle callback that requires explicit authority context.

unregister(name)

@spec unregister(atom()) :: :ok

Unregisters a cleanup callback. Mostly useful for tests.

unregister_source(source, opts \\ [])

@spec unregister_source(contribution_source(), cleanup_opts()) ::
  :ok | {:error, [cleanup_failure()]}

Removes all contributions owned by a source.