Vesper Review — feat/directional-drift-guard¶
To: Orion (he/him), Katja (Captain) From: Vesper (she/her) CC: Atlas (he/him) Date: 2026-04-19 Status: APPROVED — apply and merge
Verdict: APPROVED¶
24/24 tests green. 111/111 regression green. Spec compliance confirmed on all critical points. Two corrections required to the apply instructions (below) — do not use Orion's apply command as written.
Spec Compliance¶
OR logic: Any single condition triggers DEGRADED. Conditions A, B, and C are evaluated independently; first hit wins. Correct per Atlas-locked spec.
Condition A — Fill burst: Buy and sell counts evaluated independently within the rolling burst_window_seconds deque. Symmetric — both sides can trigger. Correct.
Condition B — Net notional: Signed RLUSD tracked via rolling net_notional_window_seconds deque. abs(sum) >= threshold — symmetric, catches both buy-side and sell-side accumulation. Correct.
Condition C — No opposing fills: no_opposing_fill_min_fills gate correctly prevents false trigger at session open before any fills. Tick counter resets on opposing fill side. Correct.
One-shot flag: _drift_guard_triggered_this_session = True set before WARNING log, before record_circuit_breaker_event, before _enter_degraded_mode. Per explicit requirement in Q5 ruling (2026-04-19). Correct.
Insertion point (Step 8.5b): After anchor saturation guard, before "no intents" log and Step 9 submit. Coexistence analysis correct — both guards use _enter_degraded_mode (idempotent), independent one-shot flags. No ordering conflict. Correct.
Persist-failure safety: DB write failure swallowed, DEGRADED still entered. DB read failure swallowed (no trigger, ERROR log). Guard's safety function not blocked by logging failures. Correct.
Watermark convention: ISO string from fills.created_at, strictly-greater-than filtering, session-scoped. Deque timestamps are wall-clock time.time() at observation — correctly distinct from the watermark. Correct per Q4 ruling.
_enter_degraded_mode reason strings: "directional_drift_guard_A", "directional_drift_guard_B", "directional_drift_guard_C" — discriminates condition at restart. Correct per Q5 ruling.
Config defaults: enabled: true, burst_fill_count: 3, burst_window_seconds: 30.0, net_notional_threshold_rlusd: 50.0, net_notional_window_seconds: 120.0, no_opposing_fill_ticks: 15, no_opposing_fill_min_fills: 1 — match Atlas-locked values across all three config files. net_notional_threshold_rlusd flagged for calibration in config.example.yaml comments per D2 ruling. Correct.
Windows teardown fix: addCleanup(sm.close) LIFO pattern applied in Part C integration tests. Consistent with C5a pattern from anchor guard branch. Correct.
Deviations — Confirmed Pre-Approved¶
- D1 (
get_fill_events_since): Approved in Q1 ruling. Additive read helper, no schema change, existing index. - D2 (
net_notional_threshold_rlusd = 50.0): Approved in D2 ruling. YAML-wired, calibration-TBD flagged. Atlas to tune post-first-live-session. - D3 (wall-clock timestamps): Approved in D3 ruling. Consistent with participation filter precedent. Paper-mode lag within window margins.
No unapproved deviations.
Apply Instructions — CORRECTED¶
Do not use Orion's apply command. Two issues: (1) feat/anchor-saturation-guard is already merged to main — use main as the base. (2) The *.patch glob does not expand in PowerShell and will fail. Use the following instead:
cd C:\Users\Katja\Documents\NEO GitHub\neo-2026
git checkout -b feat/directional-drift-guard main
Get-ChildItem "C:\Users\Katja\Documents\Claude Homebase Neo\02 Projects\NEO Trading Engine\patches\feat-directional-drift-guard\" -Filter "*.patch" | Sort-Object Name | ForEach-Object { git am $_.FullName }
python -m pytest tests/test_directional_drift_guard.py -q
Expected: 24 passed. Then optionally run the full regression:
python -m pytest tests/test_directional_drift_guard.py tests/test_anchor_saturation_guard.py tests/test_ledger_reconciler.py tests/test_flag_036_wallet_truth_reconciliation.py tests/test_reconciler_anomaly_log.py tests/test_config.py tests/test_config_invariants.py tests/test_anchor_error_stat.py -q
Expected: 111 passed.
What This Means¶
The Directional Drift Guard is the second of three required guards for Phase 7.3. Once merged:
- Phase 7.3 gate 3 (Anchor Saturation Guard) ✅
- Phase 7.3 gate 5 (Directional Drift Guard) ✅
- Next: Inventory Corridor Guard (gate 4)
— Vesper