CommBus.Protocol.SectionRoles (CommBus v0.1.0)

Copy Markdown View Source

Registry for mapping CommBus sections (e.g., :system, :pre_history) to downstream message roles understood by provider pipelines.

Sections default to :system roles, but callers can register additional mappings (for example, mapping :memory sections to :assistant). Overrides from pipeline opts still take precedence, so projects can adjust behaviour per request.

Summary

Functions

Returns the built-in section-role mapping.

Removes a custom mapping for the provided section.

Returns the currently configured section-role mapping.

Registers or updates a mapping between a section and a downstream role.

Registers multiple mappings at once.

Resets all mappings back to factory defaults.

Returns the resolved mapping merged with optional overrides (map/keyword).

Types

mapping()

@type mapping() :: %{optional(atom()) => atom()}

role()

@type role() :: atom() | String.t()

section()

@type section() :: atom() | String.t()

Functions

default_roles()

@spec default_roles() :: mapping()

Returns the built-in section-role mapping.

delete(section)

@spec delete(section()) :: :ok | {:error, term()}

Removes a custom mapping for the provided section.

get()

@spec get() :: mapping()

Returns the currently configured section-role mapping.

put(section, role)

@spec put(section(), role()) :: :ok | {:error, term()}

Registers or updates a mapping between a section and a downstream role.

put_all(mappings)

@spec put_all(map() | keyword()) :: :ok

Registers multiple mappings at once.

reset()

@spec reset() :: :ok

Resets all mappings back to factory defaults.

resolve(overrides \\ %{})

@spec resolve(map() | keyword()) :: mapping()

Returns the resolved mapping merged with optional overrides (map/keyword).