babylon.models.entities.relationship
Relationship entity model.
A Relationship is the fundamental edge type in the Babylon simulation. It represents a directed relationship between two entities (typically SocialClasses).
Relationships encode: 1. Value flows (imperial rent, unequal exchange) 2. Social dynamics (solidarity, repression, competition) 3. Dialectical tension (accumulated contradiction intensity)
This is the Phase 1 edge type from the four-phase blueprint.
Classes
|
Value flow and tension state of a relationship. |
|
A directed edge between two entities. |
- class babylon.models.entities.relationship.FlowComponent(**data)[source]
Bases:
BaseModelValue flow and tension state of a relationship.
- Parameters:
- model_config: ClassVar[ConfigDict] = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class babylon.models.entities.relationship.Relationship(**data)[source]
Bases:
BaseModelA directed edge between two entities.
Represents flows of value, solidarity, or repression between classes. In Phase 1, the primary relationship is exploitation: value flows from the periphery worker (source) to the core owner (target).
This model uses Sprint 1 constrained types for automatic validation: - Currency: [0, inf) for value_flow - Intensity: [0, 1] for tension
- Parameters:
- source_id
Origin entity ID (value/action flows FROM here)
- target_id
Destination entity ID (value/action flows TO here)
- edge_type
Nature of the relationship (EdgeType enum)
- value_flow
Imperial rent or value transfer amount (Currency, default 0.0)
- tension
Dialectical tension/contradiction intensity (Intensity, default 0.0)
- description
Optional description of the relationship
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'str_strip_whitespace': True, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod unpack_flow_component(data)[source]
Unpack flow component into flat fields if provided.
- validate_no_self_loop()[source]
Ensure entities cannot have a relationship with themselves.
- Return type:
- property edge_tuple: tuple[str, str]
Return (source_id, target_id) tuple for NetworkX edge creation.
Usage:
G.add_edge(*relationship.edge_tuple, **relationship.edge_data)
- property edge_data: dict[str, object]
Return edge attributes dict for NetworkX, excluding IDs.
Usage:
G.add_edge(*relationship.edge_tuple, **relationship.edge_data)
- property flow: FlowComponent
Return flow component view (computed, not live).