Files
nt8-sdk/TASK_GAP064_SILENT_SIGNAL_PIPELINE_PROMPT.md
mo 5907e9cc54
Some checks failed
CI Build & Test / Build & Test (Windows) (push) Has been cancelled
CI Build & Test / Build & Test (Linux/mono) (push) Has been cancelled
[GOV]: sync governance to v9.0 + 2026-10-24 findings; stage GAP-077/067 prompts
2026-10-26 08:12:20 -04:00

142 lines
10 KiB
Markdown

# TASK: GAP-064 — real order-evaluation/reject pipeline appears completely silent across two trading days
# Staged: 2026-09-04 (urgent — likely root cause of "no trades" reports; live strategy currently running,
# do not restart it until this task has captured what it needs from the live session, unless the
# operator decides otherwise)
# Sprint: Stage 2 — diagnostic-first; do not change order-evaluation or logging behavior until root cause
# is confirmed
# 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.
# ─────────────────────────────────────────────────────────────────
## THE SYMPTOM
`session_20260903_143151.log` (continuously running since 2026-09-03 14:31:51 ET, spanning through
2026-09-04 RTH with no restart) shows:
- **Zero `SIGNAL:` lines** in the entire session.
- **Zero `REJECT:`/`REJECT SUMMARY:` lines for `OrbRangeNotEstablished`, `GradeFilter`, `MaxDailyTrades`,
or `RegimeVeto`** — the reasons that should dominate a normal trading day. `grep -c OrbRangeNotEstablished`
and `grep -c GradeFilter` against the full file both return `0`.
- The only reject reasons that ever appear are `RthGuard`, `HistoricalReplayCatchup`, and
`WarmupIncomplete` — all three froze at a fixed count once RTH began on 2026-09-04 (`RthGuard count=197`
from ~09:30 ET onward, unchanged through at least 14:40 ET) and never incremented again.
- **Meanwhile `STATE:`/`STATE_DETAIL:`/`STATE_CONTEXT:` telemetry looks completely normal** — real
`DirectionSource=PendingBreakout` evaluations appear every 5 minutes with plausible, moving scores
(e.g. `14:00:00.056] STATE: ... DirectionSource=PendingBreakout Score=0.391 Grade=F ...`), and
`AvwapSlope`/`Avwap` in `STATE_CONTEXT` are visibly updating bar to bar.
This combination — telemetry alive, real evaluation/reject output completely dead — is what makes this
dangerous: the session log and dashboard both look like a normal quiet day, not a broken one.
`OrbRangeNotEstablished` specifically should be close to impossible to have zero occurrences of. Per
`SimpleORBStrategy.cs` line ~600, once the ORB window closes with no confirmed breakout yet, every bar
that doesn't arm a fresh breakout candidate falls through to:
```
RecordSignalRejection(context, "OrbRangeNotEstablished", string.Format("No confirmed breakout close={0:F2} longTrigger={1:F2} shortTrigger={2:F2} breakoutBarSeen={3} pendingDirection={4}", ...), bar.Time);
```
This should fire on the large majority of RTH bars on any day without a breakout in progress. Its total
absence across four-plus hours of RTH on 2026-09-04 (and however much of 2026-09-03 this session covered)
is the core anomaly this task must explain.
## WHY THIS IS INVISIBLE (a compounding, separate gap — same pattern as GAP-063)
`NT8StrategyBase.OnBarUpdate()` (~824-849) wraps the entire real-evaluation call chain — `ConvertCurrentBar()`,
`BuildStrategyContext()`, `_sdkStrategy.OnBar(barData, context)`, `MaybeWriteStateTelemetry(...)`,
`ProcessStrategyIntent(...)`/`LogSignalRejectionFromContext(...)` — in one try/catch whose catch block
only calls `_logger.LogError(...)`, `Print(...)`, and `Log(...)`. **None of these write to `FileLog`.**
If anything in that block throws on a given bar, the session log would show exactly what we're seeing on
that bar: no `SIGNAL:`, no `REJECT:`. This is the same blind spot GAP-063 fixed for `State.DataLoaded` —
it was never extended to `OnBarUpdate()`'s own try/catch.
However, this alone would also be expected to suppress the `STATE:` telemetry on the same bar, since
`MaybeWriteStateTelemetry(...)` is called from inside the same try block, after `_sdkStrategy.OnBar(...)`.
Since `STATE:` telemetry is visibly still firing normally, either:
(a) the exception (if any) is happening after `MaybeWriteStateTelemetry(...)` returns but during/before
`ProcessStrategyIntent`/`LogSignalRejectionFromContext` — narrowing the search significantly, or
(b) there is no exception at all, and `_sdkStrategy.OnBar(barData, context)` is genuinely returning
`null` on every bar without ever calling `RecordSignalRejection(...)` first — i.e. the real
post-ORB evaluation branch inside `SimpleORBStrategy.OnBar()` is exiting through some path that
sets neither an intent nor a reject reason, or is not being reached at all, or
(c) `context.CustomData["signal_reject_reason"]` is being set correctly by
`RecordSignalRejection(context, ...)` but is not surviving to reach
`LogSignalRejectionFromContext(context)` — check whether `context` is genuinely the same object
reference throughout `OnBarUpdate()`'s call chain, or whether anything between the `OnBar()` call
and `LogSignalRejectionFromContext(context)` replaces or clears `context.CustomData`.
**This task is diagnostic-first: do not assume which of (a)/(b)/(c), or something else, it is.**
## READ-FIRST
1. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~824-849 — `OnBarUpdate()`'s real-evaluation try/catch.
Confirm the exact call sequence and what the catch block does (currently: `_logger.LogError`, `Print`,
`Log` — no `FileLog`).
2. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~1503-1520 — `LogSignalRejectionFromContext(context)`:
returns immediately if `context.CustomData` is null or doesn't contain `signal_reject_reason`. Confirm
this is unchanged and understand exactly what upstream state it depends on.
3. `src/NT8.Strategies/Examples/SimpleORBStrategy.cs` ~1040-1052 — `RecordSignalRejection(context, reason,
detail, barTime)`: sets `context.CustomData["signal_reject_reason"]`/`["signal_reject_detail"]`/
`["signal_reject_bar"]`/`["signal_reject_line"]` directly on the passed-in `context`. Confirm every
code path in `OnBar()` that can return `null` calls this first — enumerate them (there appear to be at
least: `RthGuard` ~396, `CmeHoliday` ~407, `OrbRangeNotEstablished` (window building) ~432, invalid ORB
~442, `MaxDailyTrades` ~476/492, `OrbRangeNotEstablished` (no confirmed breakout) ~600, `RegimeVeto`
~640/649, `GradeFilter` ~677) and check for any `return null;` (or equivalent early exit) that does NOT
go through `RecordSignalRejection` first — that would be a direct, provable cause.
4. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~1037-1094 — `MaybeWriteStateTelemetry(barData,
context)`: confirm it does not mutate the shared `context.CustomData` (its own `BuildStateTelemetryIntent`
builds a separate `StrategyIntent` with its own fresh `Metadata` dictionary) — rule out or confirm
telemetry as a source of clobbering the reject-reason keys set moments earlier by the real `OnBar()` call
on the same `context` object.
5. `session_20260903_143151.log` (device log directory) — the full session this task is investigating.
Confirm the exact bar/timestamp (if any) after which `STATE:` telemetry keeps appearing but no further
`RthGuard`/`HistoricalReplayCatchup`/`WarmupIncomplete` counts increment either (all three froze
simultaneously right around RTH open on 2026-09-04) — this simultaneity is itself a clue: if it were
purely "the real evaluation path throws," `WarmupIncomplete`/`HistoricalReplayCatchup` freezing at the
same moment RTH began, rather than continuing to update from other bar-processing branches, may mean
something specific changes state right at the RTH transition.
## THE INVESTIGATION
1. Reproduce or trace, from source alone if reproduction isn't practical, whether `SimpleORBStrategy.OnBar()`
is being called at all on RTH bars after ORB close today, and if so, whether it is reaching a
`RecordSignalRejection(...)` call before returning `null`, or returning `null` through some other path.
Add temporary, clearly-marked diagnostic instrumentation only if needed to pin this down — do not leave
debug-only code in the final commit.
2. If a genuine exception is being thrown and silently swallowed by `OnBarUpdate()`'s catch block, identify
what is throwing and why — and separately, note that the catch block's `FileLog`-blind behavior is itself
a real, general defect (same class as GAP-063) that should be fixed regardless of what today's specific
exception turns out to be: add a `FileLog` line to that catch block with the exception message/type, so
a future occurrence is visible on disk immediately instead of requiring source archaeology like this task.
3. If no exception is being thrown and `OnBar()` is genuinely returning `null` without recording a reason,
find the exact code path responsible and explain why it doesn't call `RecordSignalRejection`.
4. Cross-check against `trades_Simple_ORB_NT8_20260903.jsonl` and `trades_Simple_ORB_NT8_20260904.jsonl`
(the latter does not exist as of this task being staged) and confirm whether this silence is confined to
the rejection/signal logging layer only, or whether it indicates the strategy has not been evaluating
trade candidates at all — these have different severities and different fixes.
5. Determine whether this is connected to, or fully independent of, GAP-054-FOLLOWUP (the 2026-09-01
trailing-stop validation failure, also currently under diagnostic investigation). They may be unrelated;
do not assume a shared root cause without evidence.
## DO NOT
- Do not change order-evaluation, sizing, or risk logic based on a hypothesis alone.
- Do not deploy anything as part of this task.
- Do not restart the live NT8 strategy as part of this investigation unless the operator explicitly asks —
the currently-running session is the only evidence of this behavior in its natural state; a restart may
clear whatever condition is causing it before it's understood.
## VALIDATION (operator, after root cause is confirmed and a fix, if any, is proposed)
Confirm a subsequent live/SIM session produces `REJECT:`/`REJECT SUMMARY:` lines for `OrbRangeNotEstablished`
at a normal cadence on a quiet no-breakout day, and that a deliberately low-grade real breakout produces a
`REJECT: reason=GradeFilter` line, matching historical behavior (e.g. the pattern documented in
`DEC-20260825-04`).
## GOVERNANCE
Track as **GAP-064** in `SPRINT_BOARD.md` as its own entry (this is a distinct defect class from GAP-054's
runner-trail issue, not a sub-item of it). Reference the new decision entry (`DEC-20260904-01`) in the
commit and in `decisions.md`.