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:
ProtocolProtocol defining a historical materialist system.
- __init__(*args, **kwargs)
- 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:
objectMass 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}
- 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:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
context (ContextType)
- Return type:
None
- class babylon.engine.systems.ProductionSystem[source]
Bases:
objectPhase 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
- 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:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
_context (ContextType)
- Return type:
None
- class babylon.engine.systems.ImperialRentSystem[source]
Bases:
object5-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:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
context (ContextType)
- Return type:
None
- class babylon.engine.systems.ConsciousnessSystem[source]
Bases:
objectPhase 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:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
context (ContextType)
- Return type:
None
- class babylon.engine.systems.SurvivalSystem[source]
Bases:
objectPhase 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:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
_context (ContextType)
- Return type:
None
- class babylon.engine.systems.StruggleSystem[source]
Bases:
objectAgency 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:
Calculate EXCESSIVE_FORCE probability:
spark_prob = repression * spark_scaleRoll for spark occurrence
Check uprising condition:
(Spark OR P(S|R) > P(S|A)) AND agitation > thresholdExecute 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
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:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
context (ContextType)
- Return type:
None
- class babylon.engine.systems.ContradictionSystem[source]
Bases:
objectPhase 4: Accumulation of Tension and Ruptures.
- name = 'Contradiction Tension'
- step(graph, services, context)[source]
Update tension on edges based on wealth gaps.
- Parameters:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
context (ContextType)
- Return type:
None
- class babylon.engine.systems.SolidaritySystem[source]
Bases:
objectProletarian 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:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
context (ContextType)
- Return type:
None
- class babylon.engine.systems.TerritorySystem[source]
Bases:
objectTerritory 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:
graph (nx.DiGraph[str] | GraphProtocol)
services (ServiceContainer)
context (ContextType)
- Return type:
None
- class babylon.engine.systems.ReserveArmySystem[source]
Bases:
objectComputes 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).
- class babylon.engine.systems.DispossessionEventSystem[source]
Bases:
objectComputes 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).
- class babylon.engine.systems.ContradictionFieldSystem[source]
Bases:
objectCompute 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'
- class babylon.engine.systems.FieldDerivativeSystem[source]
Bases:
objectCompute 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'
- class babylon.engine.systems.EdgeTransitionSystem[source]
Bases:
objectEvaluate 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'
Modules
Community hypergraph system (Feature 022). |
|
Contradiction systems for the Babylon simulation - The Rupture. |
|
ContradictionFieldSystem — System #14 in materialist causality order. |
|
Control ratio system for tracking guard:prisoner dynamics. |
|
Decomposition system for class breakdown during terminal crisis. |
|
Dispossession Event system (Feature 021, System #18). |
|
Economic systems: 5-phase Imperial Circuit with pool tracking. |
|
EdgeTransitionSystem — System #16 in materialist causality order. |
|
Event Template System - Data-Driven Event Evaluation. |
|
FieldDerivativeSystem — System #15 in materialist causality order. |
|
Ideology systems for the Babylon simulation - The Superstructure. |
|
LifecycleSystem for D-P-D' population dynamics (Feature 030). |
|
MetabolismSystem - The Metabolic Rift. |
|
OODA Loop System — organizational action resolution (Feature 032). |
|
ProductionSystem - The Soil. |
|
Protocol definition for simulation systems. |
|
Reserve Army of Labor system (Feature 021, System #17). |
|
Solidarity system for the Babylon simulation - Proletarian Internationalism. |
|
Struggle system for the Babylon simulation - The Agency Layer. |
|
Survival systems for the Babylon simulation - The Calculus of Living. |
|
Territory systems for the Babylon simulation - Layer 0. |
|
VitalitySystem - The Drain, The Attrition, and The Reaper. |