Skip to content

composition

_composition

Composition families recognised by the protocol checks.

A protocol package composes its graph with one DAG authoring library and publishes the factory under that library's entry-point group. While axm-loom is being replaced by axm-tribunal, both families are recognised. Each family is one row of :data:COMPOSITION_FAMILIES: retiring a family deletes its row and nothing else, because every protocol check reads its names from this table.

Names are plain strings. axm-init never imports either library: calls are resolved statically, through the inspected module's own imports.

COMPOSITION_CALLS = frozenset().union(*((family.calls) for family in COMPOSITION_FAMILIES)) module-attribute

Every recognised declarative composition call, all families together.

GRAPH_GROUPS = tuple((family.graphs_group) for family in COMPOSITION_FAMILIES) module-attribute

Every recognised graph entry-point group, in family precedence order.

CompositionFamily dataclass

One DAG authoring library, described by the names the checks resolve.

Attributes:

Name Type Description
name str

Short family label used in findings ("tribunal").

graphs_group str

Entry-point group its graph factories are published under.

protocol_call str

Qualified call whose first argument is the graph identity.

calls frozenset[str]

Qualified declarative composition calls, protocol_call included; they are safe at module level in an inspected module.

Source code in packages/axm-init/src/axm_init/checks/_composition.py
Python
@dataclass(frozen=True, slots=True)
class CompositionFamily:
    """One DAG authoring library, described by the names the checks resolve.

    Attributes:
        name: Short family label used in findings (``"tribunal"``).
        graphs_group: Entry-point group its graph factories are published under.
        protocol_call: Qualified call whose first argument is the graph identity.
        calls: Qualified declarative composition calls, ``protocol_call``
            included; they are safe at module level in an inspected module.
    """

    name: str
    graphs_group: str
    protocol_call: str
    calls: frozenset[str]

    def __post_init__(self) -> None:
        """Refuse a row whose identity call is not one of its own calls."""
        if self.protocol_call not in self.calls:
            msg = f"{self.name}: protocol call {self.protocol_call!r} not in calls"
            raise ValueError(msg)
__post_init__()

Refuse a row whose identity call is not one of its own calls.

Source code in packages/axm-init/src/axm_init/checks/_composition.py
Python
def __post_init__(self) -> None:
    """Refuse a row whose identity call is not one of its own calls."""
    if self.protocol_call not in self.calls:
        msg = f"{self.name}: protocol call {self.protocol_call!r} not in calls"
        raise ValueError(msg)

family_named(name)

Return the family labelled name, if it is still recognised.

Source code in packages/axm-init/src/axm_init/checks/_composition.py
Python
def family_named(name: str | None) -> CompositionFamily | None:
    """Return the family labelled *name*, if it is still recognised."""
    return next((f for f in COMPOSITION_FAMILIES if f.name == name), None)

family_of_protocol_call(qualified)

Return the family whose graph-identity call is qualified, if any.

Source code in packages/axm-init/src/axm_init/checks/_composition.py
Python
def family_of_protocol_call(qualified: str | None) -> CompositionFamily | None:
    """Return the family whose graph-identity call is *qualified*, if any."""
    return next((f for f in COMPOSITION_FAMILIES if f.protocol_call == qualified), None)