From f45adcaa0332fe98acf4fff4e1a9f086419e868b Mon Sep 17 00:00:00 2001 From: mo Date: Sun, 23 Aug 2026 15:10:58 -0400 Subject: [PATCH] [GAP-058]: reject line test coverage complete - SimpleORBRejectionLoggingTests.cs: replace literal-only comparison with real RecordSignalRejection output comparison - decisions.md: mark DEC-20260823-02 implemented - SPRINT_BOARD.md: record GAP-058 housekeeping completion Build: clean | Tests: focused 3 passing; Core 446 passing; verify-build 535 passing --- SPRINT_BOARD.md | 1 + TASK_GAP058_REJECT_LINE_TEST_PROMPT.md | 81 +++++++++++++++++++ docs/00-governance/decisions.md | 10 +++ .../SimpleORBRejectionLoggingTests.cs | 22 ++++- 4 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 TASK_GAP058_REJECT_LINE_TEST_PROMPT.md diff --git a/SPRINT_BOARD.md b/SPRINT_BOARD.md index 085ab91..40daf43 100644 --- a/SPRINT_BOARD.md +++ b/SPRINT_BOARD.md @@ -58,6 +58,7 @@ - 2026-08-17 logged `reason=KillSwitch count=647` from a real kill switch; 2026-08-18 logged `count=5` from `MaxTradeRisk`. Same label. `GradeFilter` is overloaded four ways as well. - `REJECT SUMMARY` aggregates on `reason`, so the counts operators and the dashboard read are ambiguous. Defeats what GAP-035 was built for. - Prompt: `TASK_GAP048_REJECT_TAXONOMY_PROMPT.md`. Verification: `verify-build.bat` 516/516, Core Release no-build 427/427, parser syntax checks passed, deploy backup `20260823_142014`. Manual NT8 compile and live/SIM dashboard spot-check still required. +- GAP-058 housekeeping implemented 2026-08-23: replaced the tautological reject-line format test with production-path coverage; no production code changed. **[GAP-049] Telemetry `STATE:` score is direction-incorrect and presented as the trade grade** | Stage 1 | ✅ READY - `GapDirectionAlignmentCalculator` reads `daily.TradeDirection`, which the telemetry path deliberately does not set (DEC-20260818-06). Confirmed: a −523 gap scored "opposes trade" on a `Direction=Sell` setup. diff --git a/TASK_GAP058_REJECT_LINE_TEST_PROMPT.md b/TASK_GAP058_REJECT_LINE_TEST_PROMPT.md new file mode 100644 index 0000000..3535aa8 --- /dev/null +++ b/TASK_GAP058_REJECT_LINE_TEST_PROMPT.md @@ -0,0 +1,81 @@ +# TASK: GAP-058 — Tautological reject-line-format test +# Staged: 2026-08-23 (found during independent verification of GAP-048) +# Sprint: Stage 0 — housekeeping, zero trading-behaviour risk +# Owner: Kilocode +# ───────────────────────────────────────────────────────────────── + +## THE DEFECT + +`tests/NT8.Core.Tests/Strategies/SimpleORBRejectionLoggingTests.cs`, the test +`RejectLineFormat_DiffersOnlyByReasonToken` (added in `e36534b`, GAP-048), +does not call any production code: + + string oldLine = "REJECT: reason=GradeFilter detail=Regime veto before score; ..."; + string newLine = "REJECT: reason=RegimeVeto detail=Regime veto before score; ..."; + Assert.AreEqual(oldLine.Replace("reason=GradeFilter", "reason={reason}"), + newLine.Replace("reason=RegimeVeto", "reason={reason}")); + +Both strings are hand-written literals, constructed to differ only in the +`reason=` token. Replacing that token with the same placeholder in both and +asserting equality is true by construction — the assertion cannot fail +regardless of what `NT8StrategyBase.cs` / `SimpleORBStrategy.cs` actually +emit. This is the GAP-022 defect class: a test that reads as regression +coverage but exercises nothing. + +The other two tests added in the same commit +(`OnBar_BelowThresholdGrade_RecordsGradeFilterRejectLineWithScore`, +`OnBar_RegimeVeto_RecordsRegimeVetoRejectLine`) are legitimate — they call +`OnBar()` / `RecordSignalRejection()` (the latter via reflection) and assert +on real output. This task only concerns the third test. + +## READ-FIRST + +1. Read `SimpleORBRejectionLoggingTests.cs` in full, including the + `AssertRejectLineFormat` / `InvokeRecordSignalRejection` helpers already + added by GAP-048 — reuse them rather than adding new ones. +2. Confirm which production method actually formats the `REJECT:` line + (`RecordSignalRejection` and/or `LogRejectRateLimited`) and how to invoke + it twice with two different `reason` values from a test. + +## THE CHANGE + +Replace `RejectLineFormat_DiffersOnlyByReasonToken` with a test that drives +the real formatting path twice — once with each of two distinct reasons +(e.g. `GradeFilter` and `RegimeVeto`, matching the existing helper tests) — +and asserts the two real output lines are identical except for the +`reason=` token. Use `InvokeRecordSignalRejection` (already present) or the +equivalent for `LogRejectRateLimited` if that is the better seam. + +If, after reading the code, no seam exists to produce two comparable real +lines cheaply, say so explicitly and propose the smallest seam rather than +leaving the tautological version in place — do not fabricate coverage +(GAP-022 precedent). + +## DO NOT + +- Do not change any production reject-taxonomy code — this is GAP-048's + already-shipped behaviour and is out of scope here. +- Do not change the two legitimate tests in the same file. +- Do not change `REJECT:` / `REJECT SUMMARY:` line formats. + +## TESTS (required) + +The replacement test itself is the deliverable. It must fail if the format +string that precedes `reason=` in `RecordSignalRejection` / +`LogRejectRateLimited` is ever changed independently for two different +reasons (i.e. it must be capable of catching the defect class GAP-048's +byte-identical-format requirement exists to prevent). + +## VALIDATION (operator) + +None — this is test-only housekeeping. `verify-build.bat` passing is +sufficient. + +## GOVERNANCE + +Track as [GAP-058] in SPRINT_BOARD.md (housekeeping section or a one-line +note next to GAP-048 is fine — this does not need its own blocker row). +Update `docs/00-governance/decisions.md` DEC-20260823-02: change Status +from "logged, no operator decision needed — tracking only" to +"implemented" and add a short Implementation Note. +Reference: this task, `docs/00-governance/decisions.md` DEC-20260823-02. diff --git a/docs/00-governance/decisions.md b/docs/00-governance/decisions.md index 93b198d..047cfe6 100644 --- a/docs/00-governance/decisions.md +++ b/docs/00-governance/decisions.md @@ -13,6 +13,16 @@ Use this file to record durable project decisions that affect implementation pat ## Decision Log +### DEC-20260823-02 +- **ID:** DEC-20260823-02 +- **Date:** 2026-08-23 +- **Status:** implemented +- **Context:** Discovered while independently verifying the GAP-048 implementation (`e36534b`). Two of the three new tests in `tests/NT8.Core.Tests/Strategies/SimpleORBRejectionLoggingTests.cs` (`OnBar_BelowThresholdGrade_RecordsGradeFilterRejectLineWithScore`, `OnBar_RegimeVeto_RecordsRegimeVetoRejectLine`) are legitimate — they call real production code (`OnBar` / `RecordSignalRejection` via reflection) and assert on its actual output. The third, `RejectLineFormat_DiffersOnlyByReasonToken`, is not: it hand-constructs two literal strings that were written to differ only by the `reason=` token, replaces that token with a placeholder in both, and asserts the results are equal. That assertion is true by construction — it never calls any production formatting code, so it cannot fail regardless of whether `NT8StrategyBase.cs`/`SimpleORBStrategy.cs` actually preserve the line format. Same defect class as the GAP-022 precedent this project already treats as a known failure mode (fabricated coverage that reads as a real regression test but tests nothing). +- **Decision:** Track as **GAP-058**. Not blocking — the two real tests plus the byte-diff review already performed (`git show e36534b`, confirmed only `reason=` tokens changed) give adequate confidence GAP-048 itself is correct. Recommended fix, low priority: replace the third test with one that drives the actual reject-line-emitting path (e.g. invoke the same code with two different reasons and diff the real output), or delete it if the two real tests are judged sufficient coverage on their own. +- **Related Files:** `tests/NT8.Core.Tests/Strategies/SimpleORBRejectionLoggingTests.cs`, `TASK_GAP048_REJECT_TAXONOMY_PROMPT.md` +- **Implementation Note (2026-08-23):** GAP-058 replaced the tautological `RejectLineFormat_DiffersOnlyByReasonToken` literal comparison with a test that invokes `SimpleORBStrategy.RecordSignalRejection` twice through the existing reflection helper, once with `GradeFilter` and once with `RegimeVeto`, then normalizes only the `reason=` token and compares the two real emitted lines. No production code changed. +- **Action Required:** None. + ### DEC-20260823-01 - **ID:** DEC-20260823-01 - **Date:** 2026-08-23 diff --git a/tests/NT8.Core.Tests/Strategies/SimpleORBRejectionLoggingTests.cs b/tests/NT8.Core.Tests/Strategies/SimpleORBRejectionLoggingTests.cs index 42f88a7..c869c2b 100644 --- a/tests/NT8.Core.Tests/Strategies/SimpleORBRejectionLoggingTests.cs +++ b/tests/NT8.Core.Tests/Strategies/SimpleORBRejectionLoggingTests.cs @@ -54,10 +54,26 @@ namespace NT8.Core.Tests.Strategies [TestMethod] public void RejectLineFormat_DiffersOnlyByReasonToken() { - string oldLine = "REJECT: reason=GradeFilter detail=Regime veto before score; Side=Buy AVWAPSlope=-1.0000 bar=2026-08-23 09:35:00"; - string newLine = "REJECT: reason=RegimeVeto detail=Regime veto before score; Side=Buy AVWAPSlope=-1.0000 bar=2026-08-23 09:35:00"; + SimpleORBStrategy strategy = CreateStrategy((int)TradeGrade.F); + DateTime sessionStart = DateTime.Today.AddHours(9.5); + DateTime barTime = sessionStart.AddMinutes(5); + string detail = "Regime veto before score; Side=Buy AVWAPSlope=-1.0000"; - Assert.AreEqual(oldLine.Replace("reason=GradeFilter", "reason={reason}"), newLine.Replace("reason=RegimeVeto", "reason={reason}")); + StrategyContext gradeContext = CreateContext(sessionStart); + StrategyContext regimeContext = CreateContext(sessionStart); + + InvokeRecordSignalRejection(strategy, gradeContext, "GradeFilter", detail, barTime); + InvokeRecordSignalRejection(strategy, regimeContext, "RegimeVeto", detail, barTime); + + string gradeLine = gradeContext.CustomData["signal_reject_line"].ToString(); + string regimeLine = regimeContext.CustomData["signal_reject_line"].ToString(); + + AssertRejectLineFormat(gradeLine, "GradeFilter"); + AssertRejectLineFormat(regimeLine, "RegimeVeto"); + + Assert.AreEqual( + gradeLine.Replace("reason=GradeFilter", "reason={reason}"), + regimeLine.Replace("reason=RegimeVeto", "reason={reason}")); } private static SimpleORBStrategy CreateStrategy(int minTradeGrade)