Vesper Review — Pre-Phase-7.3 Blocker Branches¶
To: Katja CC: Orion, Atlas From: Vesper Date: 2026-04-19
Verdict: BOTH APPROVED ✅¶
Two commits reviewed. All spec requirements met. No blocking issues.
Branch 1 — fix/intended-distance-to-touch (commit 83e1f54)¶
Core change: New _resolve_quote_price_for_distance helper implements the live→intent priority chain. Live resting order price wins when available; intended price (mid * (1 ± offset/10000)) fires as fallback in paper mode. Falls to None only when neither source can supply a positive price.
Type guards: isinstance(x, (int, float)) on both live_price and offset_bps — correct. Prevents MagicMock attributes from slipping through fixture teardown and producing false-positive non-None values.
Docstring: Superseded Vesper Q3 "live-only source" ruling removed and replaced with Atlas 2026-04-19 priority chain. Correct.
Tests:
- test_paper_tick_distance_to_touch_intended_fallback_paper_mode: bid=150 bps, ask=150 bps, no live orders. Both sides populate. Math verified: bid_bps ≈ +51.5, ask_bps ≈ +50.49 ✅
- test_paper_tick_distance_to_touch_live_order_beats_intent: live BUY at 0.999 produces +10.0; absurd 1000 bps intent offset would produce +550.0 — any priority regression fails loudly. SELL falls to intent (+500.0). ✅
- Fixture pinned with last_bid_offset_bps = None / last_ask_offset_bps = None — preserves all 5 pre-existing tests' NULL assertions. Correct.
Test posture: +2 passing / 0 new failures vs Branch #7 baseline. ✅
Branch 2 — fix/inventory-invariant-at-shutdown (commit d6999c7)¶
Wiring: Inserted between close_session and set_engine_state("engine_status", HALTED) — correct per spec. Key is written while the connection is still open, readable by offline summaries and next session startup.
Status values: 7 failure reasons + ok + error. All required cases covered. The fail:missing_xrp_share guard handles the edge case where xrp_pct comes back as a non-numeric (e.g., None from a partial snapshot).
Never re-raises: Confirmed. Double-fault path (snapshot raises + write raises) is caught and swallowed. Shutdown proceeds unconditionally.
xrp_pct band: 5.0–95.0 inclusive. InventorySnapshot.xrp_pct confirmed as 0–100 range (not 0–1 fraction). Band matches the S40 outcome (55.9% XRP) with headroom. ✅
Tests — 10 total:
- Happy path: clean 50/50 → ok ✅; boundary 5.0 and 95.0 both → ok (inclusive) ✅
- Failure modes: negative XRP, negative RLUSD, zero total value, 99% XRP (too high), 0.38% XRP (too low) — all correct status strings ✅
- Error path: get_snapshot raises → writes error, never propagates ✅; double-fault (snapshot + write both raise) is swallowed ✅
- Shutdown integration: full _shutdown drive-through, patches close() to keep connection alive for readback, asserts key lands before close ✅
Test posture: +10 passing / 0 new failures vs Branch 1 baseline. Aggregate vs Branch #7: +12 / 0. ✅
Apply commands — Windows VS Code terminal¶
Step 1 — Branch 1¶
git fetch origin
git checkout -b fix/intended-distance-to-touch
git am "C:\Users\Katja\Documents\Claude Homebase Neo\02 Projects\NEO Trading Engine\patches\branch-1-intended-distance-to-touch\0001-fix-metrics-distance_to_touch-falls-back-to-intended.patch"
git log --oneline -2
python -m pytest tests/test_main_loop.py -k "distance_to_touch" -q
Expected: 7 passed (5 pre-existing + 2 new). Then merge:
git checkout main
git merge --no-ff fix/intended-distance-to-touch -m "Merge branch 'fix/intended-distance-to-touch' into main"
git push
Step 2 — Branch 2 (off main after Branch 1 merged)¶
git checkout -b fix/inventory-invariant-at-shutdown
git am "C:\Users\Katja\Documents\Claude Homebase Neo\02 Projects\NEO Trading Engine\patches\branch-2-inventory-invariant-at-shutdown\0001-feat-shutdown-hard-inventory-invariant-check-at-sess.patch"
git log --oneline -2
python -m pytest tests/test_inventory_invariant.py -q
Expected: 10 passed. Then merge:
git checkout main
git merge --no-ff fix/inventory-invariant-at-shutdown -m "Merge branch 'fix/inventory-invariant-at-shutdown' into main"
git push
Step 3 — S40-equivalent re-run¶
Confirm from output:
- inventory_invariant.status: ok in engine_state
- distance_to_touch_bid/ask_bps non-NULL in system_metrics
Then paste summary here — Vesper will clear the Phase 7.3 gate.
Branch status¶
| Branch | Status |
|---|---|
| #1–#7 (audit plan) | ✅ Merged |
| fix/intended-distance-to-touch | ✅ Approved — apply and merge |
| fix/inventory-invariant-at-shutdown | ✅ Approved — apply and merge (after Branch 1) |
| S40-equivalent re-run | ⏳ After both merged |
| Phase 7.3 sweep | ⏳ Unlocks after re-run passes |
— Vesper