PINK DITAv2 Sprint 2-3: accounting parity + multi-leg groundwork

Sprint 2 (accounting + observability parity, PINK scope):
- Verified pink_clickhouse.py writes the 8 BLUE-legacy row families at
  matching schema and that capital authority in pink_direct.step() is
  solely kernel.account (no balance-poll overwrite in the hot loop).
- Report: prod/clean_arch/dita_v2/SPRINT2_ACCOUNTING_PARITY.md.

Sprint 3 offline groundwork (no exchange contact):
- Add _write_trade_exit_leg to pink_clickhouse.py: one BLUE-schema-faithful
  trade_exit_legs row per exit leg, with isolated (non-cumulative) per-leg
  deltas tracked via _leg_state (reset on ENTER). Closes the docstring gap.
- New offline suite test_pink_multi_exit_groundwork.py (3 passed):
  * Flaw 4 — two-leg exit closes once, realized accrues per leg, closed
    slot rejects further EXIT (no double-close).
  * Overshoot invariant — a final EXIT requesting more than the remaining
    size CLAMPS (size to 0, no oversell), retiring the Sprint 0 cumulative-
    ratio risk empirically.
  * trade_exit_legs delta + full BLUE column-set assertions.
- Persistence regression after edits: 10 passed.

BLUE untouched: no changes to dolphin.* / DOLPHIN_*_BLUE / nautilus_event_trader.py.
Live VST multi-leg run remains deferred pending explicit authorization.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-05-30 19:21:45 +02:00
parent 3d7b00e28d
commit d4b73b236a
12 changed files with 3527 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
# DITAv2 Operator Playbook
This is the operator-facing control surface for the DITAv2 execution kernel.
## Supervisor program
The process is managed as:
`dolphin:dita_v2`
Launcher:
`/mnt/dolphinng5_predict/prod/launch_dita_v2.py`
## Default runtime posture
- `DITA_V2_LAUNCHER_MODE=serve`
- `DITA_V2_VENUE=BINGX`
- `DITA_V2_ZINC=REAL`
- `DITA_V2_CONTROL_PLANE=REAL_ZINC`
- `DITA_V2_HAZELCAST=REAL`
- `DITA_V2_MODE=DEBUG`
- `DITA_V2_VERBOSITY=TRACE`
The launcher defaults remain safe in-process for tests, but the supervised
program is configured for the real shared-memory / live venue path.
## Control commands
Use:
```bash
python /mnt/dolphinng5_predict/prod/ops/dita_v2_ctl.py status
python /mnt/dolphinng5_predict/prod/ops/dita_v2_ctl.py start
python /mnt/dolphinng5_predict/prod/ops/dita_v2_ctl.py stop
python /mnt/dolphinng5_predict/prod/ops/dita_v2_ctl.py restart
python /mnt/dolphinng5_predict/prod/ops/dita_v2_ctl.py healthcheck
```
These map to:
```bash
supervisorctl -c /mnt/dolphinng5_predict/prod/supervisor/dolphin-supervisord.conf <action> dolphin:dita_v2
```
## Live BingX testnet smoke
Use the repeatable live smoke wrapper:
```bash
python /mnt/dolphinng5_predict/prod/ops/dita_v2_live_bingx_smoke.py
```
Recommended explicit symbol:
```bash
python /mnt/dolphinng5_predict/prod/ops/dita_v2_live_bingx_smoke.py --symbol TRXUSDT
```
What it does:
- loads `/mnt/dolphinng5_predict/.env`
- sets `BINGX_SMOKE_LIVE=1`
- sets `BINGX_SMOKE_ALLOW_TRADE=1`
- sets `DITA_V2_LIVE_BINGX=1`
- starts `dolphin:dita_v2` if it is not already running
- runs `prod/tests/test_dita_v2_live_bingx_testnet_e2e.py`
- preserves the live suite's rate-limit-aware behavior and cleanup paths
Use `--dry-run` to print the exact command and env without trading.
## Validation order
1. Start the process with `start`.
2. Check `status`.
3. Run `healthcheck`.
4. Inspect the logs:
- `/tmp/dolphin_logs/supervisor/dita_v2.log`
- `/tmp/dolphin_logs/supervisor/dita_v2-error.log`
## Stop sequence
1. `python /mnt/dolphinng5_predict/prod/ops/dita_v2_ctl.py stop`
2. Confirm `status` shows the program stopped.
3. Only after that, touch the launcher config or shared-memory state.
## PINK-on-DITAv2 commands
PINK now executes through the DITAv2 kernel. The same supervisor commands
apply, and the following PINK-specific surfaces are available:
### PINK control
```bash
python /mnt/dolphinng5_predict/prod/ops/pink_ctl.py status
python /mnt/dolphinng5_predict/prod/ops/pink_ctl.py healthcheck
python /mnt/dolphinng5_predict/prod/ops/pink_ctl.py ditav2-status
python /mnt/dolphinng5_predict/prod/ops/pink_ctl.py mode-verify
```
`ditav2-status` checks the DITAv2 env vars (`DITA_V2_MODE`, `DITA_V2_VENUE`,
etc.) and the `dolphin_pink` supervisor program status.
### PINK live BingX testnet smoke
```bash
python /mnt/dolphinng5_predict/prod/ops/dita_v2_live_bingx_smoke.py --pink --symbol TRXUSDT
```
Use `--dry-run` to print the exact env and pytest command without trading.
### Stop sequence
1. `python /mnt/dolphinng5_predict/prod/ops/pink_ctl.py stop`
2. Confirm `status` shows the process stopped.
3. Inspect logs: `/tmp/dolphin_logs/supervisor/dolphin_live_pink.log`