SniperGold_ML/docs/SESSION_HANDOVER_2026-08-22_P3_S4_FVG.md

11 KiB

SESSION HANDOVER — SNIPERGOLD_ML P3-S.4: FVG SPEC + CONFORMANCE

Date       : 2026-08-22 (session close)
Status     : P3-S.4 COMPLETE — spec + conformance audit done; synthetic tests 20/20;
             NOT yet committed (handover prepared before commit+push)
Forge      : https://forge.mql5.io/chiki2bum2/SniperGold_ML
Checkpoint : P3-S.3 b6100f9c4ff631539bab4ba8c5416cae4d89564a (research content intact;
             HEAD ahead by 3 documentation-only commits: eb8a818, 0ac6ed1, 85e3b48)

1. SESSION OBJECTIVE

Formal Specification + Code-Conformance Audit for FVG (Fair Value Gap).

Question answered:
  Does the SniperGold code claiming to detect FVG really implement the
  FVG definition established by the PROJECT SEMANTIC SPECIFICATION?

Questions NOT answered:
  - Does FVG generate profit?
  - Does FVG improve AUC / PF?
  - Is the universal SMC FVG definition correct for every trader?

Principle: SPEC FIRST, CODE AUDIT SECOND. Human verification = CANCELLED. No production code changes (Phase D). No ML / AUC / PF / backtest optimization.


2. SOURCE MATERIAL (16 sources, reconciled)

 1 DESIGN.md (Algo Forge)                docs/DESIGN.md (C/E agents, display)
 2 DESAIN_MTF_v45.md                     Shared Projects\SniperGold_ML (v4.5 MTF FVG intent)
 3 v4.3/v4.4 indicator                   Indicators\Downloads\SniperGold_SMC_ProPlus_v4_3/4_4.mq5
 4 v4.5 indicator                        Indicators\Downloads\SniperGold_SMC_ProPlus_v4_5.mq5
 5 Engine 2 FVG detector                 Include\AlgoForge\AF_Engine2_Agents.mqh:329-350 (AF_FindFVG)
 6 Engine 2 C agent (context)            AF_Engine2_Agents.mqh:492-575
 7 Engine 2 E agent (entry)              AF_Engine2_Agents.mqh:583-663
 8 Engine 3 display collector            Include\AlgoForge\AF_Engine2_Display.mqh:255-292 (AF_CollectFVG)
 9 Engine 3 render                       Include\AlgoForge\AF_Engine3_Render.mqh:379-392
10 Engine 3 indicator                    Indicators\AlgoForge\AF_Engine3_Display.mq5
11 Unit test                             Experts\AlgoForge_Engine3_UnitTest.mq5:133-137
12 AF_Defines.mqh                        Include\AlgoForge\AF_Defines.mqh:31,53,58,61
13 FEATURE_CONTRACT                      docs/FEATURE_CONTRACT.md — NO FVG feature (0 refs)
14 EA runtime                            Experts\AlgoForge_Backtest_Baseline.mq5 — NO FVG (0 refs)
15 Python training                       ml/**/*.py — NO FVG (0 refs)
16 P3 docs                               P3-S.2 conformance; golden-dataset concept list

Three semantic layers separated:
  INTENDED : FVG = imbalance ZONE; C agent = "which zone is price in"; E agent =
             entry zone (ZONE + CONFIRMATION = setup); legacy chain
             Sweep -> CHoCH -> OB/FVG within InpSeqWindow; display zones with
             MIT filter + minimum size.
  LEGACY   : v4.3/v4.4/v4.5: 3-candle wick gap; minGap 0.25xATR (auto) or 0;
             mitigation = full fill by wick; entry tap +-1 ATR on ANY unmitigated
             zone; HTF projection (InpFVGTF); v4.5 per-TF MTF FVG (display).
  CURRENT  : Engine 2 AF_FindFVG = newest FVG ONLY, NO minGap, NO mitigation,
             lookback 40 (C) / 20 (E); display AF_CollectFVG = newest N
             unmitigated zones, minGap 0.02xATR, mitigation by close;
             ML features / EA / training: FVG ABSENT.

3. SPECIFICATION (docs/SMC_FVG_SPEC_v1.md)

DEFINITION  : 3-candle: bullish Low(C3) > High(C1), zone [High(C1), Low(C3)];
              bearish High(C3) < Low(C1), zone [High(C3), Low(C1)];
              C2 (gap candle) extremes unused in the zone bounds.
BOUNDARIES  : WICK-BASED (High/Low of C1 & C3); no body rule; close not used.
MIN GAP     : none in the definition (>= 1 tick); zero gap = NOT FVG;
              consumer filters 0.02 ATR (display) / 0.25 ATR (legacy auto) /
              none (Engine 2) = AMBIGUOUS (A-1).
DIRECTION   : +1 bullish (up gap), -1 bearish (down gap), 0 none;
              NO trend precondition (unlike CHoCH).
DISPLACEMENT: NOT REQUIRED BY CURRENT SPEC (geometric gap sufficient).
FORMATION   : observable at C3 close (b <= t); newest closed bar eligible;
              canonical timestamp = C3 open (A-5: legacy uses C2).
CLOSED-BAR  : all inputs <= t; no future visibility (property-tested T15).
LIFECYCLE   : ZONE (persistent); one zone per formation; no event stream;
              no age expiry; one zone stays ONE zone (T14).
MITIGATION  : full fill by wick (Low<=bot bull / High>=top bear); partial fill
              NOT mitigation; display variant = close (A-2).
INVALIDATION: NOT MODELED (only mitigation terminates a zone).
OVERLAP     : separate zones per formation; no merge/replace/dedup.
TIMEFRAME   : Engine 2 per-TF independent (H4/M30/M15/M3); canonical project
              FVG = SPECIFICATION AMBIGUOUS (A-3).
PARITY      : FVG NOT an ML feature (contract f0-f18 has none) -> parity N/A.

4. CONFORMANCE (docs/P3_S4_FVG_CONFORMANCE.md)

Detection semantics (E-1, E-2, E-4, E-5, E-7)   : CONFORMING
  geometry, wick boundaries, direction, no displacement, closed-bar/no-future.
Minimum gap (E-3)                                : SPECIFICATION AMBIGUOUS (A-1)
Formation timing (E-6)                           : PARTIALLY CONFORMING (BUG-P3S4-002)
Lifecycle zone (E-8)                             : CONFORMING (no event duplication)
Mitigation (E-9)                                 : NON-CONFORMING (Engine 2,
                                                    BUG-P3S4-001) + AMBIGUOUS (A-2)
Invalidation (E-10)                              : CONFORMING (not modeled)
Overlap / multiple (E-11)                        : CONFORMING
Timeframe (E-12)                                 : SPECIFICATION AMBIGUOUS (A-3)
Consumer semantics (E-14, E-15)                  : PARTIALLY CONFORMING
                                                    (BUG-P3S4-001/-002, A-6)
Runtime/training parity (E-13)                   : CONFORMING (N/A by absence)

VERDICT : PARTIALLY CONFORMING
  (conformance to the project spec; NOT profitability/edge)

5. SYNTHETIC TESTS

Runner  : ml/p3/smc_semantic/spec_tests_fvg.py
Cases   : ml/p3/smc_semantic/spec_test_cases_fvg.json (20 cases)
Report  : ml/p3/smc_semantic/output/spec_tests_fvg_report.json

Result  : 20/20 PASS
  FVG-T01..T20 (all required). spec_oracle (truth, from SPEC S-1..S-13) ==
  expected in all cases. code_port (Engine-2 AF_FindFVG port, observation)
  MATCHES spec in T01-T09/T14-T19; DIVERGES in:
    T10/T11: spec newest-unmitigated = none (mitigated) vs code returns the
             zone -> synthetic evidence for BUG-P3S4-001;
    T12/T13: spec newest zone (C3 = newest closed bar) vs code returns an
             older zone (1-bar lag + lookback) -> evidence for BUG-P3S4-002.
  Expected derived from SPEC, NOT from production code.
  Parity scan (T20): FEATURE_CONTRACT.md = 0 FVG refs; ml/**/*.py = 0 FVG refs
  (excluding the spec test files) -> runtime/training parity N/A by absence.
NO AUC/PF/backtest/human annotation/ML on the test path.

6. CONFIRMED BUGS (document-only; NOT fixed in P3-S.4)

BUG-P3S4-001 [MEDIUM] CONFIRMED, NOT FIXED
  Engine-2 AF_FindFVG (AF_Engine2_Agents.mqh:329-350) has NO mitigation filter:
  the Context (weight 0.25) and Entry (zone tap) agents can consume a FULLY-FILLED
  FVG as a current zone; it also returns ONLY the newest zone (older unmitigated
  zones invisible), diverging from the legacy entry rule (all-unmitigated within
  tap). NOT the f7/f9/f18 duplication class — FVG is a zone, but the mitigation
  lifecycle is not respected.
  Fix: apply the wick full-fill mitigation filter (S-9) to AF_FindFVG and clarify
  the zone-selection rule.

BUG-P3S4-002 [LOW] DOCUMENTED
  AF_FindFVG loop starts at i=1 (skips the newest closed bar as C3) -> 1-bar lag
  vs legacy/display; C-agent lookback 40 vs E-agent lookback 20 (inconsistent).
  Fix: start at i=0 (closed-bar lock) or document the maturity delay; unify the
  lookback constant.

BUG-P3S4-003 [INFO] DOCUMENTED
  FVG timestamp convention diverges: v4.4/v4.5 = middle candle (C2), Engine-3
  display = C3, Engine 2 = none. Display-only; no ML impact.

BUG-P3S4-004 [INFO] DOCUMENTED
  Minimum-gap filters diverge (none / 0.02 ATR / 0.25 ATR) — no canonical project
  threshold (SPECIFICATION AMBIGUOUS A-1). NOT optimized in this session.

7. SEMANTIC AMBIGUITIES

1. Minimum gap filters (A-1)      : none / 0.02 ATR / 0.25 ATR; no canonical value.
2. Mitigation trigger (A-2)       : wick full-fill (legacy) vs close full-fill
                                    (display) vs none (Engine 2).
3. Canonical timeframe (A-3)      : Engine-2 M15 slot explicit; HTF FVG as M15
                                    context / M3 FVG entry not defined (same class
                                    as CHoCH G-4, sweep G-3).
4. Same-bar double condition (A-4): geometrically impossible; bull-first order;
                                    unreachable.
5. Zone timestamp (A-5)           : C2 (legacy) vs C3 (display) vs none (Engine 2).
6. Consumer zone scope (A-6)      : Engine 2 newest-only vs legacy all-unmitigated.

8. NO PRODUCTION CHANGE

No production code was modified.
  AF_FindFVG / AF_CollectFVG / v4.3 / v4.4 / v4.5 / Engine 2 / Engine 3 /
  f7 / f8 / f9 / f10 / f11 / f18 / OB / CHoCH / Displacement / ML / EA :
  NOT touched.

Only P3-S.4 research artifacts added (spec, conformance, tests, report, handover).
P3-S.3 / P3-S.2 artifacts (immutable) UNCHANGED
(git status: only new files, 0 modified).

9. HUMAN VERIFICATION STATUS

HUMAN VERIFICATION = CANCELLED
  Human annotation is NOT part of the FVG validation path.
  The human_package/ remains a historical artifact only.

10. NEXT GATE

After the FVG verdict (PARTIALLY CONFORMING):
  OB -> Displacement -> MTF Alignment -> Candidate Setup.
DO NOT return to ML; DO NOT build a meta-label; DO NOT create new event labels;
DO NOT fix production bugs before the audit chain completes (BUG-P3S4-00x stay
documented until the semantic audit chain is finished).

11. CHECKPOINT & PROVENANCE (P3-S.4)

Forge HEAD (session start)   : 85e3b48 (P3-S.3 research checkpoint b6100f9 intact;
                                ahead only by 3 documentation-only commits)
P3-S.3 spec (immutable)      : docs/SMC_CHOCH_MSS_SPEC_v1.md
P3-S.2 spec (immutable)      : docs/SMC_LIQUIDITY_SWEEP_SPEC_v1.md
FEATURE_CONTRACT             : C44CC6F2... (P2-era) / 7b908b12... (committed)
P2.6 model (SHA-256)         : 06df8452... (Include\SniperGold_ML_p26_corrected.mqh)
                               VERIFIED by file hash this session
symbol/tf                    : XAUUSD / M15 (2017-01-01 .. 2026-08-20)
Human verification           : CANCELLED

12. P3-S.4 ARTIFACTS

docs/SMC_FVG_SPEC_v1.md
docs/P3_S4_FVG_CONFORMANCE.md
ml/p3/smc_semantic/spec_tests_fvg.py
ml/p3/smc_semantic/spec_test_cases_fvg.json
ml/p3/smc_semantic/output/spec_tests_fvg_report.json
docs/SESSION_HANDOVER_2026-08-22_P3_S4_FVG.md  (this document)

13. COMMIT & PUSH STATUS

NOT YET COMMITTED at handover write time.
Planned commit message:
  research: P3-S.4 FVG formal spec + conformance audit (PARTIALLY CONFORMING)
Follow with: git push origin main; verify rev-parse HEAD == ls-remote origin HEAD;
working tree CLEAN.