Unified Class System Reference
API reference for the unified class system (Feature 038). Covers configuration, filtration predicates, the unified classifier protocol, rent differential calculation, class-aware inheritance, crisis dispossession, and fractal consistency validation.
ClassSystemDefines
Centralized coefficients for the unified class system. Sub-model of
GameDefines, accessed via GameDefines().class_system.
Defined in ClassSystemDefines.
Field |
Type |
Default |
Description |
|---|---|---|---|
|
float |
0.5 |
Fed SCF / BIA discount on effective wealth for FIRST_NATIONS trust land property. 0.5 = 50% reduction. [0, 1] |
|
float |
0.6 |
Discount on effective wealth for UNDOCUMENTED households. 0.6 = 40% reduction. [0, 1] |
|
float |
0.6 |
Fraction of homeowners with meaningful equity. Calibrated: 65% ownership * 0.6 = 39% ~ 40% LA share. [0, 1] |
|
dict |
(matrix) |
Symmetric 5x5 class-pair base solidarity matrix. 15 unique values (upper triangle including diagonal). All values in [0, 1]. |
Solidarity Matrix Defaults:
From \ To |
BOURG |
PB |
LA |
PROL |
LUMPEN |
|---|---|---|---|---|---|
BOURGEOISIE |
0.70 |
0.30 |
0.10 |
0.00 |
0.00 |
PETIT_BOURGEOISIE |
0.30 |
0.50 |
0.40 |
0.15 |
0.05 |
LABOR_ARISTOCRACY |
0.10 |
0.40 |
0.60 |
0.30 |
0.10 |
PROLETARIAT |
0.00 |
0.15 |
0.30 |
0.80 |
0.50 |
LUMPENPROLETARIAT |
0.00 |
0.05 |
0.10 |
0.50 |
0.60 |
Methods:
def get_base_solidarity(self, class_a: str, class_b: str) -> float
Symmetric lookup into the matrix. Returns 0.0 for unknown pairs.
Filtration Predicates
Community-specific filtration predicates modify classification inputs based on hyperedge memberships (FR-003, FR-004).
Defined in babylon.economics.melt.filtration.
FiltrationResult
Frozen Pydantic model returned by apply_filtration().
Field |
Type |
Default |
Description |
|---|---|---|---|
|
float |
required |
Input wealth percentile before filtration. [0, 100] |
|
float |
required |
Wealth percentile after filtration. [0, 100] |
|
PrecarityStatus |
required |
Input precarity before filtration |
|
PrecarityStatus |
required |
Precarity after filtration |
|
list[str] |
[] |
Names of predicates that fired |
|
CommunityType | None |
None |
Community that produced the most restrictive result |
Validators: effective_wealth_percentile <= original_wealth_percentile.
effective_precarity severity >= original_precarity severity.
apply_filtration
def apply_filtration(
wealth_percentile: float,
precarity: PrecarityStatus,
memberships: list[CommunityMembership],
community_states: dict[str, CommunityState],
defines: ClassSystemDefines | None = None,
) -> FiltrationResult
Evaluates each predicate independently against original inputs. The most restrictive composite result (lowest wealth, highest precarity severity) is used.
Per-predicate formulas:
Community |
Wealth Effect |
Precarity Effect |
|---|---|---|
FIRST_NATIONS |
|
unchanged |
INCARCERATED |
unchanged |
override to EXCLUDED |
UNDOCUMENTED |
|
floor at PRECARIOUS |
DISABLED |
|
unchanged |
Precarity severity ordering: STABLE (0) < PRECARIOUS (1) < MARGINALLY_ATTACHED (2) < EXCLUDED (3).
Composition (FR-004): Multiple predicates evaluate independently; most-restrictive-wins for both wealth and precarity. Result is order-independent.
UnifiedClassifier Protocol
Protocol for unified class position classification. Wraps the
existing DefaultClassPositionClassifier with filtration and
dual-criteria validation.
Defined in babylon.economics.melt.unified_classifier.
classify_with_filtration
def classify_with_filtration(
self,
wealth_percentile: float,
precarity: PrecarityStatus,
memberships: list[CommunityMembership] | None = None,
community_states: dict[str, CommunityState] | None = None,
) -> ClassPosition
Applies filtration predicates to inputs, then delegates to the base wealth-percentile classifier. Without memberships, behaves identically to the existing classifier.
classify_dual_criteria
def classify_dual_criteria(
self,
wealth_percentile: float,
precarity: PrecarityStatus,
v_produced: float,
v_reproduction: float,
memberships: list[CommunityMembership] | None = None,
community_states: dict[str, CommunityState] | None = None,
) -> DualCriteriaResult
Compares wealth-percentile classification against accounting criterion. Returns agreement status and disagreement magnitude for calibration.
DualCriteriaResult
Frozen Pydantic model for dual-criteria validation output.
Field |
Type |
Description |
|---|---|---|
|
ClassPosition |
ClassPosition from wealth percentile criterion |
|
ClassPosition |
ClassPosition from accounting criterion |
|
bool |
True if both criteria produce the same ClassPosition |
|
float |
Disagreement magnitude (0.0 when agrees is True). >= 0.0 |
Validators: agrees must be consistent with wealth_class ==
accounting_class. magnitude must be 0.0 when agrees is True.
Accounting Criterion
Maps the ratio \(R = V_{\text{produced}} / V_{\text{reproduction}}\)
to ClassPosition.
Ratio Range |
ClassPosition |
Interpretation |
|---|---|---|
\(R \geq 1.5\) |
BOURGEOISIE |
Surplus extraction |
\(1.2 \leq R < 1.5\) |
PETIT_BOURGEOISIE |
Simple reproduction with buffer |
\(0.8 \leq R < 1.2\) |
PROLETARIAT |
Simple reproduction |
\(0.5 \leq R < 0.8\) |
PROLETARIAT |
Below reproduction |
\(R < 0.5\) |
LUMPENPROLETARIAT |
Dependent |
When \(V_{\text{reproduction}} \leq 0\), returns BOURGEOISIE (living off capital, no reproduction cost).
Module-level constants: _SURPLUS_THRESHOLD = 1.5,
_SIMPLE_REPRO_UPPER = 1.2, _SIMPLE_REPRO_LOWER = 0.8,
_DEPENDENT_THRESHOLD = 0.5.
Defined in _accounting_criterion() within
babylon.economics.melt.unified_classifier.
Fractal Consistency
Validates that classification produces coherent results across geographic resolutions (FR-009).
Defined in babylon.economics.melt.unified_classifier.
validate_fractal_consistency
def validate_fractal_consistency(
county_distributions: dict[str, dict[ClassPosition, float]],
) -> FractalConsistencyResult
Checks that each county has all five class positions represented and that distributions sum to approximately 1.0. Computes metro-level aggregate as equal-weighted average across counties.
FractalConsistencyResult
Frozen Pydantic model.
Field |
Type |
Description |
|---|---|---|
|
bool |
True if fractal pattern holds across all counties |
|
dict[str, float] |
PROLETARIAT + LUMPEN share per county FIPS |
|
dict[str, set[ClassPosition]] |
Set of ClassPositions present per county FIPS |
|
dict[ClassPosition, float] |
Population-weighted metro-level distribution |
Rent Differential Calculator
Protocol for computing nation-specific imperial rent differentials from ACS earnings data by race x NAICS at county level (FR-007).
Defined in babylon.economics.melt.rent_differential.
RentDifferentialCalculator Protocol
class RentDifferentialCalculator(Protocol):
def compute_differential(
self,
fips: str,
nation: CommunityType,
naics: str,
year: int,
) -> float | NoDataSentinel: ...
def compute_county_aggregate(
self,
fips: str,
nation: CommunityType,
year: int,
) -> float | NoDataSentinel: ...
compute_differential() returns \(\Phi_{\text{diff}} =
W_{\text{settler}} - W_{\text{nation}}\) for a specific
county x nation x NAICS combination. Positive values indicate settler
advantage. SETTLER self-differential returns 0.0.
compute_county_aggregate() returns the employment-weighted average
differential across all NAICS codes for a county-nation pair. QCEW
employment counts provide the weights.
NoDataSentinel propagation: Suppressed ACS data (missing county,
NAICS, or nation earnings) returns NoDataSentinel rather than
imputing values. See NoDataSentinel.
RentDifferentialResult
Frozen Pydantic model for aggregate results.
Field |
Type |
Description |
|---|---|---|
|
str |
5-digit FIPS code (length 5) |
|
CommunityType |
Target nation |
|
int |
Calendar year [2000, 2100] |
|
float |
Employment-weighted average differential ($/year) |
|
int |
Number of NAICS codes with valid data (>= 0) |
|
int |
Number of NAICS codes with suppressed data (>= 0) |
Validators: naics_count + suppressed_count > 0.
Class-Aware Inheritance
Extension to the existing InheritanceCalculator protocol
(Feature 030) that scales inheritance by class position.
Defined in babylon.economics.lifecycle.inheritance.
compute_class_aware_inheritance
def compute_class_aware_inheritance(
self,
dpd_state: DPDState,
class_position: ClassPosition,
pareto_alpha: float,
care_cost_fraction: float,
*,
foreclosed: bool = False,
) -> InheritanceFlow | None
Computes inheritance flow scaled by class position. Returns None
if no D’ deaths occurred in this tick.
Class inheritance scale factors:
ClassPosition |
Scale |
Rationale |
|---|---|---|
BOURGEOISIE |
1.0 |
Full estate transfer |
PETIT_BOURGEOISIE |
0.7 |
Business capital transfer |
LABOR_ARISTOCRACY |
0.5 |
Home equity (primary vehicle) |
PROLETARIAT |
0.05 |
Minimal (consumed by reproduction) |
LUMPENPROLETARIAT |
0.0 |
No inheritable wealth |
Foreclosure behavior: When foreclosed=True, net inheritance is
zero regardless of class position. care_consumed absorbs the full
total_transferred amount. The inheritance mechanism is severed.
Crisis Dispossession
Models crisis-driven wealth destruction events (foreclosure, eviction) with community-modifiable targeting (FR-010).
Defined in babylon.economics.lifecycle.dispossession.
compute_crisis_dispossession
def compute_crisis_dispossession(
household_wealth: float,
foreclosure_rate: float,
community_targeting_multiplier: float = 1.0,
) -> DispossessionResult
Computes wealth destruction from a crisis event.
Formulas:
Class position change is indicated when \(W_{\text{remaining}} < 0.5 \times W\) (household lost more than half its wealth).
DispossessionResult
Frozen Pydantic model.
Field |
Type |
Description |
|---|---|---|
|
float |
Original household wealth (>= 0) |
|
float |
Base foreclosure rate [0, 1] |
|
float |
Actual rate after targeting multiplier [0, 1] |
|
float |
Amount destroyed by crisis (>= 0) |
|
float |
Wealth after dispossession (>= 0) |
|
bool |
True if remaining < 50% of original |
Validators: wealth_destroyed + remaining_wealth ==
household_wealth (tolerance 0.01). Wealth conservation invariant.
Module Structure
Module |
Public Exports |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
See Also
Unified Class System — Theoretical foundations and rationale
Community System Reference — Solidarity potential formula and community system API
Lifecycle System Reference — D-P-D’ lifecycle reference
Economics Pipeline Reference (Features 012–016) — Economics pipeline data types and formulas
Configuration System — GameDefines parameter tables