babylon.engine.dialectics.world

World, Morphism, and WorldEvent — the v2 dialectical graph.

Replaces the Embedded Trinity (Ledger / Topology / Archive) with a single coherent structure. The graph isn’t separate from the dialectics — it’s how they’re wired into the tick engine’s data flow.

A morphism feeds(d1, d2) means d2.step() reads from d1.observe(). A morphism contains(d1, d2) means d1 is one of d2’s poles (nesting).

See also

babylon.engine.dialectics.base.Dialectic: The fundamental type. babylon.engine.dialectics.tick: The pure tick function.

Classes

Morphism(**data)

A typed relationship between two dialectics.

World(**data)

The complete world state at a given tick.

WorldEvent(**data)

An event generated during a tick.

class babylon.engine.dialectics.world.Morphism(**data)[source]

Bases: BaseModel

A typed relationship between two dialectics.

The five canonical relation types:

  • feeds: d2.step() reads from d1.observe()

  • constrains: d1 limits d2’s state space

  • transforms: d1’s output becomes d2’s input prices

  • contains: d1 is one of d2’s poles (nesting)

  • antagonizes: d1 and d2 are mutually antagonistic

Parameters:
id

Unique identifier for this morphism.

source_id

UUID of the source dialectic.

target_id

UUID of the target dialectic.

relation

Relationship type string.

weight

Coupling strength.

metadata

Optional additional data for the relationship.

tick_created

Tick when this morphism was created.

tick_destroyed

Tick when this morphism was destroyed (None if live).

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: UUID
source_id: UUID
target_id: UUID
relation: str
weight: float
metadata: dict[str, Any]
tick_created: int
tick_destroyed: int | None
class babylon.engine.dialectics.world.WorldEvent(**data)[source]

Bases: BaseModel

An event generated during a tick.

Events include sublations, crises, ruptures, and player actions. The narrative field is populated by the LLM layer (optional).

Parameters:
id

Auto-incrementing identifier.

event_type

Type of event (sublation, crisis, rupture, player_action).

dialectic_id

UUID of the dialectic that generated this event.

payload

Arbitrary data associated with the event.

narrative

LLM-generated prose description (optional).

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

event_type: str
dialectic_id: UUID | None
payload: dict[str, Any]
narrative: str | None
class babylon.engine.dialectics.world.World(**data)[source]

Bases: BaseModel

The complete world state at a given tick.

This is the single structure that replaces the Embedded Trinity (Ledger / Topology / Archive). It holds all dialectics, their morphism wiring, and events generated during the current tick.

Parameters:
tick

Current simulation tick.

dialectics

Map of UUID to Dialectic instance.

morphisms

List of Morphism edges wiring the dialectical graph.

events

List of WorldEvent records for this tick.

sublated_ids

Set of dialectic IDs that have been sublated (replaced by successors). These are excluded from live queries.

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

tick: int
dialectics: dict[UUID, Any]
morphisms: list[Morphism]
events: list[WorldEvent]
sublated_ids: frozenset[UUID]
get_by_type(type_tag)[source]

Filter dialectics by their type_tag.

Parameters:

type_tag (str) – The type discriminator to filter by.

Return type:

dict[UUID, Any]

Returns:

Dict of UUID → Dialectic matching the given type_tag.

get_inputs_for(target_id)[source]

Compute TickInputs for a target dialectic from morphism graph.

Collects observe() output from all source dialectics that have a feeds morphism targeting target_id.

Parameters:

target_id (UUID) – UUID of the dialectic receiving inputs.

Return type:

TickInputs

Returns:

TickInputs with upstream observations populated.

get_one_or_none(type_tag)[source]

Return a single dialectic matching the given type_tag, or None.

This is the defensive accessor for cyclical composition. When a dialectic needs to read state from a peer that may or may not exist (e.g. ConsumptionDialectic reading ProductionDialectic), it uses get_one_or_none instead of assuming the peer is present.

If multiple dialectics of the same type exist, returns the first found (iteration order).

Parameters:

type_tag (str) – The type discriminator to search for.

Return type:

Any | None

Returns:

The first matching Dialectic, or None if none exist.

get_live_dialectics()[source]

Return all dialectics that have not been sublated.

Sublated dialectics are preserved in the dialectics dict for history, but excluded from live queries.

Return type:

dict[UUID, Any]

Returns:

Dict of UUID → Dialectic for all non-sublated instances.