babylon.engine.errors
Transition error types for the simulation engine.
Spec 040, Discipline 2: Closed union of known failure modes.
TransitionError is a union of all modeled failure types that a system
step can produce. These represent expected domain failures — negative capital,
insufficient labor hours, missing organizations — not programmer errors.
Exceptions (assert, KeyError) remain for “this should be unreachable.”
Result[WorldState, TransitionError] for “this is a modeled outcome.”
Module Attributes
Closed union of all modeled transition failures. |
Classes
|
A conservation law was violated (defensive check before invariant harness). |
|
A migration between territories is not possible. |
|
A production plan requires more labor hours than available. |
|
An action references an organization that does not exist in state. |
|
A node's capital stock went negative after a system step. |
- class babylon.engine.errors.NegativeCapitalStock(node_id, field, value)[source]
Bases:
objectA node’s capital stock went negative after a system step.
- Parameters:
- class babylon.engine.errors.InsufficientLaborHours(node_id, required, available)[source]
Bases:
objectA production plan requires more labor hours than available.
- Parameters:
- class babylon.engine.errors.MissingOrganization(org_id)[source]
Bases:
objectAn action references an organization that does not exist in state.
- Parameters:
org_id (
str) – The organization ID that was not found.
- class babylon.engine.errors.InfeasibleMigration(node_id, from_territory, to_territory, reason)[source]
Bases:
objectA migration between territories is not possible.
- Parameters:
- class babylon.engine.errors.ConservationViolation(invariant_name, expected, actual, tolerance)[source]
Bases:
objectA conservation law was violated (defensive check before invariant harness).
- Parameters:
- babylon.engine.errors.TransitionError = babylon.engine.errors.NegativeCapitalStock | babylon.engine.errors.InsufficientLaborHours | babylon.engine.errors.MissingOrganization | babylon.engine.errors.InfeasibleMigration | babylon.engine.errors.ConservationViolation
Closed union of all modeled transition failures.
Systems return
Result[WorldState, TransitionError]to signal expected failures without raising exceptions.