LIBR as a Deterministic Ledger State Machine
An engineering note on replaying ordered financial transactions to preserve balance dips, same-day assumptions, and non-replenishment behavior.
Each ledger step replays one ordered transaction against running state.
- Replay one ordered transaction against running traceable balance.
- After a dip: traceable_after = min(traceable_before, account_balance_after).
- Later deposits do not automatically restore prior trace under the LIBR assumption.
Why this artifact exists
The full Exit Protocol product remains private. This public engineering note isolates one narrow technical claim: LIBR-style tracing can be represented as deterministic replay over an ordered ledger.
The companion repository uses synthetic CSV fixtures and regression tests so developers, forensic accountants, and diligence reviewers can inspect the calculation model directly. The artifact is for technical feedback — not legal conclusions, expert opinions, or product completeness claims.
LIBR replay state machine
Synthetic fixture only. Each ordered transaction advances account balance and traceable balance under explicit LIBR assumptions.
Swipe horizontally if the diagram extends beyond the screen.
stateDiagram-v2
[*] --> Baseline
Baseline --> ClaimOpen: separate-property deposit
ClaimOpen --> Replay: chronological replay
Replay --> DipDetected: withdrawal below trace level
DipDetected --> TraceReduced: cap at lowest intermediate balance
TraceReduced --> Replay: continue replay
Replay --> LaterDeposit: later deposit
LaterDeposit --> HoldTrace: balance rises
HoldTrace --> Replay
State machine representation
LIBR tracing is stateful ledger math. Each transaction advances account balance and traceable balance together. Reviewers can inspect the replay path rather than inferring results from narrative summaries.
State variables
- account_balance — running cash balance after each transaction
- traceable_balance — candidate separate-property trace under LIBR
- depletion_events — points where traceable balance is reduced by a dip
- ordering_mode — same-day tie-break assumption
- source_deposit — separate-property claim anchor for the replay
Transitions
- deposit — may increase account balance; separate deposits may increase provisional trace
- withdrawal — reduces account balance and may trigger a dip
- same-day reorder — resequences ambiguous intraday rows
- balance dip — traceable balance capped by account balance
- report snapshot — frozen state for inspection and tests
Invariants
traceable balance cannot exceed the account balance after any step.
traceable balance cannot exceed the separate-property amount being traced.
later deposits do not automatically restore a traceable amount previously reduced by a dip.
same inputs and same ordering mode produce the same outputs on every run.
Synthetic replay with a balance dip
Illustrative rows only. The public repository includes a fuller synthetic CSV and regression fixtures.
Swipe horizontally to view all ledger columns on tablet widths.
| Date | Event | Account Balance | Traceable Balance | State Note |
|---|---|---|---|---|
| Jan 1 | Opening balance | $5,000 | — | Baseline community/pre-existing funds |
| Jan 3 | Separate-property deposit | $105,000 | $100,000 | Source deposit opens traceable claim |
| Feb 10 | Withdrawal | $45,000 | $45,000 | Red dip: trace capped by account balance |
| Mar 1 | Later salary deposit | $65,000 | $45,000 | Account rises; traceable balance unchanged |
| Date | Event | Account Balance | Traceable Balance | State Note |
|---|---|---|---|---|
| Jan 1 | Opening balance | $5,000 | — | Baseline community/pre-existing funds |
| Jan 3 | Separate-property deposit | $105,000 | $100,000 | Source deposit opens traceable claim |
| Feb 10 | Withdrawal | $45,000 | $45,000 | Red dip: trace capped by account balance |
| Mar 1 | Later salary deposit | $65,000 | $45,000 | Account rises; traceable balance unchanged |
Red dip: A red dip occurs when the account balance falls below the claimed separate-property amount, reducing the candidate traceable amount under the selected LIBR assumption.
Same-day ordering assumptions
Bank statements often lack reliable intraday timestamps. When multiple rows share a date, ordering changes the replay path. These modes expose calculation assumptions for review — they are not legal conclusions.
Public repo: --ordering ledger. Preserves CSV order within each date. Baseline deterministic replay.
Public repo: --ordering best_case. Deposits before withdrawals on same day. Exit Protocol product maps to maximize strategy.
Public repo: --ordering worst_case. Withdrawals before deposits on same day. Exit Protocol product maps to minimize strategy.
Exit Protocol product uses a court-balanced neutral strategy for default replay when same-day ambiguity exists.
What the public repo demonstrates
Dependency-free Python
Standalone calculator with no Django dependency.
Synthetic ledger fixture
CSV commingled-account sample for public inspection.
Same-day ordering modes
ledger, best_case, and worst_case CLI switches.
Zero-balance depletion test
Regression coverage for full account depletion.
Replenishment fallacy test
Later deposits do not restore depleted trace.
Multiple source deposits
Edge-case fixture for added separate-property inflows.
CLI execution
Print material trace events from the command line.
Reproducible output
Same fixture and mode yield the same trace on rerun.
What Exit Protocol adds beyond the public artifact
The repository proves the calculation primitive. The product wraps that primitive in a review workflow:
Private matter context with role boundaries.
Selected financial records normalized into ledger rows.
Opening, activity, and closing balances tested before tracing.
Rows surfaced for attorney and expert inspection.
Structured export — not legal advice or an expert report.
Supporting rows linked to selected statements or exports.
Fingerprint of calculation state at export time.
Post-export byte check for generated workpapers.
Default workpaper path scoped to one claim per account.
Inspect the calculation artifact
Requires Python 3.10+. No third-party packages.
git clone https://github.com/Vinaygond/libr-state-machine-demo.git cd libr-state-machine-demo python -m unittest discover -s tests python libr.py examples/minimal_dip_ledger.csv python libr.py examples/synthetic_ledger.csv --ordering ledger python libr.py examples/synthetic_ledger.csv --ordering best_case python libr.py examples/synthetic_ledger.csv --ordering worst_case python libr.py examples/minimal_dip_ledger.csv --json
The CLI prints material trace events from the synthetic fixture. Compare ordering modes to see how same-day ambiguity changes replay output.