[C] Orion Delivery — Cleanup + anchor error bps (Apr 18)
To: Vesper CC: Katja (Captain), Atlas From: Orion Date: 2026-04-18
Branch¶
fix/cleanup-and-anchor-instrumentation — 5 commits, one per item, in the order Vesper specified. Subjects match the brief exactly.
| # | SHA | Subject | Files |
|---|---|---|---|
| 1 | 58ad919 |
fix(flag-034): session summary displays total XRP balance (fills + capital overlay) |
summarize_paper_run.py, tests/test_flag_034_display_overlay.py |
| 2 | ac33de6 |
chore: retire max_inventory_usd dead config (14 files) |
14 files — code + 4 YAMLs + 4 tests + 2 archive |
| 3 | db85c38 |
fix(flag-033): startup DB integrity check before backup and engine init |
run_paper_session.py, tests/test_flag_033_startup_integrity.py |
| 4 | 3ca933e |
fix(flag-028): add idx_fills_session_id index on fills table |
neo_engine/state_manager.py, tests/test_flag_028_fills_session_index.py |
| 5 | 469e5bb |
feat: anchor_error_bps reliability stat — pct ticks where \|error\| > 5 bps |
neo_engine/main_loop.py, summarize_paper_run.py, tests/test_anchor_error_stat.py |
All five held to the no-touch list — anchor_max_divergence_bps: 10.0, base_size_rlusd: 15.0, risk_engine.py, fill paths, schema (except the Item 4 index). No .claude or editor config stowaways.
Tests¶
| Item | Test file | Count |
|---|---|---|
| 1 | test_flag_034_display_overlay.py |
5 |
| 3 | test_flag_033_startup_integrity.py |
5 |
| 4 | test_flag_028_fills_session_index.py |
2 |
| 5 | test_anchor_error_stat.py |
3 |
Total: 15 unit tests across four new files. 15/15 green.
Item 2 (max_inventory_usd retirement) — no dedicated test file. Coverage comes from existing test suite loading cleanly without the field (all 4 YAMLs load, StrategyConfig has no field, no test touches the removed kwarg).
Item 5 — anchor_error_bps output¶
Example summary line after the change:
The |err|>5bps: X.X% suffix is only emitted when engine_state has a value, so sessions from before this branch lands render as before (no "None%" on legacy logs).
Implementation details:
_log_anchor_divergence_summary()inmain_loop.pygained one counter (abs_above_5), one computed stat (pct_error_above_5), one log-extra field, and one engine_state key (anchor.pct_error_above_5bps).- Existing buckets and one-sided counts (>10, >12, >14) untouched.
summarize_paper_run.pyreadsanchor.pct_error_above_5bpsand conditionally appends theerr5_strto the anchor line.
Delivery format — patches¶
Per git rule, handing off as .patch files for Katja to apply on her machine.
Patches location:
02 Projects/NEO Trading Engine/orion-patches-2026-04-18/
0001-fix-flag-034-session-summary-displays-total-XRP-bala.patch
0002-chore-retire-max_inventory_usd-dead-config-14-files.patch
0003-fix-flag-033-startup-DB-integrity-check-before-backu.patch
0004-fix-flag-028-add-idx_fills_session_id-index-on-fills.patch
0005-feat-anchor_error_bps-reliability-stat-pct-ticks-whe.patch
Expected conflict (one, known)¶
Patch 2 will conflict on one hunk in config/config_live_stage1.yaml. My sandbox baseline has max_inventory_usd: 10.0; Katja's main has max_inventory_usd: 20.0 # raised from 10.0 post-injection.... Since patch 2 deletes the line regardless of value, the resolution is simply delete the line and continue.
No conflicts expected on config.yaml, config_live_session1.yaml, config.example.yaml.
Git commands for Katja — copy-paste, PowerShell¶
Run each block in your VS Code terminal from the repo root. Adjust the path to the patches folder as shown.
Block 1 — create the branch off current main
Block 2 — apply patch 1 cleanly
$patches = "C:\Users\Katja\Documents\NEO GitHub\neo-2026\Claude Homebase Neo\02 Projects\NEO Trading Engine\orion-patches-2026-04-18"
git am --3way "$patches\0001-fix-flag-034-session-summary-displays-total-XRP-bala.patch"
Block 3 — apply patch 2 (expect conflict on config_live_stage1.yaml)
When git stops on the conflict, open config/config_live_stage1.yaml and delete the entire conflict block:
<<<<<<< HEAD
max_inventory_usd: 20.0 # raised from 10.0 post-injection (~10% of $200 portfolio)
=======
>>>>>>> (patch contents)
Block 4 — apply remaining patches
git am --3way "$patches\0003-fix-flag-033-startup-DB-integrity-check-before-backu.patch"
git am --3way "$patches\0004-fix-flag-028-add-idx_fills_session_id-index-on-fills.patch"
git am --3way "$patches\0005-feat-anchor_error_bps-reliability-stat-pct-ticks-whe.patch"
Block 5 — verify the branch
Expected: exactly 5 commits, same subjects and order as the table above.Block 6 — run the new tests
python -m pytest tests/test_flag_034_display_overlay.py tests/test_flag_033_startup_integrity.py tests/test_flag_028_fills_session_index.py tests/test_anchor_error_stat.py -v
15 passed.
Block 7 — push and open PR
gh pr create --base main --head fix/cleanup-and-anchor-instrumentation `
--title "cleanup + anchor_error_bps instrumentation" `
--body "5 commits per Vesper's 2026-04-18 brief: FLAG-034, max_inventory_usd retirement, FLAG-033, FLAG-028, anchor_error_bps reliability stat."
If anything goes wrong:
Ping Vesper — likely cause is main moved between sandbox snapshot and yourgit pull.
What stays unchanged¶
anchor_max_divergence_bps: 10.0— heldbase_size_rlusd: 15.0— heldrisk_engine.py— untouched- Fill calculation paths — untouched
- No schema changes beyond the Item 4 index
— Orion