Orion → Atlas, Vesper, Katja — FLAG-030 landed (Option B)¶
When: 2026-04-17 From: Orion Subject: Option B shipped on branch. Tests green, live-DB verification passed. Awaiting push from Katja's terminal.
Summary¶
Implemented Atlas's Option B exactly as specified: per-asset created_at boundary against MIN(inventory_ledger.created_at). Branch fix/flag-030-capital-overlay at commit 37692b0, stacked on fix/flag-008-capital-event-validation.
Test coverage¶
- 21 new FLAG-030 tests in
tests/test_inventory_manager.py(12 unit forget_capital_delta_total, 9 integration forrebuild()). - Includes all 4 Atlas-required scenarios: pre-baseline excluded, fresh-DB overlay skipped, post-ledger applied, mixed pre/post → only post applied.
- Also includes the live-DB reproducer: 2 pre-engine deposits +
live.starting_balance_*seeded to wallet snapshot → overlay = 0, balance unchanged. - Idempotency with a real overlay active across 5 repeated rebuilds — stable.
- 38/38 pass in
test_inventory_manager.py; 77/77 combined withtest_state_manager.py.
Live-DB verification (Atlas gate #10)¶
Ran against /tmp/live_post_s32.db:
ledger.new_balance(XRP) = 41.01792720880708
ledger.new_balance(RLUSD) = 86.22001773779789
get_capital_delta_total(XRP) = 0.0 ← pre-engine events correctly excluded
get_capital_delta_total(RLUSD) = 0.0
Rebuild #1 → XRP=41.01792720880708, RLUSD=86.22001773779789
Rebuild #2-6 → identical, no drift
All four assertions satisfied within 1e-9 tolerance:
- XRP balance == get_current_balance(XRP) ✓
- RLUSD balance == get_current_balance(RLUSD) ✓
- XRP overlay == 0.0 ✓
- RLUSD overlay == 0.0 ✓
Avoided phantom inventory under the unbounded version: +137.23 RLUSD.
Implementation note¶
I put the boundary query inside get_capital_delta_total(asset) rather than taking min_created_at as a parameter. One source of truth, no way for a caller to forget the filter. The flag spec document describes it as get_capital_delta_total(asset, min_created_at) — the shipped signature stays get_capital_delta_total(asset) and the boundary is discovered internally. Behavior is identical; mention it here for audit traceability.
Logging¶
[FLAG-030] No ledger baseline found — skipping capital overlayat INFO when an asset has no ledger rows yet (fresh-DB path).[FLAG-030] Applied capital delta: RLUSD = X, XRP = Yat INFO only when at least one non-zero overlay is applied. Cold-start restarts stay quiet; post-injection restarts are auditable.
Outstanding — push only¶
No GitHub credentials in Orion's sandbox. Branch fix/flag-030-capital-overlay exists in the local repo at /sessions/peaceful-admiring-allen/mnt/neo-2026. Katja — please run from your terminal:
cd ~/neo-2026 # or wherever your clone lives
git fetch # pull in the new branch
git push origin fix/flag-030-capital-overlay
Or, if you already have the local branch, just git push origin fix/flag-030-capital-overlay directly. PR target: whichever base you prefer — it will rebase cleanly onto main once FLAG-008 lands.
Files changed: neo_engine/inventory_manager.py, neo_engine/state_manager.py, tests/test_inventory_manager.py. 711 insertions, 14 deletions.
— Orion