Show HN: LIBRトレースとソース台帳行およびバイト単位のPDF検証
Show HN: LIBR tracing with source ledger rows and byte-exact PDF verification (exitprotocols.com)
要約
この技術ノートは、LIBR(Lowest Intermediate Balance Rule)スタイルのトレースが、順序付けられた台帳に対する決定論的なリプレイとして表現できることを示しています。これにより、残高の減少、同日仮定、および非補充行動を正確に追跡できます。公開リポジトリでは、合成データと回帰テストを用いて計算モデルを直接検証でき、開発者、フォレンジック会計士、デューデリジェンスレビュー担当者向けのツールを提供しています。
全文翻訳
Public Engineering Note
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.
Public engineering note Synthetic data only Deterministic calculation demo Not legal advice
State transition card
Each ledger step replays one ordered transaction against running state.
State inputs: - prior traceable balance - current account balance - transaction amount - ordering mode Transition: traceable_after = min(traceable_before, account_balance_after) Boundary: later deposits do not automatically restore a previously reduced traceable amount under the selected LIBR assumption.
- 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.
Purpose
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.
Visual Module
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
Model
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.
Source depositClaim opens
Ordered replayLedger walk
Balance dipTrace ceiling drops
Same-day orderMode applied
SnapshotInspectable output
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
Trace never exceeds account
traceable balance cannot exceed the account balance after any step.
Trace never exceeds source claim
traceable balance cannot exceed the separate-property amount being traced.
Non-replenishment after dip
later deposits do not automatically restore a traceable amount previously reduced by a dip.
Deterministic replay
same inputs and same ordering mode produce the same outputs on every run.
Example Ledger
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.
Ordering Modes
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.
Ledger order
Public repo: --ordering ledger. Preserves CSV order within each date. Baseline deterministic replay.
Deposits-first scenario
Public repo: --ordering best_case. Deposits precede withdrawals on the same date to expose one mechanical sensitivity boundary.
Withdrawals-first scenario
Public repo: --ordering worst_case. Withdrawals precede deposits on the same date to expose the other mechanical sensitivity boundary.
Recorded-order baseline
The product default preserves source row order where available and applies stable record tie-breakers when same-day timestamps are unavailable.
Public Repository
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.
Product Boundary
What Exit Protocol adds beyond the public artifact
The repository proves the calculation primitive. The product wraps that primitive in a review workflow:
Authenticated case workspace
Private matter context with role boundaries.
Statement ingestion
Selected financial records normalized into ledger rows.
Reconciliation
Opening, activity, and closing balances tested before tracing.
Material ledger selection
Rows surfaced for attorney and expert inspection.
Attorney-reviewable workpaper
Structured export — not legal advice or an expert report.
Source provenance
Supporting rows linked to selected statements or exports.
SHA-256 snapshot integrity
Fingerprint of calculation state at export time.
Final file hash verification
Post-export byte check for generated workpapers.
V1 single-claim export guard
Default workpaper path scoped to one claim per account.
Run Locally
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.
Professional boundary. This engineering note is educational and product-oriented. It is not legal advice, not an expert opinion, not a court filing, and not a guarantee of admissibility. LIBR and related tracing doctrines are jurisdiction-specific and fact-dependent. Attorneys and retained experts must review all source records, assumptions, calculations, and conclusions.
Related Resources