babylon.engine.field_registry

Field registry for extensible contradiction fields.

Dialectical Field Topology (Feature 002): The field registry provides a mapping from field names to computation + normalization callables. Core computation logic (gradient, Laplacian, derivatives, principal contradiction) iterates over registered field names without hardcoding any.

Reference: FR-001 (extensible field set, field-name-agnostic core computation) Reference: R-003 (contradiction field storage architecture) Reference: R-007 (domain-specific normalization)

Functions

compute_displacement(node_attributes)

Compute displacement field from population change rate.

compute_exploitation(node_attributes)

Compute exploitation field from wealth deficit relative to subsistence.

compute_immiseration(node_attributes)

Compute immiseration field from wealth decline rate.

compute_imperial_rent(node_attributes)

Compute imperial rent field from unearned increment.

Classes

DefaultFieldRegistry()

Concrete implementation of FieldRegistryProtocol.

FieldRegistryProtocol(*args, **kwargs)

Protocol for the open field registry.

class babylon.engine.field_registry.FieldRegistryProtocol(*args, **kwargs)[source]

Bases: Protocol

Protocol for the open field registry.

The registry maps field names to computation + normalization callables. Core computation logic MUST be field-name-agnostic.

register(name, computation, normalization)[source]

Register a new contradiction field.

Parameters:
  • name (str) – Field identifier (e.g., “exploitation”, “immiseration”).

  • computation (Callable[[dict[str, Any]], float]) – Callable that extracts raw value from node attributes.

  • normalization (Callable[[float], float]) – Callable that maps raw value to [0.0, 10.0].

Raises:

ValueError – If name is already registered.

Return type:

None

get_field_names()[source]

Return all registered field names in registration order.

Return type:

list[str]

compute(name, node_attributes)[source]

Compute raw field value for a named field.

Parameters:
  • name (str) – Registered field name.

  • node_attributes (dict[str, Any]) – Node attributes dict.

Return type:

float

Returns:

Raw field value.

Raises:

KeyError – If name is not registered.

normalize(name, raw_value)[source]

Normalize a raw field value using the field’s normalization function.

Parameters:
  • name (str) – Registered field name.

  • raw_value (float) – Raw value to normalize.

Return type:

float

Returns:

Normalized value in [0.0, 10.0].

Raises:

KeyError – If name is not registered.

__init__(*args, **kwargs)
babylon.engine.field_registry.compute_exploitation(node_attributes)[source]

Compute exploitation field from wealth deficit relative to subsistence.

When wealth < subsistence, the worker is being exploited: the surplus value they produce exceeds what they receive. The ratio (subsistence - wealth) / subsistence captures this deficit as a fraction.

Parameters:

node_attributes (dict[str, Any]) – Node attributes dict with wealth, s_bio, s_class.

Return type:

float

Returns:

Raw exploitation value >= 0.0. Higher means more exploited.

babylon.engine.field_registry.compute_immiseration(node_attributes)[source]

Compute immiseration field from wealth decline rate.

Immiseration captures the rate at which material conditions are worsening. Requires _previous_wealth injected from persistent_data.

Parameters:

node_attributes (dict[str, Any]) – Node attributes dict with wealth, _previous_wealth.

Return type:

float

Returns:

Raw immiseration value >= 0.0. Higher means faster decline.

babylon.engine.field_registry.compute_imperial_rent(node_attributes)[source]

Compute imperial rent field from unearned increment.

The unearned_increment attribute represents the PPP bonus that forms the material basis of labor aristocracy — wealth received not from own labor but from imperial extraction.

Parameters:

node_attributes (dict[str, Any]) – Node attributes dict with unearned_increment.

Return type:

float

Returns:

Raw imperial rent value >= 0.0.

babylon.engine.field_registry.compute_displacement(node_attributes)[source]

Compute displacement field from population change rate.

Displacement captures forced population movement — evictions, gentrification, carceral removal. Requires _previous_population injected from persistent_data.

Parameters:

node_attributes (dict[str, Any]) – Node attributes dict with population, _previous_population.

Return type:

float

Returns:

Raw displacement value. Positive = population loss (displacement).

class babylon.engine.field_registry.DefaultFieldRegistry[source]

Bases: object

Concrete implementation of FieldRegistryProtocol.

Maintains an ordered mapping of field names to (computation, normalization) callables. Registration order is preserved for deterministic iteration.

__init__()[source]
Return type:

None

register(name, computation, normalization)[source]

Register a new contradiction field.

Parameters:
  • name (str) – Field identifier.

  • computation (Callable[[dict[str, Any]], float]) – Callable that extracts raw value from node attributes.

  • normalization (Callable[[float], float]) – Callable that maps raw value to [0.0, 10.0].

Raises:

ValueError – If name is already registered.

Return type:

None

get_field_names()[source]

Return all registered field names in registration order.

Return type:

list[str]

compute(name, node_attributes)[source]

Compute raw field value for a named field.

Parameters:
  • name (str) – Registered field name.

  • node_attributes (dict[str, Any]) – Node attributes dict.

Return type:

float

Returns:

Raw field value.

Raises:

KeyError – If name is not registered.

normalize(name, raw_value)[source]

Normalize a raw field value.

Parameters:
  • name (str) – Registered field name.

  • raw_value (float) – Raw value to normalize.

Return type:

float

Returns:

Normalized value in [0.0, 10.0].

Raises:

KeyError – If name is not registered.

classmethod with_defaults()[source]

Factory that creates a registry with the four default fields.

Default fields:
  • exploitation: Wealth deficit relative to subsistence

  • immiseration: Wealth decline rate

  • imperial_rent: Unearned increment (PPP bonus)

  • displacement: Population change rate

Return type:

DefaultFieldRegistry

Returns:

DefaultFieldRegistry with four fields registered.