# TASK: GAP-025 — runner/scaler order lifecycle invisible in the persistent session log # Staged: 2026-08-26 (long-queued Sprint 2.7 item, now prompted; DEC-20260825-07) # Sprint: Stage 1 — diagnostic logging 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 (why this is worth doing) GAP-025 has sat in the backlog since Sprint 2.7 as "Runner No-Fill Anomaly Diagnosis" with no concrete spec. Reading the actual order/execution handling in `NT8StrategyBase.cs` on 2026-08-26 found a real, specific gap that explains why a runner no-fill would be nearly undiagnosable from the session log alone: 1. **`OnOrderUpdate`** (`src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~1270-1301) never calls `FileLog` for any order state transition. It only `Print`s (visible live in NT8's Output window only, not in the persistent session file) and only takes any other action (`_circuitBreaker.RecordOrderRejection`) for the `Rejected` state specifically. Every other transition an order goes through — submitted, accepted, working, part-filled, cancelled — is invisible in the file log entirely. If a runner order is submitted but never acknowledged, or acknowledged but later cancelled by the broker, or stuck in a pending state, none of that appears anywhere in `session_*.log`. 2. **`OnExecutionUpdate`**'s `FILL` line (`NT8StrategyBase.cs` ~1306-1345) logs market position, quantity, price, and order ID — but not the order/signal name. Since a single trade submits two independently named orders (`SDK_{Symbol}_S_{hex}` for the scaler leg, `SDK_{Symbol}_R_{hex}` for the runner leg — see `SubmitOrderToNT8`, `NT8StrategyBase.cs` ~2240-2242), a `FILL` line in the log currently cannot tell you *which leg* filled. You cannot distinguish "the runner never got submitted," "the runner was submitted and rejected," "the runner is still working, unfilled," and "the runner filled but the scaler didn't" purely from the file log — diagnosing any of GAP-025's original "no-fill anomaly" concern currently requires NT8's live Output window open at the exact moment, which defeats the purpose of file-based session logging (the same motivation GAP-035 was originally built for). This task closes that gap: make the full order lifecycle for both legs independently visible in the persistent session log after the fact, with zero change to order-management or execution logic itself. ## READ-FIRST 1. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~1270-1345 — `OnOrderUpdate`/`OnExecutionUpdate`, the two methods this task changes. 2. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~2171-2350 — `SubmitOrderToNT8`, to confirm the `_scalerSignalName`/ `_runnerSignalName` naming convention and the existing `SIGNAL`/ `SUBMIT` FileLog lines this task's new lines will sit alongside. 3. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` — the existing `FileLog` method (find its definition) to confirm signature and any existing rate-limiting/formatting conventions to stay consistent with. 4. `tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs` — the established source-text-assertion pattern this codebase already uses for `NT8StrategyBase`/`SimpleORBNT8` methods that can't be instantiated or invoked outside a live NT8 host (NinjaScript-derived classes). This task's tests will likely follow the same pattern. ## THE CHANGE 1. **`OnOrderUpdate`**: for orders whose `order.Name` starts with `SDK_` (the existing filter already applied earlier in the method), add a `FileLog` call on every invocation — not just on `Rejected` — recording at minimum: the order name (signal, so scaler vs runner is identifiable), `orderState`, `filled`/`quantity`, and `averageFillPrice`. Suggested format (adjust to match this file's existing `FileLog` conventions): `ORDER {order.Name} State={orderState} Filled={filled}/{quantity} AvgFillPrice={averageFillPrice:F2}`. Gate it the same way other per-bar `FileLog` calls in this file are gated (state/logging-enabled checks — check how nearby methods do it, e.g. `OnExecutionUpdate`'s existing `State != State.Realtime` guard, and mirror that convention here too — catch-up replay order-state noise should not flood the live session log any more than fills already avoid it). Keep the existing `Print` call, the existing `Rejected`-specific `_circuitBreaker.RecordOrderRejection` call, and the existing `_executionAdapter.ProcessOrderUpdate` call completely unchanged — this is purely an additional `FileLog` line, not a replacement. 2. **`OnExecutionUpdate`**: add the order/signal name (`execution.Order.Name`) to the existing `FILL` line so scaler and runner fills are distinguishable after the fact. Do not change the line's other fields, the `OrderFill`/`PortfolioRiskManager.ReportFill` call, or the `_executionAdapter.ProcessExecution` call. ## DO NOT - Do not change `SubmitOrderToNT8`, `EnterLong`/`EnterShort`, `SetStopLoss`/`SetTrailStop`/`SetProfitTarget`, or any order-submission logic — this task only adds logging around order/execution events that already occur. - Do not change `_circuitBreaker` logic, `_executionAdapter.ProcessOrderUpdate`/ `ProcessExecution` call arguments, or `PortfolioRiskManager.ReportFill`. - Do not change the existing `SIGNAL`/`SUBMIT`/`STATE`/`STATE_DETAIL`/ `STATE_CONTEXT`/`PNL_UPDATE`/`REJECT`/`REJECT SUMMARY` line formats — only add the new `ORDER` line and extend the existing `FILL` line with one additional field. - Do not touch risk, sizing, or grade-filter code. ## TESTS (required) 1. A test proving `OnOrderUpdate` now emits a `FileLog` call (source-text assertion, consistent with this codebase's established pattern for NinjaScript-derived methods — grep the compiled method body for the new `FileLog`/`ORDER` call, same tier as `SimpleORBNT8DefaultsTests.cs`'s existing tests) for state transitions beyond `Rejected`, not just the rejection case. 2. A test proving the `FILL` line format in `OnExecutionUpdate` now includes the order/signal name. 3. A test proving the existing `Rejected`-specific `_circuitBreaker` behavior and the existing `ProcessOrderUpdate`/`ProcessExecution` calls are unchanged (still present, same call sites, same arguments) — this task must be additive only. 4. Confirm the full existing suite still passes. ## VALIDATION (operator) No live order-management behavior changes — this is additive logging only. Genuine validation is observational: the next SIM trade with an active runner leg should show separately identifiable `ORDER SDK_..._S_...` and `ORDER SDK_..._R_...` lines through their full lifecycle in `session_*.log`, and `FILL` lines that name which leg filled. If the runner leg has ever silently failed to fill, this is what will finally show why — submitted-but-never-accepted, accepted-but-cancelled, or genuinely never filled while working. ## GOVERNANCE Track as [GAP-025] in SPRINT_BOARD.md — move out of the "QUEUED — branch-only during Gate Run #2" framing (that gate-sequencing language is stale; this is diagnostic-only and safe to prompt now) into an IMPLEMENTED/PROMPTED entry consistent with tonight's other tasks. Update `docs/00-governance/decisions.md` with a new dated entry referencing this task and `DEC-20260825-07`. Reference: this task, `DEC-20260825-07`, `TASK_GAP054_RUNNER_TRAIL_PROMPT.md` (the related runner-trail fix this diagnostic work follows up on).