babylon.engine.systems

Simulation systems for the Babylon engine.

Phase 2.1: Dialectical Refactor - modular system architecture. Agency Layer: StruggleSystem for political agency of oppressed classes. Feature 002: Dialectical Field Topology systems (positions 16-18). Feature 021: Capital Volume I systems (positions 5, 8).

class babylon.engine.systems.System(*args, **kwargs)[source]

Bases: Protocol

Protocol defining a historical materialist system.

__init__(*args, **kwargs)
property name: str

The identifier of the system.

step(graph, services, context)[source]

Apply system logic to the world graph.

Parameters:
  • graph – Mutable NetworkX graph representing WorldState.

  • services – ServiceContainer with config, formulas, event_bus, database.

  • context – TickContext or dict with ‘tick’ (int) and optional metadata. TickContext is the preferred type; dict is supported for backward compatibility with existing tests.

Return type:

None

class babylon.engine.systems.VitalitySystem[source]

Bases: object

Mass Line Phase 3: The Drain + Grinding Attrition + The Reaper.

Three-phase vitality check for all active entities:

Phase 1 - The Drain (Population-Scaled Subsistence Burn):

cost = (base_subsistence × population) × subsistence_multiplier wealth = max(0, wealth - cost)

Phase 2 - Grinding Attrition (Coverage Ratio Threshold Mortality):

Uses calculate_mortality_rate() from formulas.vitality: - coverage_ratio = wealth_per_capita / subsistence_needs - threshold = 1.0 + inequality - deficit = max(0, threshold - coverage_ratio) - attrition_rate = clamp(deficit × (0.5 + inequality), 0, 1) - Reduce population, emit POPULATION_ATTRITION event

Phase 3 - The Reaper (Extinction Check):

If population = 0 OR (population = 1 AND wealth < consumption_needs): - Mark entity as inactive - Emit ENTITY_DEATH event

Events:
POPULATION_ATTRITION: Coverage deficit deaths from inequality.

payload: {entity_id, deaths, remaining_population, attrition_rate}

ENTITY_DEATH: Full extinction of a demographic block.

payload: {entity_id, wealth, consumption_needs, cause, tick}

property name: str

System identifier.

step(graph, services, context)[source]

Execute three-phase vitality check.

Phase 1 - The Drain: Burn wealth based on population-scaled subsistence cost. Phase 2 - Grinding Attrition: Calculate coverage ratio threshold deaths. Phase 3 - The Reaper: Mark extinct entities as inactive.

Parameters:
Return type:

None

class babylon.engine.systems.ProductionSystem[source]

Bases: object

Phase 1: Value creation - The Soil.

Workers produce wealth proportional to territory biocapacity.

Production formula:

produced_value = base_labor_power * (biocapacity / max_biocapacity)

Only active workers with TENANCY edges to territories can produce. Bourgeoisie classes extract value but do not produce it.

__init__()[source]

Initialize ProductionSystem with declared invariants and phase.

Return type:

None

invariants: list[object] = []
property name: str

System identifier.

phase: int = 0
step(graph, services, _context)[source]

Generate wealth for workers and set extraction_intensity.

Iterates all social_class nodes. For active workers with TENANCY edges, calculates production based on territory health.

Production routing (Amin/Wallerstein model): - Direct producers (periphery): Production added to worker wealth - Employed producers (LA): Production routed to employer, stored

in graph metadata for wages phase to pay back with bonus

NOTE: base_labor_power is an annual rate, converted to weekly here to match ImperialRentSystem’s timescale conversion.

Parameters:
Return type:

None

class babylon.engine.systems.ImperialRentSystem[source]

Bases: object

5-phase Imperial Circuit: Extraction → Tribute → Wages → Subsidy → Decision.

ADR032: Subsistence burn moved to VitalitySystem (Phase 1: The Drain). This system now handles only economic extraction phases.

Pool tracks finite resources (inflow from tribute, outflow to wages/subsidy). See Simulation Systems Reference for full theory.

name = 'Imperial Rent'
step(graph, services, context)[source]

Execute 5-phase circuit. Economy state in graph.graph[‘economy’].

Parameters:
Return type:

None

class babylon.engine.systems.ConsciousnessSystem[source]

Bases: object

Phase 2: Consciousness Drift based on material conditions.

Sprint 3.4.3 (George Jackson Refactor): Uses multi-dimensional IdeologicalProfile. - class_consciousness: Relationship to Capital [0=False, 1=Revolutionary] - national_identity: Relationship to State/Tribe [0=Internationalist, 1=Fascist] - agitation: Raw political energy from crisis (falling wages)

Extended with Fascist Bifurcation mechanic: - Reads incoming SOLIDARITY edges to calculate solidarity_pressure - Tracks wage changes between ticks to detect crisis conditions - Routes agitation to either class_consciousness or national_identity

name = 'Consciousness Drift'
step(graph, services, context)[source]

Apply consciousness drift to all entities with bifurcation routing.

Parameters:
Return type:

None

class babylon.engine.systems.SurvivalSystem[source]

Bases: object

Phase 3: Survival Calculus (P(S|A) vs P(S|R)).

Bug Fix (Sprint 3.4.2): Organization is now DYNAMIC. organization = base_organization + solidarity_bonus

Mass Line Phase 4: P(S|A) uses per-capita wealth. wealth_per_capita = wealth / population

Where solidarity_bonus = sum of incoming SOLIDARITY edge weights. This ensures that High Solidarity scenarios produce higher P(S|R).

name = 'Survival Calculus'
step(graph, services, _context)[source]

Update P(S|A) and P(S|R) for all entities.

Mass Line Phase 4: P(S|A) uses wealth_per_capita, not aggregate wealth. This ensures demographic blocks are evaluated per-person, not as monolith.

Organization is calculated as:

effective_org = base_org * solidarity_multiplier

Where solidarity_multiplier = 1.0 + sum(solidarity_strength for incoming SOLIDARITY edges)

Parameters:
Return type:

None

class babylon.engine.systems.StruggleSystem[source]

Bases: object

Agency Layer - The Struggle System (“George Floyd Dynamic”).

This system runs AFTER SurvivalSystem (needs P values) and BEFORE ContradictionSystem. It gives agency to oppressed classes through the Stochastic Riot mechanic:

  1. Calculate EXCESSIVE_FORCE probability: spark_prob = repression * spark_scale

  2. Roll for spark occurrence

  3. Check uprising condition: (Spark OR P(S|R) > P(S|A)) AND agitation > threshold

  4. Execute uprising:

    • Economic damage: wealth *= (1 - destruction_rate)

    • Solidarity gain: Increase solidarity_strength on incoming SOLIDARITY edges

    • Class consciousness gain: All nodes in uprising gain consciousness

  5. Emit events for narrative layer

The solidarity built in Tick N enables SolidaritySystem transmission in Tick N+1.

name = 'Struggle'
step(graph, services, context)[source]

Apply struggle dynamics to all eligible entities.

Processes PERIPHERY_PROLETARIAT and LUMPENPROLETARIAT nodes, checking for spark events and uprising conditions.

Parameters:
Return type:

None

class babylon.engine.systems.ContradictionSystem[source]

Bases: object

Phase 4: Accumulation of Tension and Ruptures.

name = 'Contradiction Tension'
step(graph, services, context)[source]

Update tension on edges based on wealth gaps.

Parameters:
Return type:

None

class babylon.engine.systems.SolidaritySystem[source]

Bases: object

Proletarian Internationalism - Consciousness Transmission System.

Implements consciousness transmission via SOLIDARITY edges: - Unidirectional flow (Periphery -> Core) - solidarity_strength stored on edge (key for Fascist Bifurcation) - Emits CONSCIOUSNESS_TRANSMISSION and MASS_AWAKENING events

Sprint 3.4.3: Updated to work with IdeologicalProfile, affecting only the class_consciousness dimension.

name = 'Solidarity'
step(graph, services, context)[source]

Apply solidarity transmission to all SOLIDARITY edges.

For each SOLIDARITY edge: 1. Check if source consciousness > activation_threshold 2. Check if solidarity_strength > 0 3. Calculate transmission delta 4. Apply delta to target class_consciousness 5. Emit events for narrative layer

Parameters:
Return type:

None

class babylon.engine.systems.TerritorySystem[source]

Bases: object

Territory Dynamic System - Layer 0 spatial dynamics.

Implements the territorial substrate mechanics: - Heat dynamics based on operational profile - Eviction pipeline when heat exceeds threshold - Heat spillover between adjacent territories - Necropolitics for sink nodes (Sprint 3.7)

“Legibility over Stealth” - The State knows where you are. The game is about staying below the repression threshold.

Sprint 3.7 additions: - Population transfers to sink nodes during eviction - CONCENTRATION_CAMP population decay (elimination) - PENAL_COLONY organization suppression (atomization)

name = 'Territory'
step(graph, services, context)[source]

Apply territorial dynamics to the graph.

Phases execute in sequence: 1. Heat dynamics (profile-based accumulation/decay) 2. Eviction pipeline (triggered at threshold, routes to sinks) 3. Heat spillover (via adjacency edges) 4. Necropolitics (sink node effects)

Sprint 3.7.1: Context can contain ‘displacement_mode’ to override the default EXTRACTION mode for sink node routing.

Parameters:
Return type:

None

class babylon.engine.systems.ReserveArmySystem[source]

Bases: object

Computes reserve army composition and applies wage pressure.

For each territory node in the graph, reads the reserve_ratio (if available) and computes a wage_pressure coefficient that reduces median_wage. Stores the computed values on graph nodes and publishes events.

Position: #17 in _DEFAULT_SYSTEMS (after TickDynamicsSystem).

property name: str

System identifier.

step(graph, services, context)[source]

Apply reserve army wage pressure to all territories.

Parameters:
  • graph – Mutable world graph with territory nodes.

  • services – Service container with defines and event_bus.

  • context – Tick context with current tick number.

Return type:

None

class babylon.engine.systems.DispossessionEventSystem[source]

Bases: object

Computes aggregate dispossession and tracks value transfers.

For each territory node, reads dispossession rates (foreclosure_rate, eviction_rate, displacement_rate, etc.), computes composite intensity, and publishes events. Value transfers are clamped to available wealth.

Position: #18 in _DEFAULT_SYSTEMS (after ImperialRentSystem).

property name: str

System identifier.

step(graph, services, context)[source]

Process dispossession events for all territories.

Parameters:
  • graph – Mutable world graph with territory nodes.

  • services – Service container with defines and event_bus.

  • context – Tick context with current tick number.

Return type:

None

class babylon.engine.systems.ContradictionFieldSystem[source]

Bases: object

Compute contradiction fields for all social-class nodes.

Execution Order: 14 (after all 13 existing economic/consciousness systems)

For each social-class node, computes normalized contradiction field values using the registered field computation callables from the FieldRegistry. Stores field values on nodes and maintains a rolling history window in persistent_data for temporal derivative computation by System #15.

name = 'contradiction_field'
step(graph, services, context)[source]

Compute contradiction fields for all social-class nodes.

Parameters:
  • graph – Mutable graph (NetworkX or GraphProtocol).

  • services – ServiceContainer with field_registry.

  • context – TickContext or dict with tick and persistent_data.

Return type:

None

class babylon.engine.systems.FieldDerivativeSystem[source]

Bases: object

Compute spatial and temporal derivatives for contradiction fields.

Execution Order: 15 (after ContradictionFieldSystem)

Reads contradiction_fields from nodes (written by System #14), computes gradients on edges, Laplacian at nodes, and temporal derivatives from the rolling history in persistent_data.

name = 'field_derivative'
step(graph, services, context)[source]

Compute all spatial and temporal derivatives.

Parameters:
  • graph – Mutable graph (NetworkX or GraphProtocol).

  • services – ServiceContainer with field_registry.

  • context – TickContext or dict with tick and persistent_data.

Return type:

None

class babylon.engine.systems.EdgeTransitionSystem[source]

Bases: object

Evaluate compound predicates and fire edge mode transitions.

Execution Order: 16 (after FieldDerivativeSystem)

For each edge with an edge_mode, evaluates eligible transitions from the current mode. If a predicate fires, transitions to the new mode. Priority ordering resolves multiple eligible transitions.

name = 'edge_transition'
step(graph, services, context)[source]

Evaluate predicates and fire edge mode transitions.

Parameters:
  • graph – Mutable graph (NetworkX or GraphProtocol).

  • services – ServiceContainer with field_registry.

  • context – TickContext or dict with tick and persistent_data.

Return type:

None

Modules

community

Community hypergraph system (Feature 022).

contradiction

Contradiction systems for the Babylon simulation - The Rupture.

contradiction_field

ContradictionFieldSystem — System #14 in materialist causality order.

control_ratio

Control ratio system for tracking guard:prisoner dynamics.

decomposition

Decomposition system for class breakdown during terminal crisis.

dispossession_events

Dispossession Event system (Feature 021, System #18).

economic

Economic systems: 5-phase Imperial Circuit with pool tracking.

edge_transition

EdgeTransitionSystem — System #16 in materialist causality order.

event_template

Event Template System - Data-Driven Event Evaluation.

field_derivative

FieldDerivativeSystem — System #15 in materialist causality order.

ideology

Ideology systems for the Babylon simulation - The Superstructure.

lifecycle

LifecycleSystem for D-P-D' population dynamics (Feature 030).

metabolism

MetabolismSystem - The Metabolic Rift.

ooda

OODA Loop System — organizational action resolution (Feature 032).

production

ProductionSystem - The Soil.

protocol

Protocol definition for simulation systems.

reserve_army

Reserve Army of Labor system (Feature 021, System #17).

solidarity

Solidarity system for the Babylon simulation - Proletarian Internationalism.

struggle

Struggle system for the Babylon simulation - The Agency Layer.

survival

Survival systems for the Babylon simulation - The Calculus of Living.

territory

Territory systems for the Babylon simulation - Layer 0.

vitality

VitalitySystem - The Drain, The Attrition, and The Reaper.