Stock-Flow Consistent Agent-Based Macroeconomic Engine
Ducunt volentem fata, nolentem trahunt.
The fates lead the willing; they drag the unwilling.
— Cleanthes, quoted by Seneca, Epistulae Morales 107.11
| CI | Coverage | Generated outputs | CLA |
|---|---|---|---|
| Exact SFC identities | Verified ledger | Empirical validation |
|---|---|---|
| Diagnostics smoke | Diagnostics nightly | Diagnostics extended |
|---|---|---|
| Profiling smoke | Profiling nightly | Profiling extended |
|---|---|---|
A ledger-first SFC-ABM of the Polish economy where every monetary flow is accounted for. Firms produce, households consume, banks lend, the central bank sets policy, the government taxes and spends, the external sector trades and moves capital — and the books must balance. Always.
Amor Fati is a stock-flow consistent (SFC) agent-based model (ABM) that simulates the Polish economy at the level of individual households, heterogeneous firms, and a ten-row banking-sector archetype system. The engine enforces 15 exact accounting identities each month — if a single zloty goes missing, the simulation fails.
The key design principle is simple:
Macro stories can be wrong. The ledger cannot.
This engine is built on top of the separately verified amor-fati-ledger flow interpreter, checked out as a Git submodule under modules/ledger. The practical consequence is that the strongest invariant in the entire project is not "inflation should look smooth" or "GDP should converge nicely after 10 years". It is this:
The books must balance to the end of the universe.
That is the hard floor under every experiment in the model. Behavioral rules, policy heuristics, and long-horizon dynamics can be revised, recalibrated, or replaced. The accounting layer cannot silently drift.
- Why
- What Is Technically Distinctive
- Core Invariants
- State Ontology
- Verified Ledger
- Documentation
- Ledger-Derived Matrix Artifacts
Standard macro models (DSGE) assume representative agents and rational expectations. Reality has neither. Amor Fati models the economy from the bottom up: thousands of heterogeneous agents making bounded decisions, interacting through markets, generating emergent macro dynamics.
Counterfactual analysis through code. Want to test a policy hypothesis? Fork the repo, modify the mechanism, run the simulation, compare. The model is the experiment.
Amor Fati is not just an ABM with accounting checks bolted on afterwards. The project combines several layers that are rarely pushed into one executable research engine:
- heterodox macroeconomics and SFC discipline
- heterogeneous-agent ABM microstructure
- a runtime ledger execution layer backed by formal verification work
- a data-oriented mutable execution substrate for performance
- explicit state ontology separating behavioral state, macro state, and financial state
The result is a model where macro dynamics, institutional behavior, and monetary plumbing are all first-class parts of the implementation rather than separate narratives.
The project is built around a few non-negotiable invariants:
- executed financial flows must conserve value exactly at runtime
- SFC validation must preserve 15 exact semantic accounting identities
- financial execution must not depend on ad hoc mutable bookkeeping outside the ledger path
- behavioral rules may change, but accounting consistency must remain hard-constrained
This is the core philosophy of the engine: theories may evolve, but broken plumbing is not an acceptable macro result.
Amor Fati uses a hybrid runtime ontology rather than a single undifferentiated world object:
- behavioral populations
- households, firms, and banks carry heterogeneous agent state and decision logic
- macro and market state
- prices, policy, external conditions, and inter-step signals live in the macro runtime layer
- ledger-owned financial state
- supported financial balances are kept in an accounting-controlled stock layer and projected into runtime execution and validation
This split is intentional. It keeps rich agent behavior where object-level modeling is useful, while moving accounting-critical execution into a stricter ledger substrate.
Most macro models treat accounting consistency as a secondary validation step. Amor Fati does not.
The simulation pipeline is anchored to the verified amor-fati-ledger layer that enforces the project’s stock-flow constraints at runtime. In other words:
- macro behavior is experimental
- agent rules are revisable
- accounting identities are non-negotiable
This is why Amor Fati is useful even when the long-run path is still being calibrated. If a branch generates a bad macro regime, that may be a modeling problem. If the ledger breaks, the simulation itself is wrong.
That distinction matters. A nonlinear ABM can explore unstable, surprising, even pathological futures. But it should never "lose money" in the plumbing.
Start with the model card for intended use, evidence status, and limitations; continue with the model specification for scientific review, the SFC + ABM reading map if the combined modeling tradition is new to you, or the architecture documentation for code-facing orientation. For the complete documentation index, use docs/README.md:
| Step | Entry point | Boundary |
|---|---|---|
| 0. Scope and limitations | Model card | Intended use, uses outside scope, evidence status, known limitations, reproducibility, and responsible interpretation. |
| Optional background | SFC + ABM reading map | Orientation for readers new to stock-flow consistent agent-based macroeconomics and Amor Fati's ledger-first stance. |
| 1. Model specification and ODD | Model specification and ODD / ODD+D model documentation | Model identity, scope, entities, scheduling, state vector, month timing, equation families, stochasticity, limitations, and pointers to detailed sector documents. |
| 2. SFC evidence boundary | SFC matrix evidence and model equations to SFC map | Hand-maintained entry points for generated BSM/TFM snapshots, exact identities, runtime mechanism mapping, and stock-flow reconciliation evidence. |
| 3. Calibration evidence | Calibration register and data bridge | Parameter provenance, empirical sources, transformations, assumptions, and visible calibration gaps. |
| 4. Validation evidence | Empirical validation report and engine invariants | Empirical snapshot workflow, normal-path expectations, hard invariants, warnings, and known limitation surfaces. |
| Step | Entry point | Boundary |
|---|---|---|
| 1. Code architecture | Architecture documentation | Code-facing map of package boundaries, the runtime loop, state and ledger ownership, extension points, and architecture decision records. |
| 2. Operational appendices | Operations | Entry point for commands, CI ownership, diagnostics/profiling routing, generated-output guards, scenarios, robustness, and local artifacts. |
Generated SFC snapshots live under docs/sfc-matrix-artifacts/, but they are not a separate README reading path:
| Step | Entry point | Boundary |
|---|---|---|
| 1. Generated matrix snapshots | SFC matrix artifacts | Generated BSM/TFM snapshots, matrix mapping, flow-mechanism semantics, and stock-flow reconciliation artifacts. |
| 2. Evidence and regeneration | SFC matrix evidence | Regeneration commands, sign conventions, exact reconciliation rows, and coverage gaps. |
| 3. Equation mapping | Model equations to SFC map | Hand-maintained bridge from model equation families to generated rows, identities, and runtime evidence. |
See CONTRIBUTING.md for the development and research review requirements. External contributions require acceptance of the Contributor License Agreement before merge.
GNU AGPLv3 (AGPL-3.0-only) — Copyright 2026 BoomBustGroup