Sprint 3: Production Hardening — 9 tasks completed

## Summary
Implemented 9 production-hardening tasks across risk, execution, calendar, and governance.
All changes verified: build clean (0 errors), 492 tests passing (404 core + 78 integration + 10 perf).

## Core Changes

### Risk & Portfolio (3 tasks)
- **GAP-019** Portfolio Heat Tier 3.5: Added MaxHeatPct (default 3%) to AdvancedRiskConfig;
  ValidatePortfolioHeat() computes TotalOpenRisk + NewTradeRisk / Equity * 100; rejects when exceeded.
- **GAP-003** RiskPerTrade <= MaxTradeRisk Assertion: RiskPerTrade property in RiskConfig; throws
  ArgumentException at ValidateOrder() if RiskPerTrade > MaxTradeRisk; 3 unit tests.
- **GAP-005** GetRiskStatus() Live Config: _currentDailyLossLimit field updated from config.DailyLossLimit
  on each ValidateOrder(); GetRiskStatus() returns actual value; 3 unit tests.

### Execution & Position Management (3 tasks)
- **TASK-06a** Runner Mode Architecture: RunnerMode enum (Auto/Mode1DualLeg/Mode2RunnerOnly/
  Mode3ScalerOnly/Disabled); ResolveRunnerMode() logic; 4-mode SubmitOrderToNT8() behavior.
- **TASK-06b** ATR Dynamic Stop: EnableDynamicStop, AtrPeriod, AtrMultiplier, MinStopTicks, MaxStopTicks;
  computes dynStop = clamp(round(ATR/TickSize * Mult), Min, Max); overrides intent.StopTicks.
- **GAP-006** Position-Close Re-arm: OnPositionUpdate() sends clear_trade_taken when flat;
  EnableBarBasedRearm parameter gates legacy bar-driven re-arm (default false for live).

### Strategy Intelligence (2 tasks)
- **GAP-004** orbRangeTicks Fix: DailyBarContext.OrbRangeTicks field; computed from actual ORB
  high/low / TickSize; passed to Factor 7 (ORBvsATR).
- **GAP-010** Short-Side Regime Filter: EnableShortTrendFilter param; vetoes shorts when
  AVWAP slope > 0 (bullish); configurable, default true.

### Calendar & Trailing (2 tasks)
- **GAP-008** CME Holiday Awareness: NEW CmeHolidayCalendar.cs with 9 observed holidays +
  Good Friday (Easter calc); EnableCMEHolidayGuard skips ORB window on holidays.
- **GAP-009** ATR Trailing Real ATR: EnableATRTrailing, ATRTrailingPeriod (14), ATRTrailingMultiplier (2.0),
  ATRTrailingMinTicks (8), ATRTrailingMaxTicks (60); computes trailTicks from ATR(Close,Period)[0].

## Governance
- SPRINT_BOARD.md, current_status.md, decisions.md (DEC-20260711-01 through -09), NEXT_PROMPT.md updated
- All 9 tasks moved ACTIVE -> COMPLETED; GAP-011 (Gitea CI) now ACTIVE

## Verification
- verify-build.bat: 0 errors, 0 warnings
- Tests: 492 passing (404 core + 78 integration + 10 performance)

## Files
- Modified: 13 source, 3 test, 9 governance
- Deleted: 28 obsolete spec/docs
- Added: 1 new module (NT8.Core.Calendar), governance files
- Dual-deployed to NT8 Custom\Strategies\

## Rollback
Tag: sprint3-production-hardening-complete
To revert: git reset --hard sprint3-production-hardening-complete
This commit is contained in:
2026-07-13 08:38:25 -04:00
parent 99e993bee6
commit c9041df36a
64 changed files with 3338 additions and 825 deletions

View File

@@ -1,31 +1,34 @@
# Governance Docs Maintenance Policy
**Last Updated:** 2026-04-05
# Documentation Maintenance Rules
**Last Updated:** 2026-05-04
## Canonical Source Rule
- [ ] `docs/00-governance/*` is the canonical planning and execution source.
- [ ] Prefer updating canonical governance docs over duplicating guidance elsewhere.
These rules govern how and when documentation is updated during implementation.
## Historical/Contextual Docs (Read-Only by Default)
Treat these as non-canonical unless explicitly requested by task scope:
- `README.md`
- `docs/README.md`
- `PROJECT_HANDOVER.md`
- `DESIGNED_VS_IMPLEMENTED_GAP_ANALYSIS.md`
- `docs/INDEX.md`
## When to Update Each File
## Update Triggers
- [ ] Update `docs/00-governance/active_work.md` when priorities, status, blockers, or ownership change.
- [ ] Update `docs/00-governance/roadmap.md` when milestone sequence, scope, or timing changes.
- [ ] Update `docs/00-governance/decisions.md` when durable architecture tradeoffs/decisions are made.
- [ ] Update `CLEANUP_LOG.md` when cleanup debt is created, resolved, or deferred.
| File | Update Trigger |
|---|---|
| `SPRINT_BOARD.md` | Every task completion — move ACTIVE → COMPLETED, advance QUEUE → ACTIVE |
| `NEXT_PROMPT.md` | Every task completion — overwrite with next task's full prompt |
| `docs/00-governance/current_status.md` | Every task completion — update dates, active task, next task |
| `docs/00-governance/active_work.md` | Every task completion — update to reflect new active task |
| `docs/00-governance/common_failures.md` | When any NT8 API surprise or runtime issue is encountered |
| `docs/00-governance/compile_guardrails.md` | When any compile error is encountered and resolved |
| `docs/00-governance/patterns_and_antipatterns.md` | When a working implementation pattern is confirmed |
| `docs/00-governance/decisions.md` | When a durable architectural decision is made |
| `docs/00-governance/roadmap.md` | When sprint scope, sequence, or gate criteria change |
| `docs/IDEAS_BACKLOG.md` | Whenever a new idea surfaces (add freely, Claude structures) |
## Compile Knowledge Capture (Concise and Durable)
When a compile issue occurs, record:
- [ ] Prevention rule in `docs/00-governance/compile_guardrails.md`.
- [ ] Error fingerprint + fix in `docs/00-governance/common_failures.md`.
- [ ] Reusable pattern and anti-pattern in `docs/00-governance/patterns_and_antipatterns.md`.
## Self-Learning Loop
The complete protocol is in `.kilocode/rules/self_learning_loop.md`.
That file is the authoritative source. This file is a summary only.
## Documentation Hygiene
- [ ] Keep entries concise, actionable, and dated.
- [ ] Link to authoritative rules instead of duplicating long guidance.
- [ ] Do not update unrelated docs in the same task.
## What NOT to Update During Implementation
- Do not edit KILOCODE_RUNBOOK.md prompts mid-task (edit only between tasks)
- Do not edit SPRINT_BOARD.md QUEUE order without noting it in active_work.md
- Do not modify docs/archive/ contents (archive is read-only history)
## Format Rules
- All dates: YYYY-MM-DD
- All task IDs: [TASK-06a], [GAP-019] format with brackets
- All learning entries: start with `## [date] [task-id] —` for easy searching
- Git commit messages: follow format in project_context.md

View File

@@ -1,45 +1,65 @@
# Project Context - NT8 SDK
**Last Updated:** 2026-04-05
# Project Context — NT8 SDK
**Last Updated:** 2026-05-04 (Sprint 3 reboot)
**Master Reference:** `NT8_SDK_Master_Document_v6_Final.docx` (22 sections + Appendices A–F)
Mission: ship safe, compile-stable NT8 trading software with strict scope control and durable governance documentation.
## Mission
Ship safe, compile-stable NT8 trading software. Execute the sprint board. Self-maintain documentation.
## Session Start (Mandatory)
- [ ] Read these files first, in order:
1. `docs/00-governance/executive_summary.md`
2. `docs/00-governance/current_status.md`
3. `docs/00-governance/active_work.md`
4. `docs/00-governance/architecture.md`
5. `docs/00-governance/roadmap.md`
- [ ] Treat `docs/00-governance/*` as canonical for current direction.
---
## Historical/Contextual Sources (Non-Canonical)
Use only for background unless explicitly requested in task scope:
- `README.md`
- `docs/README.md`
- `PROJECT_HANDOVER.md`
- `DESIGNED_VS_IMPLEMENTED_GAP_ANALYSIS.md`
- `docs/INDEX.md`
## Session Start (Mandatory — read in this order)
1. `docs/00-governance/executive_summary.md` — current system state
2. `docs/00-governance/current_status.md` — what is working, what is active, what is next
3. `docs/00-governance/active_work.md` — the specific task being implemented
4. `SPRINT_BOARD.md` — full task queue and status
5. `.kilocode/rules/self_learning_loop.md` — mandatory end-of-session protocol
## File Touch Scope (Hard Rules)
- [ ] Modify only files explicitly listed in the task spec.
- [ ] Do not edit adjacent files for cleanup or style-only changes.
- [ ] If a required fix is outside scope, stop and record a scope blocker.
- [ ] Respect `.kilocode/rules/file_boundaries.md` at all times.
**Do not begin coding until you know:**
- Which exact task is ACTIVE
- Which files you are allowed to touch
- What the acceptance criteria are
## Conversation Separation (Hard Rules)
- [ ] Strategy conversations: entry/exit logic and behavior.
- [ ] Architecture conversations: cross-component design and interfaces.
- [ ] Coding conversations: implementation details and diffs.
- [ ] Do not mix decisions across tracks; record architecture decisions in `docs/00-governance/decisions.md`.
---
## Documentation Sync Triggers
Update governance docs as part of normal task completion:
- [ ] Update `docs/00-governance/active_work.md` when current priorities, status, blockers, or ownership change.
- [ ] Update `docs/00-governance/roadmap.md` when milestone sequence, scope, or timing changes.
- [ ] Update `docs/00-governance/decisions.md` when a durable tradeoff or architecture decision is made.
- [ ] Update `CLEANUP_LOG.md` when cleanup debt is created, resolved, or deferred.
## Session End (Mandatory — do not skip)
Follow `.kilocode/rules/self_learning_loop.md` completely. All 6 steps. Every time.
## Compatibility and Safety Baselines
- [ ] C# 5.0 only (`.kilocode/rules/csharp_50_syntax.md`).
- [ ] NT8 compile safety (`.kilocode/rules/ninjascript_guardrails.md`, `.kilocode/rules/nt8compilespec.md`).
- [ ] Verification gates (`.kilocode/rules/verification_requirements.md`).
---
## Hard Constraints (Non-negotiable)
- C# 5.0 only — no `$""`, no `?.`, no `=>` expression-bodied members, no `async/await`
- Verify NT8 API signatures at `https://developer.ninjatrader.com/docs/desktop` before any implementation
- Dual-deploy rule: every change to `src/NT8.Adapters/Strategies/` MUST ALSO go to
`C:\Users\billy\Documents\NinjaTrader 8\bin\Custom\Strategies\` in the same task
- Delete `NinjaTrader.Custom.dll` before NT8 startup on every deploy (deploy script handles this)
- `SetStopLoss` / `SetProfitTarget` MUST be called BEFORE `EnterLong` / `EnterShort`
- `EntriesPerDirection = 2` required for dual-leg Runner Mode 1 architecture
---
## File Touch Scope
- Modify ONLY files explicitly listed in the active task spec
- Do not touch adjacent files for cleanup or style-only changes
- If a required fix is outside scope, stop and add it as a BLOCKED item in SPRINT_BOARD.md
- Respect `.kilocode/rules/file_boundaries.md` at all times
---
## Known Architecture State
- Runner leg redesigned in Sprint 3 (TASK-06a): RunnerMode enum replaces Qty≥2 gate
- ATR dynamic stop added in Sprint 3 (TASK-06b): EnableDynamicStop parameter
- Portfolio Heat (Tier 3.5) added in Sprint 3 (GAP-019): MaxHeatPct enforcement
- All prior tasks TASK-01 through TASK-05 are COMPLETE (archived in docs/archive/completed-tasks/)
---
## Git Commit Format (always follow this)
```
[TASK-ID]: [task name] complete
- [file]: [what changed]
- SPRINT_BOARD.md: [old] → [new active]
- NEXT_PROMPT.md: staged [next task]
Build: clean | Tests: [N] passing
```

View File

@@ -0,0 +1,116 @@
# Self-Learning Loop — Mandatory Session End Protocol
**This rule fires at the end of EVERY task. No exceptions.**
Kilocode MUST complete all 6 steps before declaring any task done.
---
## STEP 1 — Verify Build and Tests (Non-negotiable gate)
Run build verification:
```
.\verify-build.bat
```
Expected: `✅ All checks passed!` — zero errors, zero warnings.
**If it fails: fix before proceeding. Do NOT move to Step 2 with a failing build.**
Run tests:
```
dotnet test tests/NT8.Core.Tests/NT8.Core.Tests.csproj --no-build --verbosity minimal
```
Expected: All tests pass, 0 failed.
**If any fail: fix before proceeding.**
---
## STEP 2 — Update SPRINT_BOARD.md
1. Find the completed task under `## 🔵 ACTIVE`
2. Move it to `## ✅ COMPLETED THIS SPRINT` and append ` — ✅ [YYYY-MM-DD]`
3. Find the next task at the top of `## ⬜ QUEUE`
4. Move it to `## 🔵 ACTIVE`
5. Save SPRINT_BOARD.md
---
## STEP 3 — Write Learnings to Governance
For each of these questions, append to the file if YES:
**Did this task reveal an NT8 API surprise or runtime behavior?**
→ Append to `docs/00-governance/common_failures.md`:
```
## [YYYY-MM-DD] [TASK-ID] — [one-line symptom]
- **Root cause:** [what caused it]
- **Fix:** [what fixed it]
- **Prevention:** [how to avoid in future]
```
**Did this task cause or reveal a compile error?**
→ Also append to `docs/00-governance/compile_guardrails.md`:
```
## [YYYY-MM-DD] [TASK-ID] — [error code/description]
- **Pattern to avoid:** [the problematic pattern]
- **Correct pattern:** [the working replacement]
```
**Did this task confirm a working implementation pattern?**
→ Append to `docs/00-governance/patterns_and_antipatterns.md`:
```
## [YYYY-MM-DD] [TASK-ID] — [pattern name]
- **✅ DO:** [correct pattern with code example]
- **❌ DON'T:** [incorrect pattern]
```
If no new learnings: skip Step 3 (write nothing, don't create empty entries).
---
## STEP 4 — Stage NEXT_PROMPT.md
1. Read the new ACTIVE task from SPRINT_BOARD.md
2. Find that task's full prompt in KILOCODE_RUNBOOK.md
3. Overwrite `NEXT_PROMPT.md` with exactly this format:
```
# NEXT: [TASK-ID] — [Task Name]
# Staged: [YYYY-MM-DD]
# Sprint: [N] | Estimated: [X hrs]
# ─────────────────────────────────────────────────────────────────
[paste the full Kilocode prompt here verbatim from KILOCODE_RUNBOOK.md]
```
---
## STEP 5 — Update Current Status
Edit `docs/00-governance/current_status.md`:
- Change `Last Completed Task:` to the task just finished
- Change `Active Task:` to the new active task
- Change `Next Task:` to the task after that
- Update `Last Updated:` date
---
## STEP 6 — Git Commit Everything
Stage and commit all changes:
```
git add -A
git commit -m "[TASK-ID]: [task name] complete
- [file1]: [what changed — one line]
- [file2]: [what changed — one line]
- SPRINT_BOARD.md: [old active] → [new active]
- NEXT_PROMPT.md: staged [new active task]
- docs/00-governance/current_status.md: updated
Build: clean | Tests: [N] passing | Dual-deployed: [yes/no]"
```
---
## Why This Matters
Every session adds to compound institutional memory. Governance files that update
themselves mean zero re-alignment time between sessions. NEXT_PROMPT.md means the
next task is always one paste away. Learning files mean the same compile error
never appears twice. This is how one developer moves at team speed.