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.VitalitySystem[source]
Bases:
SystemBaseMass 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.
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
context (ContextType)
- class babylon.engine.systems.ProductionSystem[source]
Bases:
SystemBasePhase 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.
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
context (ContextType)
- class babylon.engine.systems.ImperialRentSystem[source]
Bases:
SystemBase5-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.
- step(graph, services, context)[source]
Execute 5-phase circuit. Economy state in graph.graph[‘economy’].
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
context (ContextType)
- class babylon.engine.systems.ConsciousnessSystem[source]
Bases:
SystemBasePhase 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
- step(graph, services, context)[source]
Apply consciousness drift to all entities with bifurcation routing.
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
context (ContextType)
- class babylon.engine.systems.SurvivalSystem[source]
Bases:
SystemBasePhase 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).
- 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.
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
_context (ContextType)
- Organization is calculated as:
effective_org = base_org * solidarity_multiplier
Where solidarity_multiplier = 1.0 + sum(solidarity_strength for incoming SOLIDARITY edges)
- class babylon.engine.systems.StruggleSystem[source]
Bases:
SystemBaseAgency 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.
- 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.
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
context (ContextType)
- class babylon.engine.systems.ContradictionSystem[source]
Bases:
SystemBasePhase 18: fresh-gap tension + opposition-registry contradiction frames.
- step(graph, services, context)[source]
Write fresh per-edge tension, then step the opposition registry.
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
context (ContextType)
- class babylon.engine.systems.SolidaritySystem[source]
Bases:
SystemBaseProletarian 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.
- 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
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
context (ContextType)
- class babylon.engine.systems.TerritorySystem[source]
Bases:
SystemBaseTerritory 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)
- 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.
- Return type:
None
- Parameters:
graph (GraphProtocol)
services (ServicesProtocol)
context (ContextType)
- class babylon.engine.systems.ReserveArmySystem[source]
Bases:
SystemBaseComputes 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: #5 in _DEFAULT_SYSTEMS (after TickDynamicsSystem).
- step(graph, services, context)[source]
Apply reserve army wage pressure to all territories.
- Parameters:
graph (
GraphProtocol) – Mutable world graph with territory nodes.services (
ServicesProtocol) – Service container with defines and event_bus.context (
Union[dict[str,Any],TickContext]) – Tick context with current tick number.
- Return type:
- class babylon.engine.systems.DispossessionEventSystem[source]
Bases:
SystemBaseComputes 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: #10 in _DEFAULT_SYSTEMS (after ImperialRentSystem).
- step(graph, services, context)[source]
Process dispossession events for all territories.
- Parameters:
graph (
GraphProtocol) – Mutable world graph with territory nodes.services (
ServicesProtocol) – Service container with defines and event_bus.context (
Union[dict[str,Any],TickContext]) – Tick context with current tick number.
- Return type:
- class babylon.engine.systems.ContradictionFieldSystem[source]
Bases:
SystemBaseCompute contradiction fields for all social-class nodes.
Execution Order: 19 (after the material-base and action systems)
For each social-class node, computes normalized contradiction field values — from the
field_registrycalculators when one is wired, else from the opposition layer (E0). Stores field values on nodes and maintains a rolling history window in persistent_data for temporal derivative computation by System #20.- step(graph, services, context)[source]
Compute contradiction fields for all social-class nodes.
- Parameters:
graph (GraphProtocol) – Mutable graph (NetworkX or GraphProtocol).
services (ServicesProtocol) – ServicesProtocol with field_registry.
context (ContextType) – TickContext or dict with tick and persistent_data.
- Return type:
None
- class babylon.engine.systems.FieldDerivativeSystem[source]
Bases:
SystemBaseCompute spatial and temporal derivatives for contradiction fields.
Execution Order: 20 (after ContradictionFieldSystem)
Reads contradiction_fields from nodes (written by System #19), computes gradients on edges, Laplacian at nodes, and temporal derivatives from the rolling history in persistent_data.
- step(graph, services, context)[source]
Compute all spatial and temporal derivatives.
- Parameters:
graph (GraphProtocol) – Mutable graph (NetworkX or GraphProtocol).
services (ServicesProtocol) – ServicesProtocol with field_registry.
context (ContextType) – TickContext or dict with tick and persistent_data.
- Return type:
None
- class babylon.engine.systems.EdgeTransitionSystem[source]
Bases:
SystemBaseEvaluate compound predicates and fire edge mode transitions.
Execution Order: 21 (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.
- step(graph, services, context)[source]
Evaluate predicates and fire edge mode transitions.
- Parameters:
graph (GraphProtocol) – Mutable graph (NetworkX or GraphProtocol).
services (ServicesProtocol) – ServicesProtocol with field_registry.
context (ContextType) – TickContext or dict with tick and persistent_data.
- Return type:
None
Modules
Spec-070 CollapseTransitionSystem (T067 + T084-T087, FR-023, FR-024, FR-027, FR-028). |
|
Community hypergraph system (Feature 022). |
|
Contradiction system — Lawverian opposition registry (Phase C1.3). |
|
ContradictionFieldSystem — System #19 in materialist causality order. |
|
Control ratio system for tracking guard:prisoner dynamics. |
|
Cross-border commute classifier (Spec 063 T080 / T037). |
|
Decomposition system for class breakdown during terminal crisis. |
|
Dispossession Event system (Feature 021, System #10). |
|
Distribution system: Vol III Pt IV-VI surplus split at county scale. |
|
Economic systems: 5-phase Imperial Circuit with pool tracking. |
|
Edge transition system package — Spec 059 US5 / ADR-006.4. |
|
Event Template System - Data-Driven Event Evaluation. |
|
Spec-070 FactionInfluenceSystem (T054, FR-021, FR-022, FR-026, FR-029a/b/c, FR-034). |
|
FieldDerivativeSystem — System #20 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). |
|
Imperial-rent Φ distribution to counties (Spec 062 T058 / FR-034 / FR-035). |
|
ProductionSystem - The Soil. |
|
FascistFactionSystem — the reactionary subject (spec-071). |
|
Reserve Army of Labor system (Feature 021, System #5). |
|
Solidarity system for the Babylon simulation - Proletarian Internationalism. |
|
Spec-070 SovereigntySystem (T042, FR-019, FR-020, FR-035, FR-043). |
|
Struggle system for the Babylon simulation - The Agency Layer. |
|
SubstrateSystem: physical-stock tick at pipeline slot 2.5 (Spec 062, US7). |
|
Survival systems for the Babylon simulation - The Calculus of Living. |
|
Territory systems for the Babylon simulation - Layer 0. |
|
Hex-county-state diagnostics for TerritorySystem (Spec 062 T053). |
|
VitalitySystem - The Drain, The Attrition, and The Reaper. |
|
Vol II Circulation sub-stage (Spec 063 T055 / T018). |