From b20b621c4568d20acb8eecf7b29d6a059e408459 Mon Sep 17 00:00:00 2001 From: mo Date: Mon, 26 Oct 2026 12:12:00 -0400 Subject: [PATCH] [GAP-066]: run base initialization before ORB defaults --- SPRINT_BOARD.md | 15 ++++++++++----- docs/00-governance/active_work.md | 6 +++--- docs/00-governance/decisions.md | 13 +++++++++++-- src/NT8.Adapters/Strategies/SimpleORBNT8.cs | 4 ++-- .../Adapters/SimpleORBNT8DefaultsTests.cs | 14 ++++++++++++++ 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/SPRINT_BOARD.md b/SPRINT_BOARD.md index 99a7673..bda8b05 100644 --- a/SPRINT_BOARD.md +++ b/SPRINT_BOARD.md @@ -4,11 +4,11 @@ ## ▢️ 2026-10-24 STATE β€” read this first -**Run order of record: `NEXT_PROMPT.md`.** P0-E is complete: GAP-064 and governance sync committed separately on 2026-10-26; `verify-build.bat` passed 581 tests and the working tree is clean. P0-D / GAP-069 closed 2026-10-26 after the operator pushed `cleanup/wrappers-pass2` (`99e993b..5907e9c`); the branch is level with origin. Stage 0 remains in progress: the 2026-07-13 orphan `bin\Custom\Strategies\SimpleORBStrategy.cs` is **still deployed** (GAP-065). +**Run order of record: `NEXT_PROMPT.md`.** P0-E is complete: GAP-064 and governance sync committed separately on 2026-10-26; `verify-build.bat` passed 581 tests and the working tree is clean. P0-D / GAP-069 closed 2026-10-26 after the operator pushed `cleanup/wrappers-pass2` (`99e993b..5907e9c`). The operator completed P0-A quarantine on 2026-10-26 after the GAP-068 before-proof; deletion/recompile and the after-proof remain part of the single operator-controlled deploy sequence. | Area | State | Evidence | |---|---|---| -| Deployed code matches repo | ❌ | Orphan `SimpleORBStrategy.cs` still present (modified 2026-07-13). **GAP-065** | +| Deployed code matches repo | 🟑 | Orphan quarantined by operator 2026-10-26; deployed source equality/recompile not yet verified. **GAP-065** | | **Backtests trade** | ❌ **NO since 2026-08-18** | `session_20261019_155354.log`: `Account : Backtest`, `HistoricalReplayCatchup count=117`, zero `SUBMIT`. **GAP-077** | | Live SIM | 🟑 | 2026-10-05: 844 `WarmupIncomplete`, `ageSecondsβ‰ˆ602` β€” possible delayed data. **GAP-078** | | Working tree / push | βœ… | Operator push completed 2026-10-26; GAP-069 closed. Subsequent local commits are not pushed by this task. | @@ -18,12 +18,15 @@ **P0-D / GAP-069 closed (2026-10-26):** operator pushed `cleanup/wrappers-pass2` to origin (`99e993b..5907e9c`); branch confirmed level with origin. +**P0-A / GAP-065 operator quarantine (2026-10-26):** the pre-cleanup preflight check 6 failed and named unexpected `SimpleORBStrategy.cs` (deployed 2026-07-13). The operator quarantined it, `@@SimpleORBNT8Wrapper.cs`, `SDK*.zip`, and `.DS_Store` to `Documents\NT8_quarantine_20261026`. No deployed-folder cleanup was performed by Kilocode. Deployment/recompile and the preflight after-proof remain pending. + **Open blockers (v9.0 + 2026-10-24):** - **[GAP-077] Backtests take zero trades** | HIGH | πŸ”΄ NEW β€” live catch-up guard `State == State.Historical && Account != null` blocks every Strategy Analyzer intent because Analyzer uses the `Backtest` account. Also breaks backtest `MaxDailyTrades` counting. `DEC-20261024-01`; prompt `NEXT_PROMPT.md` App. B. -- **[GAP-065] Deployed-source divergence** | CRITICAL | operator P0-A sweep. `DEC-20260922-01`. +- **[GAP-065] Deployed-source divergence** | CRITICAL | P0-A quarantine done; deploy/recompile verification remains. `DEC-20260922-01`. - **[GAP-054] Runner trail failed a +$1,200 excursion** | CRITICAL | independent of GAP-065; `TASK_GAP054_FOLLOWUP_TRAIL_VALIDATION_FAILURE_PROMPT.md` (Stage 2). -- **[GAP-066] `base.OnStateChange()` last β€” overwrites 4 ORB defaults** | HIGH | `TASK_GAP066_SETDEFAULTS_ORDERING_PROMPT.md`. -- **[GAP-068] Deploy verification per-file only** | HIGH | βœ… Whole-folder preflight implemented; operator "before"/"after" proof pending (`TASK_GAP068_DEPLOY_VERIFICATION_PROMPT.md`). +- **[GAP-066] `base.OnStateChange()` last β€” overwrote 4 ORB defaults** | HIGH | βœ… Ordering fixed; operator settings-export validation remains after deploy/recompile (`TASK_GAP066_SETDEFAULTS_ORDERING_PROMPT.md`). +- **[GAP-068] Deploy verification per-file only** | HIGH | βœ… Whole-folder preflight implemented; before-proof captured 2026-10-26 (unexpected `SimpleORBStrategy.cs`); after-proof pending. +- **[GAP-068-FOLLOWUP] Preflight may hide type-collision evidence** | MEDIUM | Open 2026-10-26; see follow-up note below. Logging only, not implemented in this task. - **[GAP-069] Commits unpushed** | βœ… CLOSED 2026-10-26 | Operator push `99e993b..5907e9c`; branch level with origin. - **[GAP-064 / GAP-034] Silent zero-trade days** | root cause GAP-065; closes on N-02 SIM day showing `OrbRangeNotEstablished`. - **[GAP-062] `trend_confirm` direction fix** | ❌ never live (in the shadowed file). @@ -31,6 +34,8 @@ - **[GAP-078] Possible 10-min-delayed CME data** | MEDIUM, unverified | operator check at P0-G. `DEC-20261024-03`. - Also open from v9.0: GAP-070…076 (see v9.0 Β§7 and `DEC-20260922-01`). +**GAP-068-FOLLOWUP (MEDIUM, opened 2026-10-26; not implemented):** `Find-DeployedAssemblyTypeCollisions` has an empty catch that hides reflection/load failures, so the before-proof did not tag the orphan as a GAP-065 type collision despite `NT8.Strategies.dll` being present in `bin\Custom`. Also, the blanket root-level `@` prefix exemption let SDK-owned `@@SimpleORBNT8Wrapper.cs` pass unflagged. Follow-up: surface assembly scan failures in the check detail and run type-collision detection for `@`-prefixed files; retain the exemption from the unexpected-file failure only where policy intends it. + **Do not:** trust any Strategy Analyzer output produced before `NEXT_PROMPT.md` step 9; start Gate Run #3; run RUNNER-001; diagnose GAP-054 before P0-A. --- diff --git a/docs/00-governance/active_work.md b/docs/00-governance/active_work.md index 528ad77..633ec39 100644 --- a/docs/00-governance/active_work.md +++ b/docs/00-governance/active_work.md @@ -10,9 +10,9 @@ Run order of record: **`NEXT_PROMPT.md`**. Stage model from Master Document v9.0 |---|---|---|---| | P0-E | βœ… Complete 2026-10-26; GAP-064 `bf7acbb`, governance/prompt extraction `[GOV]` commit follows; 581 tests passed | `NEXT_PROMPT.md` App. A β†’ `TASK_P0E_TREE_RECONCILE_PROMPT.md` | Kilocode | | P0-D | βœ… CLOSED 2026-10-26; operator pushed `cleanup/wrappers-pass2` (`99e993b..5907e9c`), branch level with origin (GAP-069) | operator | Operator | -| P0-B | βœ… Implemented and committed 2026-10-26; whole-folder deploy verification (GAP-068), operator before/after run remains | `TASK_GAP068_DEPLOY_VERIFICATION_PROMPT.md` | Kilocode | -| P0-A | Delete orphan `SimpleORBStrategy.cs` + sweep `bin\Custom\Strategies` (GAP-065) | operator, after preflight "before" run | Operator | -| P0-C | `base.OnStateChange()` ordering (GAP-066) | `TASK_GAP066_SETDEFAULTS_ORDERING_PROMPT.md` | Kilocode | +| P0-B | βœ… Implemented and committed 2026-10-26; before-proof captured (check 6 failed on `SimpleORBStrategy.cs`); after-proof remains after deploy/recompile (GAP-068) | `TASK_GAP068_DEPLOY_VERIFICATION_PROMPT.md` | Kilocode / Operator | +| P0-A | βœ… Operator quarantine completed 2026-10-26 after before-proof; deploy/recompile verification remains (GAP-065) | `Documents\NT8_quarantine_20261026` | Operator | +| P0-C | βœ… Implemented and committed 2026-10-26; `base.OnStateChange()` precedes subclass defaults (GAP-066); settings-export validation follows deploy/recompile | `TASK_GAP066_SETDEFAULTS_ORDERING_PROMPT.md` | Kilocode / Operator | | P0-H | **Backtests blocked by live catch-up guard (GAP-077)** | `NEXT_PROMPT.md` App. B β†’ `TASK_GAP077_BACKTEST_HISTORICAL_GUARD_PROMPT.md` | Kilocode | | P0-G | `EnableKillSwitch=True`, `TraceOrders=true`; confirm real-time CME data (GAP-078) | operator | Operator | | β€” | Single deploy + full recompile, then validate: backtest (GAP-077), settings export (GAP-066), one SIM RTH day (N-02) | operator | Operator | diff --git a/docs/00-governance/decisions.md b/docs/00-governance/decisions.md index 179b9a0..79bfbce 100644 --- a/docs/00-governance/decisions.md +++ b/docs/00-governance/decisions.md @@ -13,14 +13,23 @@ Use this file to record durable project decisions that affect implementation pat ## Decision Log +### DEC-20261026-03 +- **ID:** DEC-20261026-03 +- **Date:** 2026-10-26 +- **Status:** implemented β€” GAP-066 base initialization ordering corrected; operator settings-export validation remains pending +- **Context:** `SimpleORBNT8.OnStateChange()` applied its `State.SetDefaults` values before calling `base.OnStateChange()`. The base then overwrote `RunnerTrailTicks` (20β†’12), `MinTradeGrade` (5β†’4), `MaxOpenPositions` (2β†’3), and `BarsRequiredToTrade` (50β†’1), as recorded in `DEC-20260922-01` and Master Document v9.0 Β§1.3 Finding 3 / Β§4.10. +- **Decision:** Call `base.OnStateChange()` first, then apply subclass state handling. The subclass `Configure` branch is currently comment-only and `DataLoaded` has no subclass branch, so moving the base call to the top preserves their behavior while making subclass defaults win. +- **Verification:** Added a source-order regression test asserting the base call precedes all four subclass assignments. `verify-build.bat` passed 582/582 tests (492 Core, 80 Integration, 10 Performance), zero warnings/errors. The task is ordering-only; no values changed. Operator must validate a fresh settings export after the controlled deploy/recompile. +- **Related Files:** `src/NT8.Adapters/Strategies/SimpleORBNT8.cs`, `tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs`, `DEC-20260922-01`, Master Document v9.0 Β§Β§1.3, 4.10. + ### DEC-20261026-01 - **ID:** DEC-20261026-01 - **Date:** 2026-10-26 - **Status:** implemented β€” GAP-068 whole-folder verification committed; operator before/after validation pending - **Context:** `tools/preflight/preflight.ps1` check 5 compared only deployed `NT8StrategyBase.cs`. `Write-DeployedSourceHashes` captured every Strategies `.cs` but did not compare them. This left the orphan-source failure in DEC-20260922-01 undetected; see Master Document v9.0 Β§1.3 Finding 1 and Β§4.4. - **Decision:** Compare the four `.cs` files copied to `bin\Custom\Strategies` by `deploy-to-nt8.bat` against repository SHA-256 values, and fail on any other `.cs` except `@` NinjaTrader samples, the operator's `@@` strategies, `ORBFibPullbackV1.cs`, and `MinimalTestStrategy.cs` (the last is retained despite the known deploy-script mismatch, GAP-073). Report each discrepancy with repository/deployed timestamps and, for unexpected files, same-name source paths and any same-type match found in deployed SDK/NT assemblies. Never delete deployed files from preflight. -- **Verification:** The standalone PowerShell fixture test exercises a matching file, hash mismatch, missing deployed file, allow-listed foreign file, and unexpected file; it passed separately from `verify-build.bat`. The operator must run the documented preflight before P0-A and retain the failure naming `SimpleORBStrategy.cs`; run it again after cleanup/recompile. -- **Scope note:** Manifest hashes and additional backup copies were not added; the secondary requests were deferred. `deployment/Verify-Deployment.ps1`'s `MinimalTestStrategy.cs` mismatch is documented and left unchanged. +- **Verification:** The standalone PowerShell fixture test exercises a matching file, hash mismatch, missing deployed file, allow-listed foreign file, and unexpected file; it passed separately from `verify-build.bat`. Operator captured the pre-cleanup run on 2026-10-26: check 6 failed and named unexpected `SimpleORBStrategy.cs` (deployed 2026-07-13). The operator then quarantined it, `@@SimpleORBNT8Wrapper.cs`, `SDK*.zip`, and `.DS_Store` under `Documents\NT8_quarantine_20261026`. The post-cleanup proof awaits deploy/recompile. +- **Scope note:** Manifest hashes and additional backup copies were not added; the secondary requests were deferred. `deployment/Verify-Deployment.ps1`'s `MinimalTestStrategy.cs` mismatch is documented and left unchanged. A follow-up was opened because reflection-load exceptions are swallowed and root-level `@` files skip type-collision checks; see GAP-068-FOLLOWUP in `SPRINT_BOARD.md`. - **Related Files:** `tools/preflight/preflight.ps1`, `tools/preflight/strategy-source-verification.ps1`, `tools/preflight/tests/strategy-source-verification.tests.ps1`, `deployment/deploy-to-nt8.bat`, `deployment/Verify-Deployment.ps1`, DEC-20260922-01, Master Document v9.0 Β§Β§1.3, 4.4. ### DEC-20261026-02 diff --git a/src/NT8.Adapters/Strategies/SimpleORBNT8.cs b/src/NT8.Adapters/Strategies/SimpleORBNT8.cs index 5642252..9160a54 100644 --- a/src/NT8.Adapters/Strategies/SimpleORBNT8.cs +++ b/src/NT8.Adapters/Strategies/SimpleORBNT8.cs @@ -111,6 +111,8 @@ namespace NinjaTrader.NinjaScript.Strategies protected override void OnStateChange() { + base.OnStateChange(); + if (State == State.SetDefaults) { Name = "Simple ORB NT8"; @@ -159,8 +161,6 @@ namespace NinjaTrader.NinjaScript.Strategies { // NT8StrategyBase adds the shared daily series for regime and ORB context at BarsArray[1]. } - - base.OnStateChange(); } protected override void OnBarUpdate() diff --git a/tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs b/tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs index 1925e98..8897122 100644 --- a/tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs +++ b/tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs @@ -18,6 +18,20 @@ namespace NT8.Core.Tests.Adapters Assert.IsFalse(setDefaults.Contains("EnableShortTrades = false;"), "SetDefaults must not disable short trades by default."); } + [TestMethod] + public void OnStateChange_BaseRunsBeforeOrbSetDefaultsAssignments() + { + string source = File.ReadAllText(FindSourceFile()); + string method = ExtractMethodBlock(source, "protected override void OnStateChange"); + int baseCall = method.IndexOf("base.OnStateChange();", StringComparison.Ordinal); + + Assert.IsTrue(baseCall >= 0, "OnStateChange must invoke the base implementation."); + Assert.IsTrue(baseCall < method.IndexOf("RunnerTrailTicks = 20;", StringComparison.Ordinal), "Base defaults must run before the subclass trail default."); + Assert.IsTrue(baseCall < method.IndexOf("MinTradeGrade = 5;", StringComparison.Ordinal), "Base defaults must run before the subclass grade default."); + Assert.IsTrue(baseCall < method.IndexOf("MaxOpenPositions = 2;", StringComparison.Ordinal), "Base defaults must run before the subclass position default."); + Assert.IsTrue(baseCall < method.IndexOf("BarsRequiredToTrade = 50;", StringComparison.Ordinal), "Base defaults must run before the subclass warm-up default."); + } + [TestMethod] public void BuildStateTelemetryIntent_DailyContext_UsesDirectionCorrectClone() {