[GOV]: cleanup prompted task state

- SPRINT_BOARD.md: stage GAP-025/GAP-030 and correct GAP-062 deploy status

- TASK_GAP025_RUNNER_ORDER_LIFECYCLE_LOGGING_PROMPT.md: add runner lifecycle logging prompt

- TASK_GAP030_ORB_HYDRATION_VERIFY_PROMPT.md: add ORB hydration verify prompt

- TASK_GAP051/052/059/060 prompts: record commit-only deploy instruction

- TASK_GAP054_RUNNER_TRAIL_PROMPT.md: clarify SIM/replay validation path

- docs/00-governance/2026-08-19-run-book.md: reconcile implemented/verified task states

- docs/00-governance/active_work.md: update blocker status and validation requirements

- docs/00-governance/decisions.md: record prompted follow-ups and resolved GAP-062 deploy status

Build: clean | Tests: 569 passing | Deploy: GAP-062 deployed backup 20260826_005308
This commit is contained in:
2026-08-26 00:59:35 -04:00
parent 885e298fb7
commit 34c3767fbf
11 changed files with 408 additions and 32 deletions

View File

@@ -0,0 +1,164 @@
# TASK: GAP-030 — historical ORB range hydration on a late strategy enable
# Staged: 2026-08-26 (long-queued Sprint 2.7 item, now prompted; DEC-20260825-08)
# Sprint: Stage 1 — verify existing behaviour first; implement only if a real gap is found
# 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 QUESTION (not yet a confirmed defect — verify before implementing)
GAP-030 has sat in the backlog since Sprint 2.7 as "Historical ORB State
Hydration" with the concern: if the strategy is enabled after 09:30 ET
(the ORB window's start) but before or after the window closes at 10:00,
does it correctly reconstruct that day's opening-range high/low from
historical replay bars, and does it correctly avoid ever generating a
real order from one of those historical bars?
**Tracing this on 2026-08-26 by reading the actual source (not assuming
the bug exists) found reason to believe this already works correctly by
construction:**
1. `SimpleORBStrategy.OnBar()`'s ORB-building logic
(`UpdateOpeningRange()`, `src/NT8.Strategies/Examples/
SimpleORBStrategy.cs` ~1031-1037) is entirely state-blind:
`StrategyContext` (`src/NT8.Core/Common/Models/StrategyContext.cs`) has
no field at all for NT8's `State` (Historical/Realtime). The Core
strategy has no way to know whether a bar is a historical catch-up bar
or a genuine live one — it simply accumulates
`_openingRangeHigh`/`_openingRangeLow` from whatever `BarData` the
adapter hands it, unconditionally, every time it's called during the
09:30-10:00 window.
2. The adapter (`NT8StrategyBase.OnBarUpdate()`, ~622-700) does not
currently gate `State.Historical` bars out before they reach
`_sdkStrategy.OnBar()`. The only state-based early-return near the top
of that method is the "REPLAY BURST GUARD" (~638-647), and its own
comment explicitly says it only applies `if (State == State.Realtime)`
using a wall-clock-age heuristic — genuine `State.Historical` bars
(e.g. same-day catch-up bars NT8 may deliver on a late enable) skip
that guard entirely and, subject only to `CurrentBar >=
BarsRequiredToTrade`, fall through to `_sdkStrategy.OnBar()`.
3. Order submission is independently protected regardless of what the
Core strategy decides: `ProcessStrategyIntent()` (~2059-2066) has an
explicit `if (State == State.Historical && Account != null) { ...
return; }` guard, logged as `HistoricalReplayCatchup`, that blocks any
order from being submitted off a historical-replay bar.
**Net, if this trace is correct: the range hydration and the "no order
from historical bars" safety GAP-030 originally asked for may already both
exist, just never tested end-to-end.** But this task's trace rests on one
assumption that cannot be verified from this repo's source alone — that
NT8 actually delivers same-day 09:30-onward bars to `OnBarUpdate()` marked
`State.Historical` when the strategy is enabled partway through or after
the ORB window, rather than starting the strategy cold with no same-day
history at all. **Verify this yourself before treating it as settled** —
check NT8 platform documentation/behavior, any prior operator experience
with late enables recorded elsewhere in this repo, or a test harness if
one exists that can simulate it. If you cannot verify it with confidence,
say so plainly in your writeback rather than guessing either way.
## READ-FIRST
1. `src/NT8.Strategies/Examples/SimpleORBStrategy.cs` ~347-460 — the
09:30-10:00 window-building logic (`UpdateOpeningRange` call site,
`OrbRangeNotEstablished` rejection, `_openingRangeReady` gating).
2. `src/NT8.Strategies/Examples/SimpleORBStrategy.cs` ~1031-1037 —
`UpdateOpeningRange()` itself.
3. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~622-700 —
`OnBarUpdate()`'s early guards, especially the REPLAY BURST GUARD
(~638-647) and its comment explaining why it's `State == State.Realtime`
scoped, not `State.Historical`.
4. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~2059-2075 —
`ProcessStrategyIntent()`'s `State == State.Historical` early-return
guard (`HistoricalReplayCatchup`).
5. `src/NT8.Core/Common/Models/StrategyContext.cs` — confirm there is
genuinely no `State`/`IsHistorical`-equivalent field, i.e. Core really
cannot distinguish bar provenance on its own.
6. `docs/00-governance/decisions.md` — search for `GAP-039` (a related,
already-resolved defect about `_dailyTradeCount` only incrementing in
`State.Realtime`, meaning historical replay couldn't latch the daily
count) for how this codebase has previously reasoned about historical
vs. realtime bar handling in this exact strategy.
## THE CHANGE
**Step 1 — verify.** Confirm or correct the trace in THE QUESTION above
by reading the source yourself. State plainly in your writeback whether
you found it accurate.
**Step 2a — if verification confirms hydration and the order-block
already work correctly by construction:** this task's job is to close the
test-coverage gap, not write new production logic. Add:
- A test proving that feeding `SimpleORBStrategy.OnBar()` a realistic
sequence of `BarData` covering the 09:30-10:00 window (including a
scenario representing a late enable — i.e. the strategy only starts
receiving bars partway into the window, if that is what NT8 actually
delivers per your Step 1 finding, or a full-window replay sequence if
NT8 delivers the complete window as historical bars) results in the
correct `_openingRangeHigh`/`_openingRangeLow`/`OpeningRangeReady`
state.
- A test proving `ProcessStrategyIntent()`'s `State == State.Historical`
early-return guard is still present and unweakened (source-text
assertion is fine here, consistent with this codebase's established
pattern for this NinjaScript-derived class — check
`TASK_GAP057_STOP_TRAIL_TEST_SEAM_PROMPT.md`'s precedent for the
nearest equivalent seam pattern).
Do not add new hydration logic that isn't needed — the point of this
path is proving existing safety, not building something redundant.
**Step 2b — if verification finds a real gap** (for example: NT8 does
*not* deliver same-day historical catch-up bars for a live/SIM late
enable the way THE QUESTION assumed, so the range would genuinely build
incomplete or wrong from only the live-onward portion of the window):
implement the minimal fix for the actual gap found. Do not guess at a
fix for a hypothetical gap — explain precisely what you found different
from the trace above and why your fix addresses it, in your writeback.
## DO NOT
- Do not touch the RTH guard, kill switch, connection-loss guard, or
`MaxDailyTrades` restart persistence (GAP-055, separate and already
implemented) — unrelated mechanisms.
- Do not touch the pullback-confirmation two-bar breakout state machine
(`_breakoutBarSeen`/`_pendingBreakoutDirection`) for its own sake. If
your Step 1 investigation finds that a late-enable scenario could leave
this state machine in a stale or incorrect state (e.g. a breakout that
"happened" only during historical catch-up bars, before the strategy
was genuinely watching), flag it explicitly in your writeback as a
separate, not-yet-decided follow-up — do not fix it as part of this
task.
- Do not change risk, sizing, or grade-filter code.
- Do not weaken or remove `ProcessStrategyIntent()`'s existing
`State == State.Historical` guard under any circumstance.
## TESTS (required)
1/2. As specified in Step 2a above, or the equivalent tests covering
whatever fix Step 2b implements if a real gap is found.
3. Confirm the full existing suite still passes.
## VALIDATION (operator)
If Step 2a applies (test-only outcome): no live-behavior change expected,
nothing new to validate on SIM beyond the existing suite passing. If Step
2b applies (a real fix was implemented): the operator should enable the
strategy on SIM after 09:30 ET on a future session and confirm
`STATE_CONTEXT`'s `OrbHigh`/`OrbLow` match the true 09:30-current range,
and confirm zero orders were submitted before the first genuine realtime
bar (check for any `HistoricalReplayCatchup` rejections in the log during
that window — their presence with no order fired is exactly the expected,
safe behavior).
## GOVERNANCE
Track as [GAP-030] in SPRINT_BOARD.md — move out of the "QUEUED —
branch-only during Gate Run #2" framing (that gate-sequencing language is
stale) into an entry reflecting whichever outcome (2a test-only, or 2b
real fix) actually happened. Update `docs/00-governance/decisions.md`
with a new dated entry referencing this task and `DEC-20260825-08`,
explicitly recording which of Step 2a/2b applied and why.
Reference: this task, `DEC-20260825-08`, `DEC-20260825-04`'s addenda (this
codebase's established pattern of tracing historical/realtime bar
handling through source before assuming a defect exists).