# TASK: GAP-057 — no test seam exposes NinjaScript's SetStopLoss/SetTrailStop managed-order calls # Staged: 2026-08-21 (found during GAP-054 verification, DEC-20260821-01), promoted 2026-08-25 # Sprint: Stage 1 — test coverage only, zero trading-behaviour risk # Owner: Kilocode # Deploy: COMMIT ONLY — do NOT run deploy-to-nt8.bat or copy build output to # the live NT8 install as part of this task. Verify-build and commit # as usual; leave the deploy step for the operator to run manually # once ready. # ───────────────────────────────────────────────────────────────── ## THE DEFECT GAP-054 fixed a real, expensive bug: `SetStopLoss()` on `_runnerSignalName` was replacing the `SetTrailStop()` issued at entry, silently disabling the runner's trailing stop for its entire life (confirmed in 4/4 broker- confirmed trades — the trail was 12-16 ticks in profit when breakeven fired and got moved back to +1). The original `TASK_GAP054_RUNNER_TRAIL_PROMPT.md` asked for a regression test asserting no `SetStopLoss` call is issued after `SetTrailStop` for a runner signal, with instructions to propose the smallest test seam if none existed. Kilocode correctly declined to fabricate coverage rather than write a fake-passing test — but no concrete seam proposal was written up either, so this defect class (silent exit-order clobbering via NT8's managed-order Set() calls) currently has zero regression protection. If a future change reintroduces a similar clobber — even accidentally, e.g. a new breakeven-style feature calling `SetStopLoss` for a runner signal — it would not be caught by tests, only by the kind of manual source review that caught GAP-054 and this review's other findings tonight. ## READ-FIRST 1. Read `DEC-20260821-01` for the original finding. 2. Read the current runner/scaler order-management code in `NT8StrategyBase.cs` (the block GAP-054 touched, and the `SetTrailStop`/`SetStopLoss` call sites at entry, ~2188/2196 per `DEC-...` references) to understand the current (correct) call sequence you need to protect. 3. NinjaScript's `SetStopLoss`/`SetTrailStop`/managed-order calls (`EnterLongManaged` etc.) are NinjaTrader platform APIs — confirm whether they can be reached through any existing test double/wrapper in this codebase (check `NT8.Adapters/Wrappers/` — `SimpleORBNT8Wrapper.cs` and similar were used elsewhere this session for testability) or whether `NT8StrategyBase`/`SimpleORBNT8` call them directly with no seam at all, same as the class-can't-be-instantiated situation this session already established for other tests in these files. ## THE CHANGE Propose and implement the smallest seam that lets a test assert the call *sequence* (no `SetStopLoss` after `SetTrailStop` for the same signal name) without needing a live NinjaTrader instance. Options to weigh, pick one and justify it in your writeback: **Option A — extract an interface.** A thin `IOrderManagementCalls` (or similar) interface wrapping just the handful of Set()/managed-order calls this block uses, with a real NinjaScript-backed implementation and a test-double implementation that records call order. Larger diff, reusable for future order-flow tests beyond just this one defect class. **Option B — source-text assertion, same as established precedent.** If extracting a real seam would require touching NinjaScript-derived classes in a way that risks the actual order-flow code (not just adding a test hook), fall back to the same source-text-assertion pattern already used and accepted this session for `NT8StrategyBase.cs`/`SimpleORBNT8.cs` tests — assert the compiled method body contains the correct guard/order and does not contain the reintroduced-clobber pattern. Weaker coverage tier, but consistent with this class's established constraints and zero risk of the test scaffolding itself touching production order flow. State clearly in your writeback which you chose and why — this is exactly the kind of judgment call the original GAP-054 task asked for and didn't get answered. ## DO NOT - Do not change any order-flow, `SetStopLoss`/`SetTrailStop`, runner, or scaler logic — this task adds test coverage only, it does not touch GAP-054's fix. - Do not introduce a seam that changes real order submission timing or behavior, even subtly — if Option A is chosen, the real implementation must be a pure pass-through with no behavior change. ## TESTS (required) 1. A regression test proving the current (correct) behavior: no `SetStopLoss` call for `_runnerSignalName` after its `SetTrailStop` call. This is the test GAP-054 asked for and didn't get. 2. Whichever seam is chosen, a test proving the seam itself doesn't alter real call behavior (e.g. the real implementation forwards to the actual NinjaScript call unchanged). ## VALIDATION (operator) None required — test-only change, zero order-flow/risk/sizing behavior change. ## GOVERNANCE Track as [GAP-057] in SPRINT_BOARD.md. Update `docs/00-governance/decisions.md` `DEC-20260821-01` status to note GAP-057 implemented, which seam option was chosen and why. Reference: this task, `DEC-20260821-01`, `TASK_GAP054_RUNNER_TRAIL_PROMPT.md`.