babylon.models.entities.community

Community membership models for the hypergraph layer (Feature 022).

Communities are n-ary membership structures represented as XGI hyperedges. This module defines the data models for community state and agent membership.

See also

babylon.engine.systems.community: CommunitySystem that operates on these models. Constitution II.7: Edges vs Hyperedges (NetworkX + XGI).

Functions

effective_infiltration_ceiling(base_ceiling, ...)

Compute effective infiltration ceiling reduced by community resistance.

is_hegemonic(community)

Return True if the community is on the hegemonic side of any axis.

is_marginalized(community)

Return True if the community is marginalized (including institutional exclusion).

shared_marginalized_communities(...)

Return marginalized communities shared by two agents.

Classes

CommunityMembership(**data)

An agent's membership in a community.

CommunityState(**data)

State of a community, independent of its members.

babylon.models.entities.community.is_hegemonic(community)[source]

Return True if the community is on the hegemonic side of any axis.

Parameters:

community (CommunityType) – A CommunityType member.

Return type:

bool

Returns:

True if hegemonic, False otherwise.

babylon.models.entities.community.is_marginalized(community)[source]

Return True if the community is marginalized (including institutional exclusion).

Parameters:

community (CommunityType) – A CommunityType member.

Return type:

bool

Returns:

True if marginalized, False otherwise.

babylon.models.entities.community.shared_marginalized_communities(agent_a_communities, agent_b_communities)[source]

Return marginalized communities shared by two agents.

Parameters:
  • agent_a_communities (set[CommunityType]) – Set of community types agent A belongs to.

  • agent_b_communities (set[CommunityType]) – Set of community types agent B belongs to.

Return type:

set[CommunityType]

Returns:

Set of CommunityType that are in both agents’ sets AND are marginalized.

class babylon.models.entities.community.CommunityState(**data)[source]

Bases: BaseModel

State of a community, independent of its members.

Each community has collective attributes tracking state attention, internal cohesion, organizational infrastructure, and material modifiers applied to all members.

Parameters:
  • community_type (CommunityType) – Identity of this community.

  • heat (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)]) – State attention/surveillance intensity [0, 1].

  • legal_status (LegalStatus) – Current legal designation (one-way escalation).

  • cohesion (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)]) – Internal trust and mutual aid effectiveness [0, 1].

  • infrastructure (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)]) – Organizational capacity (meeting spaces, comms) [0, 1].

  • visibility (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)]) – Community legibility to state surveillance [0, 1].

  • reproduction_cost_modifier (Annotated[float, Ge(ge=0)]) – Multiplier on V_reproduction for members.

  • rent_access_modifier (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)]) – Multiplier on imperial rent received by members.

  • category (HyperedgeCategory)

  • consciousness (TernaryConsciousness)

  • education_pressure (Annotated[float, Ge(ge=0)])

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

community_type: CommunityType
category: HyperedgeCategory
heat: Probability
legal_status: LegalStatus
cohesion: Probability
infrastructure: Probability
visibility: Probability
reproduction_cost_modifier: float
rent_access_modifier: Coefficient
consciousness: CommunityConsciousness
education_pressure: float
property infiltration_resistance: float

Community resistance to state infiltration.

Formula: CI * 0.6 + cohesion * 0.3 + CI * cohesion * 0.1

Returns:

Resistance score in [0.0, 1.0].

property is_cross_class_bridge: bool

Whether this community can span contradiction axes.

Only INSTITUTIONAL_EXCLUSION communities bridge across axes because their members can come from both hegemonic and marginalized sides.

Returns:

True if the community is an institutional exclusion type.

babylon.models.entities.community.effective_infiltration_ceiling(base_ceiling, target_community_states)[source]

Compute effective infiltration ceiling reduced by community resistance.

Parameters:
  • base_ceiling (float) – Base infiltration ceiling [0, 1].

  • target_community_states (list[CommunityState]) – Communities the target belongs to.

Return type:

float

Returns:

Reduced ceiling. At max resistance (~1.0), drops to ~30% of base.

class babylon.models.entities.community.CommunityMembership(**data)[source]

Bases: BaseModel

An agent’s membership in a community.

Represents the relationship between an individual agent and a community hyperedge. Each membership has a role determining integration level and a visibility determining legibility to state.

Parameters:
  • agent_id (str) – Identifier of the member agent.

  • community_type (CommunityType) – Which community this membership is in.

  • role (MembershipRole) – Integration level within the community.

  • strength (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)]) – Membership weight [0, 1], derived from role default.

  • visibility (Annotated[float, Ge(ge=0.0), Le(le=1.0), AfterValidator(func=~babylon.utils.math.quantize)]) – Base legibility to state [0, 1].

  • overt (bool) – Publicly identified — overrides visibility to 1.0.

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

agent_id: str
community_type: CommunityType
role: MembershipRole
strength: Coefficient
visibility: Probability
overt: bool
property effective_visibility: float

Effective visibility accounting for overt flag.

Returns:

1.0 if overt, otherwise the base visibility value.