chore: checkpoint contaminated Gate 2 findings

This commit is contained in:
2026-08-03 08:46:51 -04:00
parent 0c6b6b90a1
commit 56d7c7880e
21 changed files with 1593 additions and 892 deletions

View File

@@ -1,22 +1,25 @@
# Active Work
**Last Updated:** 2026-05-04
**Sprint:** 3 — Production Hardening
**Last Updated:** 2026-07-14
## Currently Active
**TASK-06a — Runner Mode Architecture**
- Spec: NT8_SDK_Master_Document_v6_Final.docx — Section 6.1
- Files: `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`
- Est: ~3 hrs
- Acceptance: RunnerMode enum exists; Auto mode resolves Mode1 (Qty≥2) or Mode2 (Qty=1);
Mode2 uses SetTrailStop only (no SetProfitTarget); [SDK] log confirms resolved mode;
verify-build.bat passes; all tests pass; dual-deployed to NT8 Custom.
- Prompt: `NEXT_PROMPT.md` (ready to paste)
## RB-4.1 — Gate Run #2 Configuration Freeze
**Owner:** Human operator
**State:** Active; gate clock has not started.
## Blockers
None currently.
1. Deploy the verified cleanup source to NinjaTrader Custom\Strategies and run NinjaTrader's compile check.
2. In SimSimple ORB, set and triple-check:
- `EnableDynamicStop=TRUE`
- `RunnerActivationMode=Auto`
- `RegimeGate=GradePenalty`
- `MinTradeGrade=A`
- `MaxDailyTrades=1`
- `TestMode=FALSE`
- `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-GATE2-CONFIG` with the frozen configuration and planned start date.
5. At gate start, enforce the no-dual-deploy rule. GAP-025 and GAP-022-FOLLOWUP remain branch-only work.
## Notes for Next Claude Review Session
- Feed `SPRINT_BOARD.md` + `docs/00-governance/current_status.md` to Claude
- Ask: "Review our state and plan the next workset"
- Claude will assess completed tasks, check learning files, and update SPRINT_BOARD.md
with any re-prioritization before the next Kilocode execution batch
## Parallel work, not a gate prerequisite
- GAP-025 runner no-fill diagnosis blocks live promotion, not Gate Run #2.
- GAP-022-FOLLOWUP needs an injectable connection-state seam before the three deferred scenarios can be implemented honestly.

View File

@@ -28,12 +28,21 @@ Record concise error fingerprints and verified fixes.
- Root cause: wrong overload or argument ordering.
- Fix: align call with exact method signature and parameter types.
6. **MaxDailyTrades overlap: second trade fires while first position still open**
5. **MaxDailyTrades overlap: second trade fires while first position still open**
- Root cause: `_tradeTaken` re-arm in `SimpleORBStrategy` is bar-driven, not position-close-driven. The strategy re-arms on the next bar after generating an intent, regardless of whether NT8 has closed the previous position.
- Risk: only relevant when `MaxDailyTrades > 1`. With default `MaxDailyTrades=1` this cannot occur.
- Mitigation (SIM): `MaxOpenPositions` and `DailyLossLimit` in NT8 adapter limit exposure.
- Fix (pre-live): wire re-arm to position-close callback in `NT8StrategyBase`. See DEC-20260429-01 in `docs/00-governance/decisions.md`.
5. **C# 6+ syntax in C# 5 project**
6. **C# 6+ syntax in C# 5 project**
- Root cause: use of `$""`, `?.`, `nameof`, expression-bodied members, etc.
- Fix: rewrite using C# 5 compatible constructs.
## New Entries
7. **Post-task build verification skipped -- build broken after task completion**
- Date: 2026-07-13
- Error: `CS0101` (duplicate `RunnerMode` enum), `CS0101` (duplicate `RunnerActivationMode` property), `CS1513` (unbalanced `#region`/`#endregion`)
- Fingerprint: `NT8StrategyBase.cs` ~line 249 (nested enum), ~line 279 (duplicate property), ~line 281 (extra `#endregion`)
- Root cause: Post-task build verification (`verify-build.bat` + `dotnet test`) was skipped after a previous task. Duplicate enum/property and unbalanced `#region`/`#endregion` compiled in IDE with Roslyn leniency but failed the strict dotnet CLI build used by NT8 SDK CI.
- Fix: Removed nested `RunnerMode` enum (keep namespace-level at line ~35), removed duplicate `RunnerActivationMode` property (keep `[NinjaScriptProperty]` version at line ~181), removed extra `#endregion` at line 281. Ran `verify-build.bat` + `dotnet test` -- 492 tests passed (10 perf + 78 integration + 404 core).
- Prevention link: Add mandatory `verify-build.bat && dotnet test --verbosity minimal` step to every task completion checklist in `docs/00-governance/decisions.md` and sprint templates.

View File

@@ -1,35 +1,24 @@
# Current Status
**Last Updated:** 2026-07-11 | **Sprint:** 3 — Production Hardening
**Last Completed Task:** GAP-009 — ATR Trailing Real ATR Wiring
**Active Task:** GAP-011 — Gitea CI Pipeline (see NEXT_PROMPT.md)
# Current Status — NT8 SDK
**Last Updated:** 2026-07-14
## Build State
- `dotnet build`: ✅ passing (baseline confirmed before Sprint 3 start)
- `dotnet test`: ✅ 492 passing (404 core + 78 integration + 10 performance)
- NT8 NinjaScript compile: ✅ confirmed in SIM
## Verified implementation state
- **Last completed task:** GAP-029 — Code-Version Provenance Stamp
- **Active task:** RB-4.1 — Gate Run #2 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
## SIM Validation Gate (Sprint 2 — ongoing parallel)
- Status: Collecting data
- Gate criteria: PF > 2.0, MaxDD < $500, 2+ weeks uninterrupted
- Gate met: NO — do not deploy live capital until gate is met
## Build and test evidence
- `verify-build.bat` completed successfully on 2026-07-14.
- Build: **0 errors**, **6 CS1998 warnings** in existing test mock/test methods.
- Tests: **497 passed, 0 failed** — 409 Core, 78 Integration, 10 Performance.
## Open Architecture Defects (block live trading)
| ID | Issue | Sprint | Status |
|---|---|---|---|
| TASK-06a | Runner Mode — useRunner = Qty≥2 is wrong architecture | 3 | ✅ COMPLETED |
| TASK-06b | ATR dynamic stop — fixed 8-tick stop too tight | 3 | ✅ COMPLETED |
| GAP-019 | Portfolio Heat Tier 3.5 not implemented | 3 | ✅ COMPLETED |
| GAP-003 | RiskPerTrade can exceed MaxTradeRisk silently | 3 | ✅ COMPLETED |
| GAP-004 | orbRangeTicks hardcoded 0.0 | 3 | ✅ COMPLETED |
| GAP-005 | GetRiskStatus() returns hardcoded value | 3 | ✅ COMPLETED |
| GAP-006 | _tradeTaken re-arm is bar-driven not position-close-driven | 3 | ✅ COMPLETED |
| GAP-010 | Short trades lack regime filter | 3 | ✅ COMPLETED |
| GAP-008 | No CME holiday awareness | 3 | ✅ COMPLETED |
| GAP-009 | ATR Trailing uses bar range not real ATR | 3 | ✅ COMPLETED |
| GAP-011 | No CI pipeline for Gitea | 3 | 🔴 ACTIVE |
## Gate readiness
- Provenance records have `session_id`, `trade_seq`, parameter-only `config_hash`, exact `session_tag`, and compiled `code_version` (assembly version + MVID).
- 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 start:** deploy the cleanup source to NinjaTrader Custom\Strategies and run the NinjaTrader compile check. Then freeze the configuration and enforce the no-deploy rule.
## Operational State
- Deploy script: `deployment\Deploy-To-NT8.ps1` — deletes DLL, forces full recompile ✅
- Kilocode rules: `.kilocode\rules\` — 14 active rule files ✅
- Sprint board: `SPRINT_BOARD.md` — tasks ordered, prompts staged in KILOCODE_RUNBOOK.md ✅
- Ideas backlog: `docs\IDEAS_BACKLOG.md` — add ideas here between sessions ✅
## Authoritative documents
- Master document: `docs/NT8_SDK_Master_Document_v6.1_Complete.docx`
- Operator runbook: `docs/02-runbooks/NT8_SDK_Operator_Runbook_v1.0.docx`
- Decision correction: `DEC-20260713-02`

View File

@@ -13,6 +13,16 @@ Use this file to record durable project decisions that affect implementation pat
## Decision Log
### DEC-20260713-01
- **ID:** DEC-20260713-01
- **Date:** 2026-07-13
- **Status:** accepted
- **Context:** July 11 sprint executed 11 tasks from old pre-v6.1 queue (TASK-06a, TASK-06b, GAP-003/004/005/006/008/009/010/011/019) but skipped v6.1-mandated TASK-00a/00b (provenance + chart diagnostics). HEAD left broken (duplicate enum/property). Sprint 2.6 executed repair + v6.1 instrumentation in strict order.
- **Decision:** Accept July 11 work as valid Sprint 2 substance; Sprint 2.6 completes v6.1 instrumentation. Next sprint = Sprint 3 (Second Strategy + MNQ).
- **Consequences:** Sprint numbering aligned with v6.1. Governance artifacts now match code reality. SIM gate requires all 5 Sprint 2.6 tasks + governance reconciliation before live.
- **Related Files:** `docs/00-governance/current_status.md`, `SPRINT_BOARD.md`, `KILOCODE_RUNBOOK.md`, `docs/00-governance/decisions.md`, `docs/00-governance/active_work.md`, `docs/INDEX.md`, `docs/archive/master_docs/NT8_SDK_Master_Document_v6.1_Complete.docx`, `docs/archive/master_docs/NT8_SDK_Operator_Runbook_v1.0.docx`
- **Action Required:** All Sprint 2.6 governance artifacts committed. Sprint 3 queue active in KILOCODE_RUNBOOK.md. SIM gate remains blocked until governance reconciliation complete.
### DEC-20260711-03
- **ID:** DEC-20260711-03
- **Date:** 2026-07-11
@@ -105,4 +115,45 @@ Use this file to record durable project decisions that affect implementation pat
- **Decision:** Added ATR-based trailing stop with 5 new parameters: `EnableATRTrailing` (default `false`), `ATRTrailingPeriod` (14), `ATRTrailingMultiplier` (2.0), `ATRTrailingMinTicks` (8), `ATRTrailingMaxTicks` (60). When `EnableATRTrailing=true` and `CurrentBars[0] >= ATRTrailingPeriod`, computes `trailTicks = clamp(round(ATR(Close, ATRTrailingPeriod)[0] / TickSize * ATRTrailingMultiplier), ATRTrailingMinTicks, ATRTrailingMaxTicks)` and calls `SetTrailStop` with this dynamic value instead of fixed `RunnerTrailTicks`. Added logging: `[SDK] ATR Trail: ATR={X}ticks x {Y} = {Z}ticks (clamped {Min}-{Max})`. When disabled, falls back to fixed `RunnerTrailTicks`.
- **Consequences:** Trailing stop now scales with volatility — tighter in quiet markets, wider in volatile. Backward compatible: `EnableATRTrailing=false` preserves fixed tick trail. Dual-deployed to NT8 Custom\Strategies\.
- **Related Files:** `src\NT8.Adapters\Strategies\NT8StrategyBase.cs` (5 params, ATR trailing logic in SubmitOrderToNT8, logging), `src\NT8.Strategies\Examples\SimpleORBStrategy.cs` (_enableAtrTrailing field, SetParameters, ATRTrailingPeriod/Multiplier/MinTicks/MaxTicks properties), `src\NT8.Adapters\Strategies\SimpleORBNT8.cs` (EnableATRTrailing, ATRTrailingPeriod/Multiplier/MinTicks/MaxTicks params + ConfigureStrategyParameters)
- **Action Required:** Verify in SIM with EnableATRTrailing=true — session log should show [SDK] ATR Trail line with computed value inside 8-60t; chart trail stop should sit at ATR distance, not fixed 20t.
- **Action Required:** Verify in SIM with EnableATRTrailing=true — session log should show [SDK] ATR Trail line with computed value inside 8-60t; chart trail stop should sit at ATR distance, not fixed 20t.
### DEC-20260713-01
- **ID:** DEC-20260713-01
- **Date:** 2026-07-13
- **Status:** superseded
- **Context:** Sprint 2.6 (July 11) completed all 5 technical tasks (TASK-FIX-01, TASK-00a, TASK-00b, TASK-06c, GAP-024) and build/tests passed (492 tests). However, the v6.1 Master Document and Operator Runbook (dated July 13) were not committed to the repository, and Sprint artifacts (SPRINT_BOARD.md, KILOCODE_RUNBOOK.md, current_status.md) still reflected Sprint 2.6 state. Governance required reconciliation: commit v6.1 docs to repo archive, promote Sprint 4 backlog to Sprint 3 queue, rewrite sprint artifacts for Sprint 3 (Second Strategy + MNQ Prep), and log this reconciliation decision.
- **Decision:**
1. Committed NT8_SDK_Master_Document_v6.1_Complete.docx and NT8_SDK_Operator_Runbook_v1.0.docx to docs/archive/master_docs/
2. Rewrote SPRINT_BOARD.md: all 6 Sprint 2.6 tasks marked COMPLETED; Sprint 4 backlog promoted to Sprint 3 queue (TASK-06a Runner Mode, TASK-06b ATR Dynamic Stop, GAP-019 Portfolio Heat, GAP-003 RiskPerTrade Assertion, GAP-004 orbRangeTicks Fix, GAP-005 GetRiskStatus, GAP-006 Position Close Re-arm, GAP-010 Short Regime Filter, GAP-008 CME Holiday, GAP-009 ATR Trailing, GAP-011 Gitea CI, GAP-022 Scenario Tests, GAP-007 Walk-Forward Docs)
3. Rewrote KILOCODE_RUNBOOK.md for Sprint 3 (Second Strategy + MNQ Prep) with TASK-06a, GAP-013, GAP-015, GAP-014, MNQ-001, MNQ-002 as the Sprint 3 queue
4. Logged DEC-20260713-01 in decisions.md (this entry)
5. Updated current_status.md to Sprint 3 handoff state
- **Consequences:** Sprint 2.6 governance fully reconciled. Sprint 3 queue defined and staged. SIM Gate remains blocked until governance reconciliation complete (now satisfied). All governance files consistent. Build and 492 tests still pass.
- **Related Files:** `docs/archive/master_docs/NT8_SDK_Master_Document_v6.1_Complete.docx`, `docs/archive/master_docs/NT8_SDK_Operator_Runbook_v1.0.docx`, `SPRINT_BOARD.md`, `KILOCODE_RUNBOOK.md`, `docs/00-governance/current_status.md`, `docs/00-governance/decisions.md`
- **Action Required:** Verify .\verify-build.bat ✅ | dotnet test ✅ (492 tests) | git status clean
### DEC-20260713-02
- **ID:** DEC-20260713-02
- **Date:** 2026-07-13
- **Status:** accepted
- **Context:** The 2026-07-13 reconciliation (DEC-20260713-01) incorrectly re-queued 12 implemented tasks, archived master docs, and staged TASK-06a as next action. Code greps confirm all 12 tasks already implemented in code (verified by grep on ResolveRunnerMode, EnableDynamicStop, orbRangeTicks, CmeHolidayCalendar, EnableShortTrendFilter, GetRiskStatus, OnPositionUpdate, clear_trade_taken, ValidatePortfolioHeat, RiskPerTrade).
- **Decision:** Restore governance to match code reality.
1. Move 12 July 11 tasks back to COMPLETED with 2026-07-11 dates in SPRINT_BOARD.md.
2. Sprint 2.7 queue = TASK-00a (reissued), GAP-024 data layer, GAP-022 scenario tests, GAP-025 diagnosis.
3. Move master docs from `docs/archive/master_docs/` → `docs/` + `docs/02-runbooks/`.
3. Overwrite NEXT_PROMPT.md with TASK-00a reissue (grep-verifiable acceptance).
4. Log this decision as DEC-20260713-02 superseding DEC-20260713-01.
5. Update current_status.md for Sprint 2.7.
- **Consequences:** Sprint numbering realigned (2.7 truth reconciliation before 3). Governance artifacts now match code greps. NEXT_PROMPT.md stages TASK-00a reissue. DEC-20260713-01 superseded by this entry.
- **Related Files:** `SPRINT_BOARD.md`, `KILOCODE_RUNBOOK.md`, `NEXT_PROMPT.md`, `docs/00-governance/current_status.md`, `docs/00-governance/decisions.md`, `docs/archive/master_docs/` (to be moved)
- **Action Required:** Complete TASK-GOV-02 (governance reconciliation), then TASK-00a reissue.
### DEC-20260714-01
- **ID:** DEC-20260714-01
- **Date:** 2026-07-14
- **Status:** accepted
- **Context:** `ComputeConfigHash()` correctly fingerprints NinjaScript parameters, but a mid-gate recompile or redeploy can change executable code while preserving every parameter value and therefore the same config hash.
- **Decision:** Persist a compiled-code stamp in all gate-relevant provenance. The stamp is the running assembly version plus `ManifestModule.ModuleVersionId`; it is written to session provenance, each trade JSONL record, settings exports, and the SimpleORB strategy snapshot. Each real-time signal also writes its TestMode/LIVE MODE state to the session file log.
- **Consequences:** Parameter drift and code drift are distinguishable without relying on a manually maintained git SHA. The Gate Run #2 procedure must archive both `ConfigHash` and `CodeVersion`, and it forbids dual-deploys after the configuration freeze.
- **Related Files:** `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`, `src/NT8.Strategies/Examples/SimpleORBStrategy.cs`, `docs/00-governance/patterns_and_antipatterns.md`, `SPRINT_BOARD.md`, `NEXT_PROMPT.md`.
- **Action Required:** Deploy the cleanup source, compile it in NinjaTrader, then record `DEC-GATE2-CONFIG` before starting the gate.

View File

@@ -48,3 +48,8 @@ Capture recurring implementation patterns that impact compile stability.
— can generate a second intent while first position is still open.
- Why it matters: see DEC-20260429-01 in `docs/00-governance/decisions.md`.
- Action required: wire re-arm to position-close callback in `NT8StrategyBase` before go-live.
8. **Compiled-code provenance stamp** (2026-07-14)
- Good pattern: persist the running assembly version plus `ManifestModule.ModuleVersionId` alongside the parameter-only configuration hash.
- Anti-pattern: treat an unchanged parameter hash as proof that unchanged code is running.
- Why it matters: a mid-gate recompile/redeploy can preserve settings while changing executable behavior; the module MVID makes that drift detectable in session and trade artifacts.

View File

@@ -1,5 +1,5 @@
# Roadmap
**Last Updated:** 2026-05-04
**Last Updated:** 2026-07-14
**Master Reference:** NT8_SDK_Master_Document_v6_Final.docx — Sections 7, 8, 21
## Sequencing Rule
@@ -35,6 +35,7 @@ Infrastructure:
- GAP-011: Gitea CI pipeline (build.yml)
- GAP-009: ATRTrailing real ATR wiring (replace proxy)
- GAP-022: 8 scenario tests (ATR spike, FOMC, partial fill, disconnect, etc.)
- GAP-030: Historical ORB state hydration — safely reconstruct the current day's 09:30–10:00 ET range after a late enable without evaluating historical bars as signals; retain the realtime replay guard and add no-historical-order tests.
- GAP-007: Walk-forward test setup documentation
Gate criteria for Sprint 3 → Sprint 4:

Binary file not shown.

View File

@@ -13,6 +13,10 @@ Navigation links in this file may be stale or broken.
## 📚 Documentation Structure
### Master Documents (v6.1 — Authoritative)
- **[NT8 SDK Master Document v6.1 Complete](NT8_SDK_Master_Document_v6.1_Complete.docx)** — Complete specification, architecture, all sprints, all gaps, all decisions
- **[NT8 SDK Operator Runbook v1.0](02-runbooks/NT8_SDK_Operator_Runbook_v1.0.docx)** — Operator procedures, SIM gate, go-live checklist, runbooks
### Getting Started
- **[Quick Start Guide](QUICK_START.md)** - Get trading in 10 minutes
- **[README](README.md)** - Project overview and main documentation

Binary file not shown.