# P3-S.9 ROOT-CAUSE MATRIX — SNIPERGOLD_ML CROSS-PRIMITIVE CONSOLIDATION ```text Date : 2026-08-22 Session : P3-S.9 — Cross-Primitive Consolidated Repair & Architecture Review Purpose : Identify SHARED root causes across P3-S.2..P3-S.8 findings so the future repair phase patches ONE architecture, not N files. Evidence : docs/SMC_*_SPEC_v1.md (P3-S.2..S.8), docs/P3_S*_CONFORMANCE.md, docs/SESSION_HANDOVER_2026-08-22_P3_S*_*.md, FEATURE_CONTRACT.md, AF_Engine1/2/3 sources, legacy v4.3/v4.4/v4.5 (all reconciled). Rule : Every mark below cites at least one audited finding. No AUC/PF/ profit-based inference. Human verification = CANCELLED. ``` --- ## 1. SHARED ROOT-CAUSE PATTERNS (from §7 of the brief) ### A. EVENT/STATE CONFUSION ```text Definition : a detector that is semantically an EVENT (onset + validity) is consumed as a persistent STATE (never expires), or vice versa. Evidence : - Liquidity Sweep: f7 EVENT with 40-bar lifecycle (P3-S.0 fix, CONFORMING) vs per-TF stateless state in Engine 2 (AF_DetectSweep, no expiry) and vs g_swpDir persistent state consumed by f9/f18 WITHOUT age bound (BUG-P3S2-001; P3-S.2 E-10 NON-CONFORMING). - CHoCH/MSS: f8 = persistent STATE per contract (99.89% active bars, median run 318 bars; P3-S.3 audit_choch_state) vs f9/f18 consuming it as a fresh EVENT (BUG-P3S3-001, 34.7% / 58.0% stale) vs Engine-2 AF_DetectChoch per-bar state with no expiry (P3-S.8 D-12). - Candidate Setup: E-rule consumes choch as a same-bar state, so a CHoCH 500 bars old still "confirms" (P3-S.8 CS-T14). Affected : Sweep, CHoCH/MSS, Candidate Setup. ``` ### B. ZONE/MITIGATION CONSUMER ERROR ```text Definition : a ZONE producer applies mitigation in display/legacy, but the decision-path consumer reads the zone WITHOUT mitigation. Evidence : - FVG: Engine-2 AF_FindFVG (AF_Engine2_Agents.mqh:329-350) has NO mitigation filter; C/E agents consume the newest-ANY zone (BUG-P3S4-001; P3-S.4 E-9 NON-CONFORMING). Display AF_CollectFVG applies MIT, legacy FindEntryFVG requires unmitigated. - OB: Engine-2 AF_FindOrderBlock (293-322) has NO mitigation and NO age bound; C/E consume newest-ANY (BUG-P3S5-001; P3-S.5 E-9 NON-CONFORMING). Display AF_CollectOBs applies close-through MIT + 0.5 ATR dedupe. Affected : FVG, OB, Candidate Setup (zone leg inherits the error). ``` ### C. DUPLICATE EVENT EMISSION ```text Definition : a per-bar state detector emits the "event" on every bar the state holds, with no onset suppression. Evidence : - f7 pre-fix: a single sweep onset yielded TRUE for hundreds of bars (P3-S.0; max per-onset lifetime ~996 -> 41 after fix). - f8: state run median 318 bars, returns to 0 NEVER after first event (P3-S.3 audit_choch_state.json). - P3.1c candidate strata: median gap between candidate bars = 1 bar (candidate_setup_audit.json event_frequency) — no dedup by construction. - Engine-2 E-rule: fires every bar while zone+conf hold (P3-S.8 CS-T13). Affected : Sweep, CHoCH/MSS, Candidate Setup. ``` ### D. STALE STATE CONSUMPTION ```text Definition : a consumer reads a detector's persistent state without checking the event validity window. Evidence : - f9/f18 sweep leg: uses raw g_swpDir/g_swpBar without age bound (BUG-P3S2-001; EA AlgoForge_Backtest_Baseline.mq5:470-471, 510-516). - f9/f18 CHoCH leg: same pattern (BUG-P3S3-001; f9 34.7% stale, f18 +15 leg 58.0% stale). - Engine-2 C/E zone consumers: no age bound on OB/FVG (BUG-P3S4-001/-002, BUG-P3S5-001). Affected : Sweep, CHoCH/MSS, FVG, OB, Candidate Setup. ``` ### E. MULTIPLE INCOMPATIBLE DEFINITIONS ```text Definition : the same concept has 2+ definitions/TF-models in the repo with no canonical rule. Evidence : - MTF models: FEATURE_CONTRACT D1/H4/H1+M15 vs Engine 2 H4/M30/M15/M3 vs legacy v4.5 D1/H4/H1+M15 (P3-S.7 D-5/D-6; X-1..X-5). - OB: current "opposite bar before strong move (1.5x avg)" vs legacy "opposite candle before structure break" (P3-S.5 A-2, BUG-P3S5-002). - CHoCH: f8/f9 (5/5+gate, M15) vs Engine 2 (2/2, no gate) vs display struct lines (P3-S.3 A-2; P3-S.7 X-2). - Sweep: f7 internal pivot (M15) vs Engine-2 swing-pivot per-TF vs legacy D1/H4/H1 per-TF (P3-S.2 A-2; P3-S.7 X-1). - FVG: min-gap none vs 0.02 ATR vs 0.25 ATR; timestamp C2 vs C3 (P3-S.4 A-1/A-5). - Displacement: 1.6x avg body vs OB strong-move 1.5x (BUG-P3S6-001). - Candidate Setup: Definition A (E-rule) vs Definition B (legacy gate chain) (P3-S.8 D-8). Affected : ALL primitives (Sweep, CHoCH, FVG, OB, Displacement, MTF, Candidate Setup). ``` ### F. FLAT SCORE USED AS SETUP SUBSTITUTE ```text Definition : the aggregator's weighted score/signal is treated as (or displayed as) a Candidate Setup. Evidence : - Aggregator outputs direction+score only; any single TF can produce BUY/SELL with zero setup contribution (P3-S.7 MTF-T19/T20/T22; P3-S.8 CS-T05/T11/T21; unit test T6 "N buy kuat saja -> BUY"). - Dashboard "TRADE SETUP" panel renders the aggregated signal (AF_Engine3_Render.mqh:272-278; P3-S.8 D-9). Affected : Candidate Setup, MTF (aggregation). ``` ### G. TIMEFRAME ROLE DRIFT ```text Definition : roles are assigned by AGENT LABEL, not by structural cross-TF dependency; the same detector runs per-TF. Evidence : - 4 agents each read exactly ONE slot; same detector suite per-TF; NO cross-TF structural references (P3-S.7 S-R, D-7; MTF ROLE DIVERGENCE). - "H4 Narrative -> M30 Context -> M15 Entry -> M3 Price Action" is an ANALYSIS order; the DECISION is a flat vote (P3-S.7 S-H, D-1). Affected : MTF, Candidate Setup. ``` ### H. TRAINING/RUNTIME SEMANTIC DRIFT ```text Definition : training features and the agent runtime implement different semantics for the same concept. Evidence : - MTF model mismatch: contract/training D1/H4/H1+M15 vs agent path H4/M30/M15/M3; agent path has NO Python counterpart (P3-S.7 D-5, S-PR "N/A by absence"; FEATURE_CONTRACT MTF MISMATCH). - CHoCH pivots: train_model.build_structure STRICT vs EA/parity feed equal-allowed: 0.26% choch_dir / 2.40% choch_bar divergence (BUG-P3S3-002; P3-S.3 E-13). - FVG/OB/Displacement: absent from contract (PARITY = N/A by absence). Affected : CHoCH/MSS, MTF. ``` ### I. MISSING SETUP IDENTITY ```text Definition : no setup_id / formation timestamp / originating event / zone linkage exists; downstream receives direction+score only. Evidence : - No setup struct/array anywhere in Engine 2; E-rule is a fuzzy weight contribution; no dedup (P3-S.8 D-10, CS-T13/T16/T20; SETUP-IDENTITY GAP). Affected : Candidate Setup. ``` ### J. MISSING EXPLICIT LIFECYCLE ```text Definition : no onset/completion/expiry/invalidation states for setups or for Engine-2 events/zones. Evidence : - Engine 2 has no SeqWindow constant (AF_Defines.mqh); E-rule has no age bound; CHoCH/sweep states never expire in Engine 2 (P3-S.8 D-12, CS-T14). - FVG/OB invalidation NOT modeled anywhere (P3-S.4 E-10, P3-S.5 E-10 CONFORMING by absence). - Setup onset/completion/lifecycle: SPECIFICATION AMBIGUOUS (P3-S.8 A-5/A-6/A-7). Affected : Sweep, CHoCH/MSS, Candidate Setup (zones have implicit mitigation-based lifecycle only). ``` --- ## 2. ROOT-CAUSE × PRIMITIVE MATRIX | Root Cause | Sweep | CHoCH/MSS | FVG | OB | Displacement | MTF | Candidate Setup | |------------------------|-------|-----------|-----|----|--------------|-----|-----------------| | A. Event/state confusion | ✓ (P3S2 E-9/E-10) | ✓ (P3S3 E-11) | — | — | — | — | ✓ (P3S8 D-12/CS-T14) | | B. Zone/mitigation consumer error | — | — | ✓ (P3S4 E-9) | ✓ (P3S5 E-9) | — | — | ✓ (inherits zone leg) | | C. Duplicate event emission | ✓ (P3S0) | ✓ (P3S3 audit) | — | — | — | — | ✓ (P3S8 CS-T13) | | D. Stale state consumption | ✓ (P3S2 BUG-001) | ✓ (P3S3 BUG-001) | ✓ (P3S4 BUG-001) | ✓ (P3S5 BUG-001) | — | — | ✓ (P3S8 D-12) | | E. Multiple incompatible definitions | ✓ (P3S2 A-2) | ✓ (P3S3 A-2) | ✓ (P3S4 A-1/A-5) | ✓ (P3S5 A-2) | ✓ (P3S6 BUG-001) | ✓ (P3S7 D-5/D-6) | ✓ (P3S8 D-8) | | F. Flat score as setup substitute | — | — | — | — | — | ✓ (P3S7 D-1) | ✓ (P3S8 D-9) | | G. Timeframe role drift | — | — | — | — | — | ✓ (P3S7 D-7/S-R) | ✓ (P3S8 CS-17) | | H. Training/runtime semantic drift | — | ✓ (P3S3 BUG-002) | — | — | — | ✓ (P3S7 D-5) | — | | I. Missing setup identity | — | — | — | — | — | — | ✓ (P3S8 D-10) | | J. Missing explicit lifecycle | ✓ (P3S2 E-9) | ✓ (P3S3 E-11) | — | — | — | — | ✓ (P3S8 A-5..A-7) | Legend: "—" = no audited finding; "✓" = at least one audited finding; the citation column gives the primary evidence. --- ## 3. CONSISTENCY ACROSS THE CHAIN (detector -> consumer) ```text Detectors (mostly CONFORMING): sweep trigger, CHoCH trigger, FVG geometry, OB formation, displacement candle attribute — all validated P3-S.2..S.6. Consumers (mostly NON-/PARTIALLY CONFORMING): f9/f18 (stale sweep+choch), Engine-2 C/E zones (no mitigation/age), aggregator (flat score), display (mitigation exists but decision path ignores it), training (strict pivots). -> The dominant failure class is CONSUMER-SIDE, not detector-side. -> A single consumer-contract layer (event/zone/state/attribute contracts) addresses root causes A, B, C, D, I, J simultaneously. ``` --- ## 4. EVIDENCE REFERENCES ```text P3-S.2 : docs/SMC_LIQUIDITY_SWEEP_SPEC_v1.md, P3_S2_LIQUIDITY_SWEEP_CONFORMANCE.md P3-S.3 : docs/SMC_CHOCH_MSS_SPEC_v1.md, P3_S3_CHOCH_MSS_CONFORMANCE.md, ml/p3/smc_semantic/output/audit_choch_state.json P3-S.4 : docs/SMC_FVG_SPEC_v1.md, P3_S4_FVG_CONFORMANCE.md P3-S.5 : docs/SMC_ORDER_BLOCK_SPEC_v1.md, P3_S5_ORDER_BLOCK_CONFORMANCE.md P3-S.6 : docs/SMC_DISPLACEMENT_SPEC_v1.md, P3_S6_DISPLACEMENT_CONFORMANCE.md P3-S.7 : docs/SMC_MTF_ALIGNMENT_SPEC_v1.md, P3_S7_MTF_ALIGNMENT_CONFORMANCE.md P3-S.8 : docs/SMC_CANDIDATE_SETUP_SPEC_v1.md, P3_S8_CANDIDATE_SETUP_CONFORMANCE.md, ml/p3/smc_semantic/output/spec_tests_candidate_setup_report.json Historical : P3_S_F7_EVENT_LIFECYCLE_FORENSIC.md, P3_2_LABEL_FORENSIC.md, P3_FEATURE_LABEL_FORENSIC.md, ml/p3/output/candidate_setup_audit.json ``` *Human verification remains CANCELLED. No production file was modified by this session (this document is analysis only).*