From d4f5d4f04ac6630de209406391f5c22febd1ba73 Mon Sep 17 00:00:00 2001 From: mo Date: Mon, 3 Aug 2026 08:59:19 -0400 Subject: [PATCH] GAP-033: log session readiness for Gate 3 - report resolved DaysToLoad and loaded bars per series - report factor warm-up readiness without blocking startup - warn when SimSimple runs with kill switch disabled Build: clean | Tests: 500 passing | Dual-deployed: yes --- NEXT_PROMPT.md | 11 ++-- SPRINT_BOARD.md | 8 ++- docs/00-governance/active_work.md | 11 ++-- docs/00-governance/current_status.md | 3 +- .../patterns_and_antipatterns.md | 4 ++ .../Strategies/NT8StrategyBase.cs | 64 +++++++++++++++++++ 6 files changed, 89 insertions(+), 12 deletions(-) diff --git a/NEXT_PROMPT.md b/NEXT_PROMPT.md index 1c883b5..9e5ec67 100644 --- a/NEXT_PROMPT.md +++ b/NEXT_PROMPT.md @@ -5,8 +5,9 @@ This is a **human operator procedure**, not a coding task. Gate 2 was contaminated. Do not change strategy source or deploy any branch work after the Gate 3 configuration freeze. -1. Start NinjaTrader and use the NinjaScript Editor to compile the Gate 3 provenance and daily-limit fixes deployed on 2026-08-03. -2. In SimSimple ORB, set and triple-check: +1. Start NinjaTrader and use the NinjaScript Editor to compile all three Gate 3 remediations deployed on 2026-08-03. +2. Verify the session log reports each data series' `DaysToLoad` and loaded historical bars, `NarrowRangeFactorCalculator` and `OrbRangeVsAtrFactorCalculator` readiness, and no `EnableKillSwitch=False` warning for SimSimple. +3. In SimSimple ORB, set and triple-check: - `EnableDynamicStop=TRUE` - `RunnerActivationMode=Auto` - `RegimeGate=GradePenalty` @@ -16,8 +17,8 @@ This is a **human operator procedure**, not a coding task. Gate 2 was contaminat - `EnableFileLogging=TRUE` - `EnableVerboseLogging=TRUE` - `LogDirectory=C:\\Users\\billy\\Documents\\NinjaTrader 8\\log\\nt8-sdk` -3. Export the settings file. Record both `ConfigHash` and `CodeVersion` from the export. -4. Add `DEC-GATE3-CONFIG` to `docs/00-governance/decisions.md`, including the export location, frozen values, hashes/stamp, and gate start date. -5. At gate start, apply a no-dual-deploy freeze to the gate machine. Preserve daily `provenance_*.json` and `trades_*.jsonl` artifacts and write weekly runbook heartbeats. +4. Export the settings file. Record both `ConfigHash` and `CodeVersion` from the export. +5. Add `DEC-GATE3-CONFIG` to `docs/00-governance/decisions.md`, including the export location, frozen values, hashes/stamp, and gate start date. +6. At gate start, apply a no-dual-deploy freeze to the gate machine. Preserve daily `provenance_*.json` and `trades_*.jsonl` artifacts and write weekly runbook heartbeats. Acceptance: NinjaScript compilation succeeds, an auditable frozen-config record exists before Gate Run #3, and no branch work is deployed while the gate is active. diff --git a/SPRINT_BOARD.md b/SPRINT_BOARD.md index 2cb97c5..4b3d078 100644 --- a/SPRINT_BOARD.md +++ b/SPRINT_BOARD.md @@ -11,7 +11,7 @@ | Provenance | ✅ | Gate 3 fix serializes grade, score, submitted runner mode, and ORB ticks from the accepted intent/submission data. | | Scenario coverage | 🟡 | 5/8 genuine assertions; 3 explicitly deferred for missing seams. | | Gate Run #2 | ❌ | Contaminated; provenance defects were identified after the run. | -| Gate Run #3 | ⏳ | Provenance and daily-limit fixes deployed; complete the manual NinjaScript compile and freeze a new configuration. | +| Gate Run #3 | ⏳ | Three remediations deployed; complete the manual NinjaScript compile, verify session-start warnings, and freeze a new configuration. | > **Gate deployment rule:** Once RB-4.1 is recorded and Gate Run #2 begins, do not dual-deploy to the gate machine. Run GAP-025 and connection-seam work in branches only. @@ -57,6 +57,12 @@ - Same-session rejection logs `MaxDailyTrades reached`; next-session first entry is covered by tests. - Release build passed; 500 tests passed; deployed source and assembly hashes match. Manual NinjaScript compile remains part of RB-4.1. +**[GAP-033] Session Historical-Readiness and Gate Safety Logging** | ✅ 2026-08-03 +- Session startup logs `BarsRequiredToTrade`, resolved `DaysToLoad`, and actual loaded bars for every data series at DataLoaded and Realtime transition. +- Logs explicit 7-daily-bar NarrowRange and 5-daily-bar OrbRangeVsAtr readiness, warning without blocking when insufficient. +- Warns when `EnableKillSwitch=False` on an account containing `SimSimple`. +- Additive logging only; Release build and all 500 tests passed; deployed hashes match. Manual NinjaScript compile remains part of RB-4.1. + **[TASK-GOV-02] Governance Truth Reconciliation** | ✅ 2026-07-13 - Restored the July 11 historical record, corrected documentation placement, and logged DEC-20260713-02. diff --git a/docs/00-governance/active_work.md b/docs/00-governance/active_work.md index 156365b..53b03c8 100644 --- a/docs/00-governance/active_work.md +++ b/docs/00-governance/active_work.md @@ -5,8 +5,9 @@ **Owner:** Human operator **State:** Active; Gate 2 was contaminated and the Gate 3 clock has not started. -1. Start NinjaTrader and run the NinjaScript compile check for the Gate 3 provenance and daily-limit fixes deployed on 2026-08-03. -2. In SimSimple ORB, set and triple-check: +1. Start NinjaTrader and run the NinjaScript compile check for all three Gate 3 remediations deployed on 2026-08-03. +2. Verify session-start logging lists each series' `DaysToLoad` and loaded count, both factor warm-up results, and no SimSimple kill-switch warning. +3. In SimSimple ORB, set and triple-check: - `EnableDynamicStop=TRUE` - `RunnerActivationMode=Auto` - `RegimeGate=GradePenalty` @@ -16,9 +17,9 @@ - `EnableFileLogging=TRUE` - `EnableVerboseLogging=TRUE` - `LogDirectory=C:\\Users\\billy\\Documents\\NinjaTrader 8\\log\\nt8-sdk` -3. Export settings; preserve the parameter hash and code-version stamp. -4. Add `DEC-GATE3-CONFIG` with the frozen configuration and planned start date. -5. At Gate 3 start, enforce the no-dual-deploy rule. GAP-025 and GAP-022-FOLLOWUP remain branch-only work. +4. Export settings; preserve the parameter hash and code-version stamp. +5. Add `DEC-GATE3-CONFIG` with the frozen configuration and planned start date. +6. At Gate 3 start, enforce the no-dual-deploy rule. GAP-025 and GAP-022-FOLLOWUP remain branch-only work. ## Parallel work, not a gate prerequisite - GAP-025 runner no-fill diagnosis blocks live promotion, not Gate Run #2. diff --git a/docs/00-governance/current_status.md b/docs/00-governance/current_status.md index 5e9da48..104e3d3 100644 --- a/docs/00-governance/current_status.md +++ b/docs/00-governance/current_status.md @@ -2,7 +2,7 @@ **Last Updated:** 2026-08-03 ## Verified implementation state -- **Last completed task:** GAP-032 — Session-Scoped MaxDailyTrades Enforcement +- **Last completed task:** GAP-033 — Session Historical-Readiness and Gate Safety Logging - **Active task:** RB-4.1 — Gate Run #3 Configuration Freeze (human operator) - **Next code task:** GAP-025 — Runner No-Fill Anomaly Diagnosis (branch-only during the gate) - **Following code task:** GAP-022-FOLLOWUP — connection-state seam and the three deferred scenarios @@ -15,6 +15,7 @@ ## Gate readiness - Trade provenance now reads grade, weighted score, and ORB ticks from the accepted intent metadata and records the exact runner mode resolved for submission. - `MaxDailyTrades` now remains enforced after position-flat events and resets only when the trading session date rolls over. +- Session startup now records per-series load configuration/counts, factor warm-up readiness, and warns if the SimSimple gate account has its kill switch disabled. - Every real-time signal writes its `TEST MODE ACTIVE` or `LIVE MODE` status to the session file log. - GAP-022 has five real scenario assertions. Its remaining three requirements are deferred architecture work, not fabricated tests. - **Before Gate 3 start:** complete the pending NinjaTrader compile check, freeze the configuration, and enforce the no-deploy rule. diff --git a/docs/00-governance/patterns_and_antipatterns.md b/docs/00-governance/patterns_and_antipatterns.md index d3be726..5de5bb1 100644 --- a/docs/00-governance/patterns_and_antipatterns.md +++ b/docs/00-governance/patterns_and_antipatterns.md @@ -61,3 +61,7 @@ Capture recurring implementation patterns that impact compile stability. ## 2026-08-03 [GAP-032] — Session-scoped daily trade limits - **DO:** Increment on accepted intent and reset only when the trading session date changes. - **DON'T:** Re-arm a daily trade allowance when a position returns flat. + +## 2026-08-03 [GAP-033] — Non-blocking startup readiness evidence +- **DO:** Log resolved series load settings, actual bar counts, factor thresholds, and gate safety configuration at lifecycle transitions. +- **DON'T:** Turn an observability requirement into a new trading guard or mutate runtime configuration from logging code. diff --git a/src/NT8.Adapters/Strategies/NT8StrategyBase.cs b/src/NT8.Adapters/Strategies/NT8StrategyBase.cs index e6aef43..71d70de 100644 --- a/src/NT8.Adapters/Strategies/NT8StrategyBase.cs +++ b/src/NT8.Adapters/Strategies/NT8StrategyBase.cs @@ -505,6 +505,7 @@ namespace NinjaTrader.NinjaScript.Strategies // TASK-00a: Write session provenance on realtime transition WriteSessionProvenance(); + WriteHistoricalReadiness("REALTIME ELIGIBILITY"); WriteSettingsFile(); } else if (State == State.Terminated) @@ -950,9 +951,72 @@ namespace NinjaTrader.NinjaScript.Strategies FileLog(string.Format("Sizing : MinContracts={0} MaxContracts={1}", MinContracts, MaxContracts)); FileLog(string.Format("VerboseLog : {0} FileLog: {1}", EnableVerboseLogging, EnableFileLogging)); FileLog(string.Format("ConnectionLost : {0}", _connectionLost)); + WriteHistoricalReadiness("DATA LOADED"); FileLog("---"); } + private void WriteHistoricalReadiness(string phase) + { + FileLog(string.Format("Historical readiness [{0}] : BarsRequiredToTrade={1}", phase, BarsRequiredToTrade)); + + int dailyBars = 0; + if (BarsArray == null || BarsArray.Length == 0) + { + FileLog(string.Format("WARNING: Historical readiness [{0}] unavailable; no data series loaded.", phase)); + } + else + { + for (int i = 0; i < BarsArray.Length; i++) + { + int daysToLoad = 0; + int loadedBars = 0; + string seriesType = "Unknown"; + + if (BarsArray[i] != null) + { + loadedBars = BarsArray[i].Count; + if (BarsArray[i].BarsType != null) + { + daysToLoad = BarsArray[i].BarsType.DaysToLoad; + seriesType = BarsArray[i].BarsType.GetType().Name; + } + } + + FileLog(string.Format("DataSeries[{0}] : Type={1} DaysToLoad={2} HistoricalBarsLoaded={3}", + i, + seriesType, + daysToLoad, + loadedBars)); + + if (seriesType.IndexOf("DayBarsType", StringComparison.OrdinalIgnoreCase) >= 0) + dailyBars = loadedBars; + } + } + + bool narrowRangeReady = dailyBars >= 7; + bool orbRangeReady = dailyBars >= 5; + FileLog(string.Format("FactorWarmup : NarrowRangeFactorCalculator={0} ({1}/7 daily bars) OrbRangeVsAtrFactorCalculator={2} ({1}/5 daily bars)", + narrowRangeReady ? "SATISFIED" : "NOT SATISFIED", + dailyBars, + orbRangeReady ? "SATISFIED" : "NOT SATISFIED")); + + if (!narrowRangeReady || !orbRangeReady) + { + FileLog(string.Format("WARNING: Factor warm-up not satisfied before real-time order eligibility; daily bars={0}, NarrowRange requires 7, OrbRangeVsAtr requires 5. Strategy startup is not blocked.", + dailyBars)); + } + else + { + FileLog(string.Format("Factor warm-up confirmed before real-time order eligibility; daily bars={0}.", dailyBars)); + } + + string accountName = Account != null ? Account.Name : string.Empty; + if (!EnableKillSwitch && accountName.IndexOf("SimSimple", StringComparison.OrdinalIgnoreCase) >= 0) + { + FileLog(string.Format("WARNING: EnableKillSwitch=False for gate account {0}.", accountName)); + } + } + private void WriteSessionFooter() { FileLog("---");