Fundamental Tensor Primitive Reference
Technical reference for the ValueTensor4x3 — the single source of truth for all economic data in the Babylon simulation. All values are measured in labor-hours, not monetary units. The tensor layer is the only component that queries the database for economic data.
Core Data Types
NoDataSentinel
Non-instantiable falsy marker for missing tensor data. Enables the walrus operator pattern:
if tensor := registry.get("26163", 2020):
print(tensor.exploitation_rate)
else:
print(tensor.reason) # "FIPS code not in database"
Field |
Type |
Description |
|---|---|---|
|
|
5-digit county FIPS code |
|
|
Calendar year |
|
|
Human-readable error (format: |
bool(sentinel) returns False. Implements __eq__ and
__hash__ for use in dicts and sets.
DepartmentRow
Value composition for a single Marxian department. Frozen Pydantic
model with three non-negative LaborHours fields.
Field |
Type |
Description |
|---|---|---|
|
|
Constant capital (dead labor / means of production consumed) |
|
|
Variable capital (living labor / wages paid) |
|
|
Surplus value (unpaid labor appropriated by capital) |
Computed properties:
Property |
Formula |
Note |
|---|---|---|
|
c + v + s |
Total commodity value |
|
c / v |
Capital intensity ( |
|
s / v |
Unpaid labor ratio ( |
ValueTensor4x3
The fundamental 4×3 Marxian reproduction schema for a county-year.
Frozen Pydantic model with index structure
T^μ_ν[fips, year] where μ ∈ {I, IIa, IIb, III}
and ν ∈ {c, v, s}.
Field |
Type |
Description |
|---|---|---|
|
|
County FIPS code (regex validated) |
|
|
Calendar year |
|
|
Means of production (capital goods) |
|
|
Necessary consumption (wage goods) |
|
|
Luxury consumption (bourgeois goods) |
|
|
Social reproduction (care work) |
|
|
Data quality: fraction of wages with 6-digit NAICS |
|
|
Government/excluded sector wages (outside M-C-M’) |
|
|
Visibility of care work to price system (Fortunati) |
Departments
Code |
Name |
Description |
|---|---|---|
I |
Means of Production |
Capital goods: machinery, raw materials, infrastructure |
IIa |
Necessary Consumption |
Wage goods: food, housing, transport for workers |
IIb |
Luxury Consumption |
Bourgeois goods: luxury housing, yachts, art |
III |
Social Reproduction |
Care work: childcare, cooking, eldercare, emotional labor |
Computed Metrics
Aggregate Metrics
Property |
Formula |
Description |
|---|---|---|
|
Σ dept.total_value |
Total commodity value across all departments |
|
Σ dept.c |
Total constant capital |
|
Σ dept.v |
Total variable capital (total wages in labor-hours) |
|
Σ dept.s |
Total surplus value |
Rate Metrics
Property |
Formula |
Description |
|---|---|---|
|
s / (c + v) |
Economy-wide return on capital (r) |
|
s / v |
Rate of surplus value extraction (e) |
|
c / v |
Capital intensity (OCC) |
Imperial Rent
Positive Φ: core territory receives imperial rent (labor aristocracy). Negative Φ: periphery territory donates value.
Fortunati Visibility Metrics
The visibility scalar g₃₃ controls what fraction of Department III (reproductive labor) the price system recognizes:
Property |
Formula |
Description |
|---|---|---|
|
Σ(I,IIa,IIb) + III × g₃₃ |
Value visible to price system |
|
Σ(I,IIa,IIb).v + III.v × g₃₃ |
Wages actually paid |
|
III.v × (1 − g₃₃) |
Unpaid reproductive labor |
|
(s + shadow) / monetized_v |
True exploitation including care work |
When g₃₃ = 1.0, all care work is monetized (no shadow subsidy). When g₃₃ = 0.0, all care work is invisible (maximum shadow extraction).
Tensor Registry
babylon.economics.tensor_registry.TensorRegistry is the
cache and aggregation layer that provides tensor access to the
simulation engine.
Access Methods
Method |
Description |
|---|---|
|
County tensor (cache hit, no DB). Returns NoDataSentinel if missing. |
|
Aggregated tensor (lazy compute, LRU cached) |
|
Store tensor, invalidate aggregate cache |
|
Mark (fips, year) as explicitly missing |
|
Bulk load via external hydrator |
|
frozenset of cached FIPS codes |
|
frozenset of years for a county |
Geographic Aggregation
Level |
Code Format |
Description |
|---|---|---|
COUNTY |
5-digit FIPS |
Individual county (direct cache lookup) |
STATE |
2-digit FIPS |
Sum all counties with matching state prefix |
NATION |
|
Sum all available counties |
Aggregation sums department values. naics_granularity and
visibility_g33 are weighted averages by total_value.
Performance
Operation |
Target |
Note |
|---|---|---|
|
< 1ms p95 |
Direct dict lookup |
|
< 1ms p95 |
LRU cache hit |
|
< 100ms p95 |
Computed, then cached |
Peak RSS (full US) |
< 500MB |
LRU eviction at threshold |
Thread-safe via RLock on both county and aggregate caches.
Hydration Pipeline
babylon.economics.hydrator.MarxianHydrator transforms
raw QCEW wage data into ValueTensor4x3 using BEA ratios and
department mappings.
Pipeline Steps
Fetch QCEW records:
[(naics_code, total_wages, employment)]viaQCEWDataSource.fetch_county_wages(fips, year)Get SNLT factor: Year-specific conversion factor (default 1.0 = wage-proportional proxy)
Allocate to departments:
DepartmentMapper.allocate_batch()distributes wages across I/IIa/IIb/III by NAICS-to-department weights. Excluded sectors (NAICS 92 = government) tracked asexcluded_wages.Apply BEA ratios per department:
\[s = v \times \frac{s}{v}_{\text{ratio}} \qquad c = v \times \frac{c}{v}_{\text{ratio}}\]Convert to labor-hours: Multiply by SNLT factor
Compute naics_granularity: (6-digit wages) / (allocated wages)
Return frozen ValueTensor4x3
Ratio Lookup Hierarchy
For both s/v and c/v ratios, the system tries three sources (most specific first):
BEA source — empirical industry-level data from
fact_bea_national_industrywith temporal interpolation (nearest year within ±5 years)Sector YAML — 2-digit NAICS ratios from
naics_to_dept.yamlDepartment default — fallback per department (e.g., Dept I default c/v = 2.0, s/v = 1.5)
SNLT Configuration
babylon.economics.snlt.SNLTConfig provides year-specific
labor-hour conversion factors.
Factor |
Meaning |
|---|---|
1.0 |
Wage-proportional proxy (derived ratios exact, magnitudes uncalibrated) |
< 1.0 |
Higher productivity (fewer labor-hours per dollar) |
> 1.0 |
Lower productivity (more labor-hours per dollar) |
Until SNLT calibration is complete, the default factor of 1.0 means tensor values are wage-proportional labor-time proxies. All derived ratios (r, e, OCC) are exact; absolute magnitudes require SNLT calibration.
Department Mapping
babylon.economics.department_mapper.DepartmentMapper
maps NAICS codes to departments with allocation weights.
NAICS lookup hierarchy (most specific first):
6-digit override (e.g.,
325110→ specific chemical)5, 4, 3-digit overrides
2-digit sector default (e.g.,
44→ Retail)Excluded set (NAICS
92= government, outside M-C-M’)
Allocation weights sum to 1.0 per NAICS code. Example:
Agriculture (
11): 62% Dept I, 33% Dept IIa, 5% Dept IIbWholesale (
42): 85% Dept I, 15% Dept IIaRetail (
44): 72% Dept IIa, 28% Dept IIb
Configured via naics_to_dept.yaml.
Data Source Protocols
Protocol |
Method |
|---|---|
|
|
|
|
|
|
Implementations:
SQLiteQCEWSource: Queriesfact_qcew_annualvia 3NF joinsInterpolatingBEASource: Queriesfact_bea_national_industrywith linear temporal interpolation (±5 years)
See Also
The Marxian Value Tensor: Labor-Hours, Not Dollars — Theoretical exposition of the Marxian value tensor
Formulas Reference — Complete formula reference
Capital Volume I Production Dynamics Reference — How Volume I mechanisms modify tensor values
Data Models Reference — Full data model reference