- ConfluenceScorer.cs: apply designed factor baseline weights - ConfluenceScorerTests.cs: cover 5.85 total weight, worked example, and overrides - TASK_GAP047_PART2_WEIGHT_RUNTIME_PROMPT.md: add accepted runtime prompt - docs/00-governance: record DEC implementation and fresh-freeze requirement - SPRINT_BOARD.md: mark GAP-047 Part 2 implemented Build: clean | Tests: 514 passing; Core 425 passing | Deploy: backup 20260823_135331
7.7 KiB
TASK: GAP-047 Part 2 — Apply the designed confluence factor weights
Staged: 2026-08-23 (v7.0 review, Finding 1 — runtime change)
APPROVED: 2026-08-23 — see DEC-20260823-01. Implementation approach resolved,
not an open decision. Depends on GAP-047 Part 1 (TASK_GAP047_WEIGHT_RESCORE_PROMPT.md,
complete, commit cbf45df) for its evidence base.
Sprint: Stage 1 (P1-A step 2)
Owner: Kilocode
─────────────────────────────────────────────────────────────────
THE DEFECT (confirmed by Part 1's study, DEC-20260823-01)
ConfluenceScorer's constructor (src/NT8.Core/Intelligence/ConfluenceScorer.cs ~105-117)
pre-populates _factorWeights with 1.0 for ALL TEN FactorType values:
_factorWeights.Add(FactorType.Setup, 1.0); // correct — 1.0 by design
_factorWeights.Add(FactorType.Trend, 1.0); // correct — 1.0 by design
_factorWeights.Add(FactorType.Volatility, 1.0); // correct — 1.0 by design
_factorWeights.Add(FactorType.Timing, 1.0); // correct — 1.0 by design
_factorWeights.Add(FactorType.ExecutionQuality, 1.0); // correct — 1.0 by design
_factorWeights.Add(FactorType.NarrowRange, 1.0); // WRONG — should be 0.20
_factorWeights.Add(FactorType.OrbRangeVsAtr, 1.0); // WRONG — should be 0.15
_factorWeights.Add(FactorType.GapDirectionAlignment, 1.0); // WRONG — should be 0.15
_factorWeights.Add(FactorType.BreakoutVolumeStrength, 1.0); // WRONG — should be 0.20
_factorWeights.Add(FactorType.PriorDayCloseStrength, 1.0); // WRONG — should be 0.15
ResolveWeight(type, fallbackWeight) (~410-419) checks _factorWeights first and returns
the stored value if present — it always is, so each calculator's own designed weight
(passed as fallbackWeight via factor.Weight) is unreachable dead code. Confirmed against
FactorCalculators.cs: NarrowRangeFactorCalculator declares 0.20 (line 569),
OrbRangeVsAtrFactorCalculator declares 0.15 (line 670), GapDirectionAlignmentCalculator
declares 0.15 (line 797), BreakoutVolumeStrengthCalculator declares 0.20 (line 897),
PriorDayCloseStrengthCalculator declares 0.15 (line 1021).
NORMALIZATION — ALREADY CORRECT, NOTHING TO FIX HERE
Score()'s composite (ConfluenceScorer.cs ~144-183) computes:
weightedScoreSum += (weightedFactor.Score * weightedFactor.Weight);
totalWeight += weightedFactor.Weight;
...
var weightedScore = totalWeight > 0.0 ? weightedScoreSum / totalWeight : 0.0;
This already normalizes DYNAMICALLY by whatever weights are actually applied — it is not
hardcoded to divide by 10 or by 5.85. Once the five wrong literals below are corrected,
totalWeight will naturally sum to 5.85 and the composite will be correctly scaled with
no further change needed. Confirm this during Read-First; do not re-derive or "fix" the
normalization — it isn't broken.
THE CHANGE — approved, not an open decision
In the ConfluenceScorer constructor, change exactly these five literals:
NarrowRange: 1.0 → 0.20
OrbRangeVsAtr: 1.0 → 0.15
GapDirectionAlignment: 1.0 → 0.15
BreakoutVolumeStrength: 1.0 → 0.20
PriorDayCloseStrength: 1.0 → 0.15
Leave Setup, Trend, Volatility, Timing, ExecutionQuality at 1.0 — unchanged,
correct by design.
DO NOT: touch ResolveWeight(), UpdateFactorWeights(), the Score() composite
calculation, any FactorCalculators.cs file, MapScoreToGrade() or its thresholds,
MinTradeGrade, or any NinjaScript/adapter-layer file. This task is scoped entirely to
src/NT8.Core/Intelligence/ConfluenceScorer.cs — five numeric literals.
Why not remove the pre-population and let fallbackWeight flow through instead?
Considered and rejected — same runtime result, but a larger diff, and it would make the
dictionary conditionally authoritative depending on what each calculator happens to pass,
undermining the UpdateFactorWeights() API's own assumption that the dictionary is the
single source of truth. Changing the five literals directly is the smaller, more precise
fix for what is actually a wrong-placeholder-constant bug, not an architecture problem.
READ-FIRST
src/NT8.Core/Intelligence/ConfluenceScorer.cs— constructor (~105-117),Score()(~144-200),ResolveWeight()(~410-419),UpdateFactorWeights()(~302-334).src/NT8.Core/Intelligence/FactorCalculators.cs— confirm the five weight literals above still match lines 569/670/797/897/1021 exactly before editing; if any calculator's weight has drifted since the Part 1 study, use the CURRENT value and flag the drift.- Any existing
ConfluenceScorerunit tests that hardcode an expected composite score or grade assuming equal 1.0 weights — these encode the bug's behavior, not the design, and will need updating as part of this task, not left red.
TESTS (required)
- Unit test(s) asserting
ResolveWeight/Score()now applies the five designed weights for a synthetic factor set — confirmtotalWeightsums to 5.85, not 10.0. - Reproduce Part 1's worked example as an automated test. Using the same factor scores
as the 2026-08-18 10:10:11.833 sample (
Setup=1.00, Trend=0.30, Volatility=0.70, Timing=1.00, ExecutionQuality=0.80, NarrowRange=0.45, OrbRangeVsAtr=0.50, GapDirectionAlignment=0.10, BreakoutVolumeStrength=0.85, PriorDayCloseStrength=0.70), assertScore()now returns0.727(not the old0.640) and gradeB. This is the same cross-check DEC-20260818-18/DEC-20260823-01's evidence chain already relies on — closing the loop with a real test means this can never silently regress. - Fix any existing test broken by the weight change per Read-First item 3 — update the expected values to the designed-weight result, do not skip or delete the test.
- Confirm
UpdateFactorWeights()still overrides correctly on top of the new baseline (existing behavior, should be unaffected — verify, don't assume).
VALIDATION
Unlike GAP-054, this change is fully contained in the platform-neutral NT8.Core layer —
no NinjaScript managed-order call is involved. No SIM trade is required to validate
correctness; the automated test in TESTS item 2 is the actual proof. Standard build/test
gate applies:
.\verify-build.batpasses.dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimalpasses.- Deploy per the usual process; a live/SIM session afterward is worth watching to observe the real trade-frequency and grade-distribution shift in practice, but that's a nice-to-have observation, not a blocking correctness gate the way GAP-054's SIM trade was.
FOLLOW-ON, NOT THIS TASK
- A fresh Gate 3 configuration freeze/baseline is needed before collecting gate evidence
after this lands — trade-qualification behavior changes. Flag when this task is done;
don't run
preflight.ps1 --freezeas part of this task itself. - The workspace currently runs
MinTradeGrade=4(B) while the Gate 3 plan targetsMinTradeGrade=A(5) — now that Grade A is reachable, whether to raise the live threshold is an operator call, not part of this task.
GOVERNANCE
Track as [GAP-047] Part 2 in SPRINT_BOARD.md. Update DEC-20260823-01 with an
Implementation Note on completion (commit hash, test results) — same pattern as
DEC-20260818-18's GAP-054 implementation note.
Reference: NT8_SDK_Master_Document_v7.0 Finding 1, Sections 4.6, 9.4 (P1-A), 12.2 (O-01).
DEC-20260823-01, tools/rescore/GAP-047_weight_rescore_output.md.