[GAP-050]: quantity-aware risk contract complete

- IRiskManager.cs: add quantity-aware ValidateOrder contract

- AdvancedRiskManager.cs: delegate Tier 1 through sized BasicRiskManager overload and preserve 3-arg behavior

- NT8StrategyBase.cs: remove BasicRiskManager type-check workaround and call sized interface method

- NT8OrderAdapter.cs: size before risk validation and pass actual contracts

- tests: add AdvancedRiskManager, NT8OrderAdapter, and NT8StrategyBase coverage

Build: clean | Tests: 566 passing; Core 476 passing | Dual-deployed: no - skipped by prompt
This commit is contained in:
2026-08-25 16:39:56 -04:00
parent a673475738
commit a99ce1d0e7
10 changed files with 388 additions and 15 deletions

View File

@@ -37,7 +37,7 @@
**[GAP-045 / GAP-046] Risk-envelope coherence guards** | Stage 0/1 | ✅ IMPLEMENTED — deployed 2026-08-23
- GAP-045: `MaxStopTicks` 50 × $5 = $250 > `MaxTradeRisk` $200 on NQ. Five valid signals rejected 2026-08-18 10:10 ET at $225.00. The top 20% of the ATR stop range is unreachable.
- GAP-046: `EnableTrailingDrawdown=True` with `AccountStartingBalance=$0.00` blocked every entry from 14:30 ET, 27 rejections. No startup assertion pairs the two.
- GAP-050: `MaxTradeRisk` has no quantity term — worst case is $600 against a $1,000 daily limit. v6.4 §3.2 documented a `× Qty` the code has never had.
- GAP-050: tracked separately below — its own entry has the corrected 2026-08-25 finding (live path already safe; fix scoped to the `IRiskManager` interface contract, not this NQ risk-guard work).
- **Decided 2026-08-19:** collision resolved via MNQ (staged separately, DEC-20260819-01); MaxTradeRisk is per-position (total). Tier 1 check reorders to post-sizing. Implement and validate on NQ first — MNQ cutover is a later, separate step.
- Prompt: `TASK_GAP045_GAP046_RISK_GUARDS_PROMPT.md` (Part 3 rewritten 2026-08-19, now fully actionable). Verification: `verify-build.bat` 535/535, Core Release no-build 446/446, deploy backup `20260823_144817`. Manual NT8 compile and NQ SIM validation still required; MNQ cutover remains separate.
@@ -88,6 +88,10 @@
- Found during GAP-054 verification (`DEC-20260821-01`): the regression test GAP-054's own task asked for (no `SetStopLoss` after `SetTrailStop` for a runner signal) was never written because no test seam exists — Kilocode correctly declined to fabricate coverage rather than write a fake test. Same defect class as GAP-054 (silent exit-order clobbering) currently has zero regression protection.
- Prompt: `TASK_GAP057_STOP_TRAIL_TEST_SEAM_PROMPT.md`. Implemented Option B: source-text regression seam. Added tests proving the runner entry block never calls `SetStopLoss(_runnerSignalName...)` after `SetTrailStop(_runnerSignalName...)`, the post-entry runner monitor in `OnBarUpdate()` contains no `SetStopLoss`/`SetTrailStop` calls, and no production order-management indirection was introduced. Verification: focused tests 3/3, `verify-build.bat` 558/558, Core Release no-build 469/469. Deploy intentionally skipped by task prompt.
**[GAP-050] MaxTradeRisk quantity term missing from IRiskManager contract** | Stage 1 | ✅ IMPLEMENTED — deploy skipped by prompt
- Originally flagged as a live risk-math gap ("$600 vs $1,000 daily limit"). Investigation on 2026-08-25 found the live path is already safe: `SimpleORBNT8`/`NT8StrategyBase` constructs `BasicRiskManager` directly and reaches its quantity-aware 4-arg `ValidateOrder` overload via a runtime type-check. The real gap is that `IRiskManager` itself never declared a quantity-aware member — `AdvancedRiskManager` (unwired to anything live) and `NT8OrderAdapter` (unwired scaffolding, also validates before sizing) would silently reintroduce the 1-contract assumption if either is ever wired up.
- Prompt: `TASK_GAP050_ADVANCED_RISK_QTY_PROMPT.md`. Implemented Option A: `IRiskManager` now declares the quantity-aware 4-arg `ValidateOrder`; `AdvancedRiskManager` delegates Tier 1 through the quantity-aware `BasicRiskManager` overload while retaining 3-arg one-contract behavior; `NT8StrategyBase` uses the interface directly instead of an `as BasicRiskManager` type-check; `NT8OrderAdapter` sizes first, rejects zero-size, then validates risk with the sized contract count. Verification: focused Core 10/10, focused Integration 13/13, `verify-build.bat` 566/566, Core Release no-build 476/476. Deploy intentionally skipped by task prompt.
**[GAP-061] Expose raw AVWAP/slope/trend-confirm inputs in STATE_CONTEXT telemetry** | Stage 1 | ✅ IMPLEMENTED — deploy skipped by prompt
- Found during the "zero trades this week" investigation (`DEC-20260825-04`): every real breakout this week and on 2026-08-18 capped at Grade B/C, driven by `Trend=0.30` on every best short setup. Source read confirmed the sharper asymmetry: `trend_confirm` is `avwapSlope > 0.0 ? 1.0 : 0.0`, while short-side slope alignment requires `avwapSlope < 0.0`, so a short cannot earn both bonuses.
- Prompt: `TASK_GAP061_AVWAP_TELEMETRY_PROMPT.md`. Implemented as observability-only: `STATE_CONTEXT` now includes `Avwap` (`F2`), `AvwapSlope` (`F4`), and `TrendConfirm` (`F1`) when those existing `context.CustomData` keys are present. Missing keys are omitted with no placeholders. No scoring, `trend_confirm`, `STATE:`, `STATE_DETAIL:`, risk, sizing, or order-flow logic changed. Verification: focused tests 7/7, `verify-build.bat` 561/561, Core Release no-build 472/472. Deploy intentionally skipped by task prompt.