Event System Reference
This reference documents the typed event system that enables the AI narrative layer to observe simulation state changes. For conceptual background, see Event System Architecture.
Overview
The simulation emits typed Pydantic events during each tick. Events are
captured by the EventBus, converted to typed models, and persisted
in WorldState.events. This enables:
AI narrative generation from structured data
Event-driven analysis and visualization
Replay and counterfactual scenarios
Key Components:
babylon.models.events- Pydantic event models (20+ classes)babylon.models.enums- EventType enum (24 types)babylon.engine.event_bus- Pub/sub event busbabylon.engine.simulation_engine- Event conversion
EventType Enum
All events are categorized by type. The EventType enum defines 24
distinct event types organized by category:
Economic Events:
EventType |
Description |
|---|---|
|
Imperial rent extracted from worker via EXPLOITATION edge |
|
Subsidy paid to comprador state (converts to repression) |
|
Pool depleted below critical threshold, triggers crisis response |
|
Core cannot afford super-wages (triggers LA decomposition) |
|
Periphery severs EXPLOITATION edges when P(S|R) > P(S|A) |
Consciousness Events:
EventType |
Description |
|---|---|
|
Consciousness flows via SOLIDARITY edge |
|
Class consciousness crosses threshold |
|
Entity enters active struggle (deprecated, use MASS_AWAKENING) |
Struggle Events (George Floyd Dynamic):
EventType |
Description |
|---|---|
|
State violence spark event (stochastic police brutality) |
|
Mass insurrection triggered by spark + agitation |
|
Solidarity infrastructure built through shared struggle |
|
Comprador insolvency triggers George Jackson bifurcation |
|
Organized labor seizes opportunity during power vacuum |
|
Core workers react with nationalism during power vacuum |
Vitality Events:
EventType |
Description |
|---|---|
|
Entity starved (wealth < consumption_needs) |
|
Probabilistic mortality from inequality |
|
Grinding Attrition deaths from coverage deficit |
Terminal Crisis Events:
EventType |
Description |
|---|---|
|
Labor aristocracy splits into enforcers + internal proletariat |
|
Prisoners exceed guard capacity (ratio inverted) |
|
System bifurcates to revolution or genocide |
Topology Events:
EventType |
Description |
|---|---|
|
Contradiction tension reached 1.0 |
|
Percolation threshold crossed (gaseous/transitional/liquid/solid) |
Metabolism Events:
EventType |
Description |
|---|---|
|
Consumption exceeds biocapacity (O > 1.0) |
Endgame Events:
EventType |
Description |
|---|---|
|
Game-ending condition met (victory, collapse, or fascism) |
Event Class Hierarchy
Events form a type hierarchy with shared base classes:
classDiagram
SimulationEvent <|-- EconomicEvent
SimulationEvent <|-- SuperwageCrisisEvent
SimulationEvent <|-- ClassDecompositionEvent
SimulationEvent <|-- ControlRatioCrisisEvent
SimulationEvent <|-- TerminalDecisionEvent
SimulationEvent <|-- ConsciousnessEvent
SimulationEvent <|-- StruggleEvent
SimulationEvent <|-- ContradictionEvent
SimulationEvent <|-- TopologyEvent
SimulationEvent <|-- EndgameEvent
EconomicEvent <|-- ExtractionEvent
EconomicEvent <|-- SubsidyEvent
EconomicEvent <|-- CrisisEvent
ConsciousnessEvent <|-- TransmissionEvent
ConsciousnessEvent <|-- MassAwakeningEvent
StruggleEvent <|-- SparkEvent
StruggleEvent <|-- UprisingEvent
StruggleEvent <|-- SolidaritySpikeEvent
ContradictionEvent <|-- RuptureEvent
TopologyEvent <|-- PhaseTransitionEvent
class SimulationEvent {
<<frozen>>
+tick: int
+timestamp: datetime
}
class EconomicEvent {
+amount: Currency
}
class ConsciousnessEvent {
+target_id: str
}
class StruggleEvent {
+node_id: str
}
class ContradictionEvent {
+edge: str
}
class TopologyEvent {
+percolation_ratio: float
+num_components: int
}
Base Event Model
SimulationEvent
All events inherit from SimulationEvent:
Field |
Type |
Description |
|---|---|---|
|
|
Discriminator for event category |
|
|
Simulation tick when event occurred |
|
|
Optional wall-clock time |
Model Configuration:
frozen=True: Events are immutable after creationextra="forbid": No additional fields allowed
Economic Events
Events related to value extraction and imperial rent dynamics.
EconomicEvent (Base)
Field |
Type |
Description |
|---|---|---|
|
|
Value transferred in this event |
ExtractionEvent
Emitted when imperial rent is extracted via EXPLOITATION edge.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Worker node ID (extracted from) |
|
|
Owner node ID (extracted to) |
|
|
Amount of rent extracted |
|
|
Extraction mechanism (default: “imperial_rent”) |
SubsidyEvent
Emitted when imperial subsidy is paid via CLIENT_STATE edge.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Core bourgeoisie node ID |
|
|
Comprador state node ID |
|
|
Subsidy amount |
|
|
Increase to target’s repression capacity |
CrisisEvent
Emitted when economic crisis conditions are detected.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Current imperial rent pool ratio |
|
|
Total system tension |
|
|
Bourgeoisie response (e.g., “AUSTERITY”) |
|
|
Change in wage rates |
Terminal Crisis Events
Events from the Carceral Equilibrium (Terminal Crisis Dynamics).
SuperwageCrisisEvent
Emitted when the imperial rent pool cannot pay super-wages.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Core bourgeoisie who can’t pay |
|
|
Labor aristocracy not receiving wages |
|
|
Amount of wages that were needed |
|
|
Amount available (zero or negative) |
ClassDecompositionEvent
Emitted when Labor Aristocracy splits into two fractions.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Labor aristocracy entity that split |
|
|
Fraction that became enforcers (default 0.15) |
|
|
Fraction that became internal proletariat (0.85) |
ControlRatioCrisisEvent
Emitted when prisoners exceed guard control capacity.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Size of prisoner/surplus population |
|
|
Size of enforcer/guard population |
|
|
Prisoners per enforcer |
|
|
Maximum ratio enforcers can handle |
TerminalDecisionEvent
Emitted when system bifurcates to final outcome.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Either “revolution” or “genocide” |
|
|
Average organization level of prisoners |
|
|
Threshold above which revolution occurs |
Consciousness Events
Events related to ideology drift and consciousness transmission.
ConsciousnessEvent (Base)
Field |
Type |
Description |
|---|---|---|
|
|
Node whose consciousness is affected |
TransmissionEvent
Emitted when consciousness is transmitted via SOLIDARITY edge.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Transmitting node ID |
|
|
Receiving node ID |
|
|
Consciousness change magnitude |
|
|
Edge strength facilitating transmission |
MassAwakeningEvent
Emitted when a node’s consciousness crosses the awakening threshold.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Awakened node ID |
|
|
Consciousness before awakening |
|
|
Consciousness after awakening |
|
|
Node that triggered awakening |
Struggle Events
Events related to the Agency Layer (George Floyd Dynamic).
StruggleEvent (Base)
Field |
Type |
Description |
|---|---|---|
|
|
Node where struggle occurs |
SparkEvent
Emitted when EXCESSIVE_FORCE event occurs (stochastic police brutality).
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Target of state violence |
|
|
Repression level at node |
|
|
Probability that triggered event |
UprisingEvent
Emitted when conditions trigger revolt.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Node where uprising occurs |
|
|
What triggered uprising (e.g., “spark”, “p_rev”) |
|
|
Agitation level at trigger |
|
|
Repression level at trigger |
SolidaritySpikeEvent
Emitted when solidarity infrastructure is built during uprising.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Node gaining solidarity |
|
|
Amount of solidarity added |
|
|
Number of edges strengthened |
|
|
Cause (e.g., “uprising”) |
Vitality Events
Events from the VitalitySystem (mortality and extinction).
Note
These events currently have EventType enum values but no dedicated Pydantic model classes. They are emitted as raw Event objects.
ENTITY_DEATH:
Emitted when an entity is fully extinct (population = 0 or starvation).
Payload fields: entity_id, wealth, consumption_needs, s_bio,
s_class, cause (“extinction”, “starvation”, or “wealth_threshold”)
POPULATION_ATTRITION:
Emitted when deaths occur from coverage deficit (Grinding Attrition phase).
Payload fields: entity_id, deaths, remaining_population, attrition_rate
POPULATION_DEATH:
Emitted for probabilistic mortality from inequality (deprecated, use POPULATION_ATTRITION).
Contradiction Events
Events related to tension accumulation and rupture.
ContradictionEvent (Base)
Field |
Type |
Description |
|---|---|---|
|
|
Edge identifier (format: “source->target”) |
RuptureEvent
Emitted when tension on an edge reaches 1.0.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Edge that ruptured |
Topology Events
Events related to network structure and phase transitions.
TopologyEvent (Base)
Field |
Type |
Description |
|---|---|---|
|
|
L_max / total_nodes |
|
|
Number of disconnected components |
PhaseTransitionEvent
Emitted when percolation ratio crosses a threshold boundary.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
Previous phase (“gaseous”, “transitional”, “liquid”, “solid”) |
|
|
New phase after transition |
|
|
Size of giant component (L_max) |
|
|
Ratio of cadre to sympathizers [0, 1] |
|
|
Resilience test result (if available) |
4-Phase State Model:
State |
Threshold |
Meaning |
|---|---|---|
Gaseous |
|
Atomized, no coordination capacity |
Transitional |
|
Emerging structure, unstable |
Liquid |
|
Mass movement (weak ties) |
Solid |
|
Vanguard party (strong ties) |
Metabolism Events
Events from the MetabolismSystem (ecological overshoot).
ECOLOGICAL_OVERSHOOT:
Emitted when consumption exceeds biocapacity (overshoot ratio > 1.0).
Payload fields: overshoot_ratio, total_consumption, total_biocapacity
Endgame Events
Events signaling game-ending conditions.
EndgameEvent
Emitted when a game-ending condition is met.
Field |
Type |
Description |
|---|---|---|
|
|
Always |
|
|
The outcome that ended the simulation |
GameOutcome Values:
REVOLUTIONARY_VICTORY: Proletarian revolution succeededECOLOGICAL_COLLAPSE: Metabolic rift has become fatalFASCIST_CONSOLIDATION: Fascism has consolidated powerIN_PROGRESS: Simulation still running (not an endgame)
Event Lifecycle
Events flow through the system in this sequence:
Emission: Systems call
event_bus.publish(type, tick, payload)Collection:
EventBus.get_history()returns all events for tickConversion:
_convert_bus_event_to_pydantic()creates typed modelsPersistence: Events appended to
WorldState.eventsObservation: AI/narrative layer reads typed events
Observer Events (Sprint 3.3):
Observers like TopologyMonitor emit events after the tick completes.
These are collected via get_pending_events() and injected into the
next tick’s WorldState.events via persistent_context['_observer_events'].
Factory Methods
The DomainFactory provides factory methods for creating events in tests:
from tests.factories.domain import DomainFactory
factory = DomainFactory()
# Create events
extraction = factory.create_extraction_event(tick=1, amount=0.1)
subsidy = factory.create_subsidy_event(tick=1, amount=0.05)
transmission = factory.create_transmission_event(tick=1, delta=0.1)
spark = factory.create_spark_event(tick=1, repression=0.8)
uprising = factory.create_uprising_event(tick=1, agitation=0.7)
phase = factory.create_phase_transition_event(
tick=1,
previous_state="gaseous",
new_state="liquid",
)
Assertions
The BabylonAssert class provides semantic assertions for events:
from tests.assertions import Assert
from babylon.models.events import ExtractionEvent
# Assert event exists
Assert(world_state).has_event(ExtractionEvent)
# Assert event with specific fields
Assert(world_state).has_event(
ExtractionEvent,
source_id="C001",
target_id="C002",
)
# Assert event count
Assert(world_state).has_events_count(3)
# Assert amount condition
Assert(world_state).has_event(ExtractionEvent, amount_gt=0.0)
See Also
Event System Architecture - Conceptual explanation of event architecture
Topology System Reference - TopologyMonitor and phase transitions
Simulation Systems Reference - Systems that emit events
babylon.engine.event_bus- Event bus implementation