Skip to content

HubArbiter

autogen.beta.network.hub.arbiter.HubArbiter #

Bases: Protocol

Decision-making Protocol the hub consults before committing.

Implementations replace the default :class:RuleBasedArbiter via :meth:Hub.register_arbiter. Only one arbiter is active at a time; the most recent registration wins.

Methods may inspect any state passed in but should not mutate hub state — they are decisions, not side-effecting work.

authorize_send async #

authorize_send(envelope, sender, sender_rule, recipients)

Gate post_envelope before the WAL append.

Checks rule-based outbound access (access.outbound_to) plus delegation depth (limits.delegation_depth). Inbox capacity is handled separately by :meth:authorize_inbox because it depends on per-recipient hub-internal counters.

Source code in autogen/beta/network/hub/arbiter.py
async def authorize_send(
    self,
    envelope: "Envelope",
    sender: "Passport",
    sender_rule: "Rule",
    recipients: list["Passport"],
) -> Decision:
    """Gate ``post_envelope`` before the WAL append.

    Checks rule-based outbound access (``access.outbound_to``)
    plus delegation depth (``limits.delegation_depth``). Inbox
    capacity is handled separately by :meth:`authorize_inbox`
    because it depends on per-recipient hub-internal counters.
    """

authorize_inbox async #

authorize_inbox(envelope, recipient, recipient_rule, current_pending)

Gate post_envelope per-recipient against inbox capacity.

Hub iterates the resolved audience, calling this once per recipient with their current pending count. Returning Deny (with error=InboxFull by default) short-circuits the send.

Source code in autogen/beta/network/hub/arbiter.py
async def authorize_inbox(
    self,
    envelope: "Envelope",
    recipient: "Passport",
    recipient_rule: "Rule",
    current_pending: int,
) -> Decision:
    """Gate ``post_envelope`` per-recipient against inbox capacity.

    Hub iterates the resolved audience, calling this once per
    recipient with their current pending count. Returning
    ``Deny`` (with ``error=InboxFull`` by default) short-circuits
    the send.
    """

authorize_dispatch async #

authorize_dispatch(envelope, sender, recipient, recipient_rule)

Gate per-recipient dispatch (inbound access).

Called for every notify frame the hub is about to send. Returning Deny causes the hub to silently skip this recipient (the rest of the audience still gets delivery).

Source code in autogen/beta/network/hub/arbiter.py
async def authorize_dispatch(
    self,
    envelope: "Envelope",
    sender: "Passport",
    recipient: "Passport",
    recipient_rule: "Rule",
) -> Decision:
    """Gate per-recipient dispatch (inbound access).

    Called for every notify frame the hub is about to send.
    Returning ``Deny`` causes the hub to silently skip this
    recipient (the rest of the audience still gets delivery).
    """

authorize_channel_open async #

authorize_channel_open(manifest, creator, creator_rule, invitees, invitee_rules, active_creator_channels)

Gate create_channel before any persistence.

Default impl checks each invitee's access.inbound_from against the creator's name, plus the creator's limits.max_concurrent_channels against the running count.

Source code in autogen/beta/network/hub/arbiter.py
async def authorize_channel_open(
    self,
    manifest: "ChannelManifest",
    creator: "Passport",
    creator_rule: "Rule",
    invitees: list["Passport"],
    invitee_rules: list["Rule"],
    active_creator_channels: int,
) -> Decision:
    """Gate ``create_channel`` before any persistence.

    Default impl checks each invitee's ``access.inbound_from``
    against the creator's name, plus the creator's
    ``limits.max_concurrent_channels`` against the running count.
    """

authorize_register async #

authorize_register(passport, resume, rule)

Gate Hub.register. Default impl always allows.

Source code in autogen/beta/network/hub/arbiter.py
async def authorize_register(
    self,
    passport: "Passport",
    resume: "Resume",
    rule: "Rule",
) -> Decision:
    """Gate ``Hub.register``. Default impl always allows."""

resolve_unknown_audience async #

resolve_unknown_audience(envelope, unknown_ids)

Federation hook for audience members the hub doesn't know.

Default impl returns None (drop unknown ids, current single-hub behavior). A federated arbiter returns a (possibly empty) list of agent_ids the envelope should be re-delivered to instead — typically the local proxy id of a remote peer.

Source code in autogen/beta/network/hub/arbiter.py
async def resolve_unknown_audience(
    self,
    envelope: "Envelope",
    unknown_ids: list[str],
) -> list[str] | None:
    """Federation hook for audience members the hub doesn't know.

    Default impl returns ``None`` (drop unknown ids, current
    single-hub behavior). A federated arbiter returns a
    (possibly empty) list of agent_ids the envelope should be
    re-delivered to instead — typically the local proxy id of a
    remote peer.
    """