FBA-Bench distinguishes itself from other "roleplay" based simulations by enforcing strict financial fidelity. At the core of the simulation lies a professional-grade Double-Entry Ledger that adheres to Generally Accepted Accounting Principles (GAAP).
Unlike systems that simply track "points" or "money" as a single variable, our ledger ensures that every penny is accounted for through balanced debits and credits.
The system continuously verifies the fundamental accounting equation:
If this equation is ever violated—even by a fraction of a cent—the ledger’s verify_integrity(...) check can be used as a "Panic Button".
- Behavior: Callers can treat integrity failure as a hard stop (the ledger logs a critical error and can raise
AccountingError). - Forensics: The critical log includes a full accounting equation breakdown and transaction counts for debugging.
- Why it matters: This guarantees that the simulation results are mathematically impossible to "hallucinate." Profit is not an opinion; it is a derived fact from balanced transactions.
The ledger handles high-frequency trading and automated agents through strict concurrency controls.
- Atomic Locking: The
post_transactionmethod usesasyncio.Lockto serialize all writes. - All-or-Nothing: Transactions are atomic. If any part of a transaction fails validation (e.g., negative balance in a strict account, unequal debits/credits), the entire transaction is rolled back, ensuring the ledger never enters an invalid state.
The system initializes with a standard Chart of Accounts structure:
- Assets (Debit Normal): Cash, Inventory, Accounts Receivable, Prepaid Expenses.
- Liabilities (Credit Normal): Accounts Payable, Accrued Liabilities, Unearned Revenue.
- Equity (Credit Normal): Owner Equity, Retained Earnings.
- Revenue (Credit Normal): Sales Revenue, Other Revenue.
- Expenses (Debit Normal): Cost of Goods Sold, Fulfillment Fees, Advertising, etc.
The implementation acts as a source of truth for the entire simulation state.
-
verify_integrity(): The watchdog ensuring mathematical correctness. -
post_transaction(transaction): The gatekeeper for all state changes. Performs zero-sum validation ($\Sigma \text{Debits} - \Sigma \text{Credits} = 0$ ). -
initialize_chart_of_accounts(): Sets up the GAAP-compliant account structure.
Implementation references:
src/services/ledger/core.pysrc/services/ledger/models.pysrc/services/ledger/validation.py
Agents do not "update their balance." They submit legal Transactions. The ledger determines the resulting balance. This separation of concerns prevents agents from hallucinating wealth or bypassing costs.