babylon.engine.systems.community
Community hypergraph system (Feature 022).
Manages the XGI hypergraph layer for n-ary community membership. Provides builder, query, and overlap matrix operations used by the CommunitySystem tick handler.
See also
babylon.models.entities.community: Data models.
babylon.formulas.community: Community formulas.
Constitution II.7: Edges vs Hyperedges (NetworkX + XGI).
Functions
|
Build XGI hypergraph where communities are hyperedges. |
|
Find institutional exclusion communities that bridge a contradiction axis. |
Compute pairwise community overlap matrix for all agents. |
|
|
State designates community — escalates legal status and raises heat. |
|
State disrupts community infrastructure. |
|
State infiltrates community — reduces cohesion. |
|
Escalate legal status by one step (one-way ratchet). |
|
Return community IDs (hyperedge IDs) shared by both agents. |
Classes
Hypergraph community system (Feature 022). |
- babylon.engine.systems.community.build_community_hypergraph(memberships, community_states)[source]
Build XGI hypergraph where communities are hyperedges.
Each community with at least one member becomes a hyperedge connecting all its member agent IDs. Community state attributes are stored as hyperedge attributes.
- Parameters:
memberships (
list[CommunityMembership]) – All community memberships across all agents.community_states (
dict[CommunityType,CommunityState]) – State dict keyed by community type.
- Return type:
Hypergraph- Returns:
XGI Hypergraph with agents as nodes and communities as hyperedges.
Return community IDs (hyperedge IDs) shared by both agents.
- babylon.engine.systems.community.communities_spanning_axis(H, contradiction)[source]
Find institutional exclusion communities that bridge a contradiction axis.
A community spans an axis if it contains members who also belong to communities on both the hegemonic and marginalized sides of that axis.
- Parameters:
H (
Hypergraph) – Community hypergraph.contradiction (
Contradiction) – The contradiction to check bridging for.
- Return type:
- Returns:
List of CommunityType values that bridge the axis.
- babylon.engine.systems.community.community_overlap_matrix(H)[source]
Compute pairwise community overlap matrix for all agents.
O[i,j] = number of communities containing both agent_i and agent_j. O[i,i] = degree of agent_i (number of communities they belong to).
- babylon.engine.systems.community.legal_status_escalate(state)[source]
Escalate legal status by one step (one-way ratchet).
- Parameters:
state (
CommunityState) – Current community state.- Return type:
- Returns:
New CommunityState with legal_status advanced one step. Returns unchanged if already at CRIMINALIZED.
- babylon.engine.systems.community.designate_community(state, heat_increase=0.3)[source]
State designates community — escalates legal status and raises heat.
- Parameters:
state (
CommunityState) – Current community state.heat_increase (
float) – Amount to add to heat.
- Return type:
- Returns:
New CommunityState with escalated legal status and increased heat.
- babylon.engine.systems.community.infiltrate_community(state, cohesion_reduction=0.2)[source]
State infiltrates community — reduces cohesion.
- Parameters:
state (
CommunityState) – Current community state.cohesion_reduction (
float) – Amount to subtract from cohesion.
- Return type:
- Returns:
New CommunityState with reduced cohesion.
- babylon.engine.systems.community.disrupt_infrastructure(state, infrastructure_reduction=0.4)[source]
State disrupts community infrastructure.
- Parameters:
state (
CommunityState) – Current community state.infrastructure_reduction (
float) – Amount to subtract from infrastructure.
- Return type:
- Returns:
New CommunityState with reduced infrastructure.
- class babylon.engine.systems.community.CommunitySystem[source]
Bases:
objectHypergraph community system (Feature 022).
Manages alpha-smoothed community state decay, solidarity potential computation from community overlap, threat score aggregation, and reproduction cost modification. Runs before SolidaritySystem in the engine pipeline (position 6).
- name = 'community'