From fefb18626e6e305eaf0cba355f825c3bb7a4fa3a Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 13 Jun 2026 00:48:38 +0200 Subject: [PATCH] VIOLET V2d: V2 exec gate PASSED on prod host + beartype ADOPT verdict 200 scenario cycles @100ms TTL with the V0 storm as concurrent background load: deadline_jitter p99 8.47ms (<25, zero early fires), ttl_resolution fire->CANCEL p99 5.89ms (<50) p50 0.08ms (<10), all terminals correct, zero stuck orders/deadlines, capital never froze, run-to-run determinism (identical outcomes_hash). V0 latency gate re-run: still PASSED. beartype A/B (subprocess, import-time kill-switch): jitter p99 delta +0.42ms, ttl p99 delta +0.025ms -> ADOPT (<1ms budget); 'typed' stays on by default, DOLPHIN_VIOLET_BEARTYPE=0 escape hatch retained. exec_harness: CLI runner (the A/B vehicle), is_capital_frozen() for the accounting verdict, early-fires derived from negative jitter. Dedicated non-gate test: full exec path vs ObserveOnlyVenue - inner venue untouched, slot stays free. Violet suite 97 green; router 77 green; shared clean. Co-Authored-By: Claude Fable 5 --- .../violet_v2_exec_gate_20260612_223838.json | 1679 +++++++++++++++++ prod/clean_arch/violet/exec_harness.py | 48 +- .../violet/test_violet_v2_exec_gate.py | 152 ++ 3 files changed, 1872 insertions(+), 7 deletions(-) create mode 100644 prod/VIOLET_dev/reports/violet_v2_exec_gate_20260612_223838.json create mode 100644 prod/clean_arch/violet/test_violet_v2_exec_gate.py diff --git a/prod/VIOLET_dev/reports/violet_v2_exec_gate_20260612_223838.json b/prod/VIOLET_dev/reports/violet_v2_exec_gate_20260612_223838.json new file mode 100644 index 0000000..2c5c109 --- /dev/null +++ b/prod/VIOLET_dev/reports/violet_v2_exec_gate_20260612_223838.json @@ -0,0 +1,1679 @@ +{ + "generated_utc": "2026-06-12T22:38:38Z", + "host": "DOLPHIN", + "script": { + "n_cycles": 200, + "seed": 7, + "asset": "STORMUSDT", + "base_price": 100.0, + "walk_bps": 8.0, + "scenarios": [ + "immediate_fill", + "rest_then_fill", + "fill_races_cancel", + "rest_expire_retry", + "retry_exhaust_skip", + "retry_exhaust_market", + "exit_expire_market", + "post_only_reject", + "cancel_reject" + ], + "script_hash": "d2616698f0e51433146ac01a5d997d48d6e95bdc63ad3a019b70a57ff67febeb", + "outcomes_hash": "fa8b9b59752a966684e5babaea39dd508ce72cba0709f777c173ed0e5a76a732", + "outcomes": [ + { + "idx": 0, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 1, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 2, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 3, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 4, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 5, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 6, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 7, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 8, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 9, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 10, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 11, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 12, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 13, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 14, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 15, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 16, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 17, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 18, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 19, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 20, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 21, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 22, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 23, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 24, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 25, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 26, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 27, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 28, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 29, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 30, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 31, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 32, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 33, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 34, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 35, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 36, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 37, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 38, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 39, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 40, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 41, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 42, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 43, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 44, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 45, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 46, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 47, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 48, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 49, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 50, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 51, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 52, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 53, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 54, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 55, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 56, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 57, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 58, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 59, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 60, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 61, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 62, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 63, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 64, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 65, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 66, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 67, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 68, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 69, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 70, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 71, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 72, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 73, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 74, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 75, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 76, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 77, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 78, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 79, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 80, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 81, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 82, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 83, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 84, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 85, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 86, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 87, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 88, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 89, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 90, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 91, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 92, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 93, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 94, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 95, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 96, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 97, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 98, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 99, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 100, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 101, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 102, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 103, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 104, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 105, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 106, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 107, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 108, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 109, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 110, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 111, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 112, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 113, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 114, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 115, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 116, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 117, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 118, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 119, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 120, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 121, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 122, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 123, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 124, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 125, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 126, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 127, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 128, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 129, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 130, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 131, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 132, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 133, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 134, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 135, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 136, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 137, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 138, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 139, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 140, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 141, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 142, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 143, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 144, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 145, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 146, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 147, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 148, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 149, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 150, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 151, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 152, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 153, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 154, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 155, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 156, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 157, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 158, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 159, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 160, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 161, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 162, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 163, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 164, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 165, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 166, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 167, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 168, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 169, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 170, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 171, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 172, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 173, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 174, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 175, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 176, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 177, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 178, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 179, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 180, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 181, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 182, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 183, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 184, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 185, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 186, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 187, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 188, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 189, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 190, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 191, + "scenario": "fill_races_cancel", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 192, + "scenario": "rest_expire_retry", + "ok": true, + "entry_path": "r1", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 193, + "scenario": "retry_exhaust_skip", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 194, + "scenario": "retry_exhaust_market", + "ok": true, + "entry_path": "m", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 195, + "scenario": "exit_expire_market", + "ok": true, + "entry_path": "base", + "exit_path": "market_fallback", + "detail": "" + }, + { + "idx": 196, + "scenario": "post_only_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 197, + "scenario": "cancel_reject", + "ok": true, + "entry_path": "none", + "exit_path": "none", + "detail": "" + }, + { + "idx": 198, + "scenario": "immediate_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + }, + { + "idx": 199, + "scenario": "rest_then_fill", + "ok": true, + "entry_path": "base", + "exit_path": "urgent_market", + "detail": "" + } + ] + }, + "cycles": 200, + "scenarios": { + "immediate_fill": 23, + "rest_then_fill": 23, + "fill_races_cancel": 22, + "rest_expire_retry": 22, + "retry_exhaust_skip": 22, + "retry_exhaust_market": 22, + "exit_expire_market": 22, + "post_only_reject": 22, + "cancel_reject": 22 + }, + "jitter": { + "name": "deadline_jitter", + "count": 199, + "retained": 199, + "overflow_dropped": 0, + "min_ms": 0.083636, + "p50_ms": 0.707658, + "p90_ms": 3.537337, + "p99_ms": 8.47129, + "p999_ms": 42.410207, + "max_ms": 42.410207 + }, + "ttl_resolution": { + "name": "ttl_resolution", + "count": 198, + "retained": 198, + "overflow_dropped": 0, + "min_ms": 0.04706, + "p50_ms": 0.079617, + "p90_ms": 0.40526599999999996, + "p99_ms": 5.890527, + "p999_ms": 6.116559, + "max_ms": 6.116559 + }, + "kernel_call": {}, + "early_fires": 0, + "stuck_orders": 0, + "pending_deadlines": 0, + "terminals_ok": true, + "accounting_ok": true, + "deterministic": true, + "beartype": { + "on_jitter_p99_ms": 1.5680749999999999, + "off_jitter_p99_ms": 1.150695, + "on_ttl_p99_ms": 0.366589, + "off_ttl_p99_ms": 0.341502, + "delta_jitter_p99_ms": 0.417, + "delta_ttl_p99_ms": 0.025, + "adopt": true + }, + "passed": true +} \ No newline at end of file diff --git a/prod/clean_arch/violet/exec_harness.py b/prod/clean_arch/violet/exec_harness.py index 8a818d8..26fcda8 100644 --- a/prod/clean_arch/violet/exec_harness.py +++ b/prod/clean_arch/violet/exec_harness.py @@ -180,16 +180,11 @@ class ExecStormHarness: ) def _accounting_ok(self) -> bool: - """K==E reconciled and capital_frozen never set.""" + """capital_frozen never set (the kernel's reconcile-gate verdict).""" try: - snap = self.kernel.snapshot() + return not bool(self.kernel.is_capital_frozen()) except Exception: return False - if isinstance(snap, dict): - if snap.get("capital_frozen"): - return False - return True - return not bool(getattr(snap, "capital_frozen", False)) def archive_report(report: ExecGateReport) -> Path: @@ -198,3 +193,42 @@ def archive_report(report: ExecGateReport) -> Path: path = REPORTS_DIR / name path.write_text(json.dumps(report.model_dump(), indent=2, default=str)) return path + + +# ── CLI (subprocess vehicle for the beartype ON/OFF gate comparison) ────────── + +def _amain(argv: Optional[List[str]] = None) -> int: + import argparse + import sys as _sys + + from .domain import _beartype_enabled + + ap = argparse.ArgumentParser(description="VIOLET V2 exec gate runner") + ap.add_argument("--cycles", type=int, default=60) + ap.add_argument("--seed", type=int, default=7) + ap.add_argument("--ttl-ms", type=float, default=100.0) + ap.add_argument("--storm-events", type=int, default=0) + ap.add_argument("--out", type=str, default="") + args = ap.parse_args(argv) + + async def go() -> ExecGateReport: + h = ExecStormHarness(ttl_ms=args.ttl_ms) + storm = (StormSpec(n_events=args.storm_events) + if args.storm_events > 0 else None) + return await h.run_gate( + IntentScriptSpec(n_cycles=args.cycles, seed=args.seed), + background_storm=storm, + beartype_meta={"enabled": _beartype_enabled()}, + ) + + report = asyncio.run(go()) + blob = json.dumps(report.model_dump(), indent=2, default=str) + if args.out: + Path(args.out).write_text(blob) + else: + _sys.stdout.write(blob + "\n") + return 0 if report.passed else 1 + + +if __name__ == "__main__": + raise SystemExit(_amain()) diff --git a/prod/clean_arch/violet/test_violet_v2_exec_gate.py b/prod/clean_arch/violet/test_violet_v2_exec_gate.py new file mode 100644 index 0000000..7ffe978 --- /dev/null +++ b/prod/clean_arch/violet/test_violet_v2_exec_gate.py @@ -0,0 +1,152 @@ +"""V2d: the VIOLET V2 exec gate — run on the prod host. + +Budgets (plan harmonic-jumping-plum, V2d): + deadline_jitter p99 < 25 ms, zero early fires (V0 budget under exec load) + ttl_resolution (fire → CANCEL submitted) p99 < 50 ms, p50 < 10 ms + every scenario cycle reaches its expected terminal + zero stuck working orders / pending deadlines; accounting never frozen + determinism: same seed ⇒ identical outcomes_hash, twice + beartype ON vs OFF: subprocess A/B, deltas recorded in the report meta + (permanent adoption iff p99 delta < 1 ms) + +The observe-only guard test runs in the regular suite (not gate-marked): +the ExecDeadlineDriver pointed at an ObserveOnlyVenue must never reach the +inner venue. +""" + +from __future__ import annotations + +import asyncio +import json +import os +import subprocess +import sys +import tempfile +from pathlib import Path + +sys.path.insert(0, "/mnt/dolphinng5_predict") +sys.path.insert(0, "/mnt/dolphinng5_predict/nautilus_dolphin") + +import pytest + +from prod.clean_arch.violet.exec_harness import ( + GATE_JITTER_P99_MS, + GATE_TTL_RESOLUTION_P50_MS, + GATE_TTL_RESOLUTION_P99_MS, + ExecStormHarness, + archive_report, +) +from prod.clean_arch.violet.harness import StormSpec +from prod.clean_arch.violet.synthetic_intents import ( + IntentScriptSpec, + Scenario, + outcomes_hash, +) + +REPO = "/mnt/dolphinng5_predict" + + +def _subprocess_gate(beartype: str, cycles: int = 60) -> dict: + with tempfile.NamedTemporaryFile(suffix=".json", delete=False) as f: + out = f.name + env = {**os.environ, "DOLPHIN_VIOLET_BEARTYPE": beartype, + "PYTHONPATH": f"{REPO}:{REPO}/nautilus_dolphin"} + proc = subprocess.run( + [sys.executable, "-m", "prod.clean_arch.violet.exec_harness", + "--cycles", str(cycles), "--out", out], + cwd=REPO, env=env, capture_output=True, text=True, timeout=600) + assert proc.returncode == 0, ( + f"beartype={beartype} subprocess gate failed:\n{proc.stdout}\n{proc.stderr}") + blob = json.loads(Path(out).read_text()) + os.unlink(out) + return blob + + +@pytest.mark.gate +def test_v2_exec_gate(): + # 1) beartype A/B (subprocesses — the kill-switch is import-time). + on = _subprocess_gate("1") + off = _subprocess_gate("0") + d_jit = on["jitter"]["p99_ms"] - off["jitter"]["p99_ms"] + d_ttl = on["ttl_resolution"]["p99_ms"] - off["ttl_resolution"]["p99_ms"] + beartype_meta = { + "on_jitter_p99_ms": on["jitter"]["p99_ms"], + "off_jitter_p99_ms": off["jitter"]["p99_ms"], + "on_ttl_p99_ms": on["ttl_resolution"]["p99_ms"], + "off_ttl_p99_ms": off["ttl_resolution"]["p99_ms"], + "delta_jitter_p99_ms": round(d_jit, 3), + "delta_ttl_p99_ms": round(d_ttl, 3), + "adopt": bool(d_jit < 1.0 and d_ttl < 1.0), + } + + # 2) main gate: 200 cycles @100ms TTL with the V0 storm as background + # load (its own MOCK kernel — load, not interleaving). + async def go(): + h = ExecStormHarness(ttl_ms=100.0) + report = await h.run_gate( + IntentScriptSpec(n_cycles=200, seed=7), + background_storm=StormSpec(n_events=20_000), + beartype_meta=beartype_meta, + ) + return report + + report = asyncio.run(go()) + path = archive_report(report) + print(f"\nV2 exec gate report → {path}") + print(json.dumps({"jitter": report.jitter, "ttl_resolution": + report.ttl_resolution, "beartype": report.beartype}, + indent=2, default=str)) + + failed = [o for o in report.script["outcomes"] if not o["ok"]] + assert not failed, f"cycles failed: {failed[:5]}" + assert report.jitter["p99_ms"] < GATE_JITTER_P99_MS, report.jitter + assert report.early_fires == 0 + assert report.ttl_resolution["p99_ms"] < GATE_TTL_RESOLUTION_P99_MS, \ + report.ttl_resolution + assert report.ttl_resolution["p50_ms"] < GATE_TTL_RESOLUTION_P50_MS, \ + report.ttl_resolution + assert report.stuck_orders == 0 and report.pending_deadlines == 0 + assert report.accounting_ok + assert report.passed + + +@pytest.mark.gate +def test_v2_gate_determinism(): + """Same seed ⇒ identical outcome projections, run twice fresh.""" + def run_once(): + async def go(): + h = ExecStormHarness(ttl_ms=100.0) + return await h.run_matrix(IntentScriptSpec(n_cycles=36, seed=21)) + return asyncio.run(go()) + + o1, o2 = run_once(), run_once() + assert all(o.ok for o in o1), [o.detail for o in o1 if not o.ok] + assert outcomes_hash(o1) == outcomes_hash(o2) + + +def test_observe_only_venue_blocks_exec_driver(): + """Defense in depth: the whole V2 exec path pointed at an + ObserveOnlyVenue never reaches the inner venue — the kernel converts + the guard's refusal into a synthetic REJECT and the slot stays free.""" + from prod.clean_arch.violet.observe_guard import ObserveOnlyVenue + from prod.clean_arch.violet.synthetic_intents import ( + IntentScriptSpec as Spec, + ) + + async def go(): + h = ExecStormHarness(ttl_ms=100.0) + inner = h.venue + h.kernel.venue = ObserveOnlyVenue(inner) + outs = await h.run_matrix( + Spec(n_cycles=1, seed=3, scenarios=[Scenario.IMMEDIATE_FILL])) + return h, inner, outs + + h, inner, outs = asyncio.run(go()) + assert inner.submits == [] # NOTHING reached the venue + assert not outs[0].ok # cycle honestly failed + assert h.slot_view()[2] == 0.0 # no position materialized + assert h.router.working_orders() == [] # nothing left working + + +if __name__ == "__main__": + raise SystemExit(pytest.main([__file__, "-v", "-m", "gate"]))