From f7ee491f15391838165f91cf492e57ef217e3f01 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 5 Jun 2026 09:32:01 +0200 Subject: [PATCH] =?UTF-8?q?PINK:=20FLAWS=20doc=20=E2=80=94=20backfill=20SH?= =?UTF-8?q?A=20b30205c=20for=20pass-6=20persistence=20entries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../PINK_DITAv2_FLAW_ANALYSIS_2026-05-31.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/prod/clean_arch/dita_v2/PINK_DITAv2_FLAW_ANALYSIS_2026-05-31.md b/prod/clean_arch/dita_v2/PINK_DITAv2_FLAW_ANALYSIS_2026-05-31.md index 7479ea8..238e983 100644 --- a/prod/clean_arch/dita_v2/PINK_DITAv2_FLAW_ANALYSIS_2026-05-31.md +++ b/prod/clean_arch/dita_v2/PINK_DITAv2_FLAW_ANALYSIS_2026-05-31.md @@ -111,7 +111,7 @@ | E20 | `_capital()` reads live from `AccountProjection` — stale row risk | Persistence | Low | | E21 | `persist_fill_events()` synthesizes fake Decision/Intent | Persistence | Medium | | E22 | `_write_trade_exit_leg` capital_before uses arithmetic reconstruction | Persistence | Medium | -| E23 | `_write_trade_event` uses entry_price as exit_price — **✅ FIXED `(pass-6)`** | Persistence | Medium | +| E23 | `_write_trade_event` uses entry_price as exit_price — **✅ FIXED `b30205c`** | Persistence | Medium | | E24 | Mock venue always emits fill on `partial_fill_ratio > 0` | Test | Low | | E25 | Test scenarios use MARKET-only `_si()` helper — no LIMIT tests | Test | Low | | E26 | Fresh-kernel reconcile tests create second kernel but share venue | Test | Low | @@ -183,7 +183,7 @@ | G18 | `exit_leg_ratios` no sum-to-1 validation | Config | Low | | G19 | RealZincControlPlane.read() no sequence check — torn-read risk | Config | Low | | G20 | ClickHouse journal strategy/db env vars — SQL injection risk | Config | Low | -| G21 | entry_price used as exit_price in trade_events — **✅ FIXED `(pass-6)`** | Persistence | **High** | +| G21 | entry_price used as exit_price in trade_events — **✅ FIXED `b30205c`** | Persistence | **High** | | G22 | active_leg_index → entry_bar semantic mis-mapping | Persistence | Medium | | G23 | capital_before arithmetic absorbs cross-slot PnL | Persistence | Medium | | G24 | Recovery trade_reconstruction always has trade_id="" | Persistence | Medium | @@ -383,12 +383,12 @@ | Flaw | Commit | What changed | |------|--------|--------------| | W10 — `BingxHttpError` blindly mapped to "REJECTED" | `e90d542` | `_http_error_status()` helper: 429/5xx/transport → RATE_LIMITED; 4xx → REJECTED | -| **G21/E23/A13** — `exit_price = entry_price` in trade_events / trade_exit_legs | `(pass-6)` | `_write_trade_event` + `_write_trade_exit_leg` now use `fill_price_hint` (extracted from venue FULL_FILL event) → `intent.reference_price` → `decision.reference_price`; entry_price only as last resort | -| **A14** — `entry_bar` maps `active_leg_index` | `(pass-6)` | `_write_position_state`: `entry_bar = intent.bars_held if intent else 0` | -| **A15** — `persist_recovery_state` uses account dict as slot dict | `(pass-6)` | Recovery reads actual slot from `kernel.slot(0).to_dict()` when kernel is wired; `trade_id` no longer always empty | -| **NaN tracing** — `_safe_float` silently swallows anomalies | `(pass-6)` | `_checked_float()` added: logs WARNING + writes `anomaly_events` spool row on NaN/inf in financial fields; used for `realized_pnl` in exit paths | -| **External-position exit_qty=0** — untracked positions gave empty exit legs | `(pass-6)` | `_write_trade_exit_leg`: when `prev_size<=0` (no prior ENTER tracked), falls back to `initial_size` or `intent.target_size` for exit_qty | -| **exit_qty field missing** from `trade_exit_legs` rows | `(pass-6)` | `exit_qty` added explicitly to `trade_exit_legs` sink dict | +| **G21/E23/A13** — `exit_price = entry_price` in trade_events / trade_exit_legs | `b30205c` | `_write_trade_event` + `_write_trade_exit_leg` now use `fill_price_hint` (extracted from venue FULL_FILL event) → `intent.reference_price` → `decision.reference_price`; entry_price only as last resort | +| **A14** — `entry_bar` maps `active_leg_index` | `b30205c` | `_write_position_state`: `entry_bar = intent.bars_held if intent else 0` | +| **A15** — `persist_recovery_state` uses account dict as slot dict | `b30205c` | Recovery reads actual slot from `kernel.slot(0).to_dict()` when kernel is wired; `trade_id` no longer always empty | +| **NaN tracing** — `_safe_float` silently swallows anomalies | `b30205c` | `_checked_float()` added: logs WARNING + writes `anomaly_events` spool row on NaN/inf in financial fields; used for `realized_pnl` in exit paths | +| **External-position exit_qty=0** — untracked positions gave empty exit legs | `b30205c` | `_write_trade_exit_leg`: when `prev_size<=0` (no prior ENTER tracked), falls back to `initial_size` or `intent.target_size` for exit_qty | +| **exit_qty field missing** from `trade_exit_legs` rows | `b30205c` | `exit_qty` added explicitly to `trade_exit_legs` sink dict | ### Fixes applied (2026-06-04 pass 5) — async/thread/race audit @@ -1190,7 +1190,7 @@ fixing for robustness. --- -### Flaw A13: `persist_fill_events` uses current price as exit price — **✅ FIXED `(pass-6)`** +### Flaw A13: `persist_fill_events` uses current price as exit price — **✅ FIXED `b30205c`** **Location:** `pink_clickhouse.py` lines ~408 @@ -1214,7 +1214,7 @@ for the persisted trade, breaking any PnL reconstruction that relies on --- -### Flaw A14: `_write_position_state` maps active_leg_index to entry_bar — **✅ FIXED `(pass-6)`** +### Flaw A14: `_write_position_state` maps active_leg_index to entry_bar — **✅ FIXED `b30205c`** **Location:** `pink_clickhouse.py` line ~673 @@ -1236,7 +1236,7 @@ from `entry_time` to now. --- -### Flaw A15: `persist_recovery_state` passes account dict as slot dict — **✅ FIXED `(pass-6)`** +### Flaw A15: `persist_recovery_state` passes account dict as slot dict — **✅ FIXED `b30205c`** **Location:** `pink_clickhouse.py` lines ~447-460