SniperGold_ML/docs/P3_S8_CANDIDATE_SETUP_CONFORMANCE.md

444 lines
26 KiB
Markdown

# P3-S.8 CANDIDATE SETUP — FORMAL SPECIFICATION & CODE-CONFORMANCE REPORT
```text
Date : 2026-08-22
Session : P3-S.8 — Candidate Setup semantic validation
Principle : SPECIFICATION FIRST, CODE AUDIT SECOND
Scope : SEMANTIC/ARCHITECTURAL conformance ONLY. No AUC/PF/backtest, no
ML, no optimization, no production code changes, no human
verification (CANCELLED).
Question : What exact combination of market conditions should constitute
ONE Candidate Setup in SniperGold, and does the current
implementation actually create Candidate Setups according to
that definition?
Artifacts : docs/SMC_CANDIDATE_SETUP_SPEC_v1.md (specification)
ml/p3/smc_semantic/spec_tests_candidate_setup.py (+ .json)
ml/p3/smc_semantic/output/spec_tests_candidate_setup_report.json
docs/SESSION_HANDOVER_2026-08-22_P3_S8_CANDIDATE_SETUP.md
```
---
## 0. CHECKPOINT & PROVENANCE (session-start verification)
```text
Forge HEAD : 533c8c6647a552d01a1a290cb2d0505f94887666 (P3-S.6) VERIFIED
(remote https://forge.mql5.io/chiki2bum2/SniperGold_ML.git)
Branch / remote : main == origin/main (533c8c6) VERIFIED
Working tree : no modified tracked files; only the 6 P3-S.7
artifacts untracked (as left by P3-S.7 handover) VERIFIED
P3-S.7 artifacts : spec/conformance/tests/report/handover INTACT
(timestamps 2026-08-22 20:21-20:25) VERIFIED
Live vs repo code : AF_Engine1_MTFData / AF_Engine2_Agents /
AF_Engine2_Aggregator / AF_Engine2_Display /
AF_Engine3_Render / AF_Defines : byte-IDENTICAL
between the terminal Include and the Forge repo VERIFIED
HUMAN VERIFICATION : CANCELLED VERIFIED
No production change after P3-S.7 : VERIFIED (clean tree, single commit)
```
---
## A. SOURCE MATERIAL (Phase A — inventory & reconciliation)
| # | Source | Function / role | TF(s) | Input conditions | Output | State | Consumer |
|---|--------|-----------------|-------|------------------|--------|-------|----------|
| 1 | DESIGN.md §9 | E-agent "ZONE + CONFIRMATION = setup" (intent) | M15 | zone + confirmation | setup rule (concept) | none | Engine 2 |
| 2 | DESIGN.md §14 | Dashboard "trade setup" | display | AFAggOut | signal + levels | none | Engine 3 |
| 3 | AF_Defines.mqh:47-50 | agent TF macros | H4/M30/M15/M3 | — | macros | — | all consumers |
| 4 | AF_Engine2_Agents.mqh:583-663 | AFAgentEntry::Compute (E) — the ONLY "setup" code | M15 | sweep/choch/disp/OB/FVG/ATR | AFSignalOut (fuzzy) | none | Aggregator |
| 5 | AF_Engine2_Agents.mqh:430-745 | N/C/P agents | H4/M30/M3 | per-slot | AFSignalOut | none | Aggregator |
| 6 | AF_Engine2_Aggregator.mqh:77-170 | AFAggregator::Compute (flat vote) | — | 4 votes | AFAggOut (dir/buy/sell/score/levels) | none | Engine 3 / consumers |
| 7 | AF_Engine2_Display.mqh:308-395 | AF_BuildDisplayData | M15+ | e1 + votes | AFDisplayData | none | Engine 3 |
| 8 | AF_Engine3_Render.mqh:272-278 | "TRADE SETUP" panel | M15 | AFAggOut | rendered signal | none | chart |
| 9 | AF_Engine3_Display.mq5 | indicator driver | chart | e1 slots | objects | g_lastDispBar | chart |
| 10 | AlgoForge_Backtest_Baseline.mq5 | ML runtime (19 features, NO Engine 2) | M15+D1/H4/H1 | closed bars | probs | persistent structure | MLP |
| 11 | FEATURE_CONTRACT.md | f7-f18 per-bar features | M15+D1/H4/H1 | closed bars | 19 features | — | ML path |
| 12 | v4.3/v4.4/v4.5 legacy | SETUP SEQUENCE gate chain (Definition B) | M15+D1/H4/H1 | HTF-align, sweep, CHoCH, OB/FVG tap | signal + notes | g_swpDir/g_chochDir etc. | legacy signal |
| 13 | P3-S.0 f7 lifecycle doc | SeqWindow=40 = f7 expiry | M15 | sweep onset | f7 0/dir | — | ML path |
| 14 | P3.1c candidate_setup_audit.py | diagnostic setup strata (f9&f7 etc.) | M15 | features | AUC strata | — | research only |
| 15 | P3_2_LABEL_FORENSIC.md | setup unit vs event unit analysis | M15 | events | findings | — | research |
**Layer separation:**
```text
INTENDED SETUP SEMANTICS : DESIGN.md §9 "ZONE + CONFIRMATION = setup"
(E-agent); P3-S.7 S-E "candidate setup = OB/FVG
zone membership (ZONE)".
LEGACY SETUP SEMANTICS : v4.x hard-gated chain (HTF-align -> sweep ->
CHoCH -> OB/FVG tap -> not-premium -> score).
CURRENT IMPLEMENTATION : E-agent fuzzy setup rule (min(zone,conf) * 0.30
weight) + flat-vote aggregator; NO setup entity.
TRAINING SEMANTICS : per-bar features f7-f9/f18; diagnostic strata
only; NO setup unit.
DISPLAY/SCORING SEMANTICS: "TRADE SETUP" panel = aggregated signal.
```
---
## B. FORMAL SPECIFICATION (Phase B)
Full document: **docs/SMC_CANDIDATE_SETUP_SPEC_v1.md** (PROJECT SEMANTIC
SPECIFICATION — not universal SMC truth).
Spec decision summary (CS-1..CS-32):
```text
CS-1 Setup (A) = E-agent M15 rule: ZONE(OB/FVG membership) AND
CONFIRMATION(max(sweep,choch)) at the same closed bar -> fuzzy vote
contribution (wSetup=0.30 normalized). NO entity, NO identity.
CS-2 Setup (B, legacy) = hard-gated chain (HTF-align -> sweep -> CHoCH ->
OB/FVG tap -> not-premium -> score>=threshold), SeqWindow=40.
CS-3 Canonical for this audit = Definition A (current Engine 2).
CS-4 Causal order (A): SAME-BAR only; no cross-bar order defined/enforced.
CS-5 Causal order (B): ordered chain within SeqWindow=40.
CS-7 Onset (A): NOT DEFINED (SPECIFICATION AMBIGUOUS).
CS-8 Onset (B): entry-tap bar (defined).
CS-9 Completion (A): NOT DEFINED (SPECIFICATION AMBIGUOUS).
CS-10 Completion (B): gates pass + score>=threshold -> signal.
CS-11 Direction (A): E-rule side = setup side; final = flat vote; arithmetic
conflict resolution (no policy; S-X).
CS-12 Direction (B): chain side; HTF-align gate; conflict -> no signal.
CS-13..16 MTF roles: H4/M30/M3 alone -> NO setup (A and B); M15 alone ->
setup YES in A (E-rule), NO in B (needs HTF gate).
CS-17 Hierarchy: A = no cross-TF requirement; B = HTF gate required.
CS-18 Alternative paths (A): {sweep|choch} x {OB|FVG}, same bar (P1..P4).
CS-19 Alternative paths (B): one chain; zone leg OR-ed.
CS-20 Hard requirements (A): zone>0 AND conf>0 (same bar); nothing else.
CS-21 Hard requirements (B): HTF-align, sweep, CHoCH, OB/FVG tap, not-premium.
CS-22 Score != setup: aggregator has no setup object (SETUP-CONSTRUCTION
DRIFT, D-9).
CS-23 Dedup: NONE in A; no setup_id (SETUP-IDENTITY GAP, D-10).
CS-26 Lifecycle (A): NONE (SPECIFICATION AMBIGUOUS).
CS-27 Lifecycle (B): freshness window only.
CS-28 SeqWindow=40 scope: f7 expiry (ML path) + legacy gates; NOT Engine 2.
CS-30 Causality: closed-bar lock; as-of <= t; future mutation cannot change
past decisions.
CS-31 Setup vs trade: execution semantics excluded from setup validity.
CS-32 State vs setup: only the E-rule conjunction constitutes a setup;
states/events/zones alone do not.
```
---
## C. CURRENT CODE BEHAVIOR (Phase C — code audit)
```mql5
// AF_Engine2_Agents.mqh:583-663 — the ONLY "setup" in the current runtime
// E-agent rule (Definition A):
// confBull = max(sweepBull, chochBull); confBear = max(sweepBear, chochBear)
// fz.Rule(true, MathMin(mZoneBull, confBull), wSetup); // wSetup=0.30
// fz.Rule(false, MathMin(mZoneBear, confBear), wSetup);
// weights normalized with wSweep=0.25, wChoch=0.30, wDisp=0.20, wZone=0.15,
// wSetup=0.30 (wDisp *= 1.3 when displacement != 0).
// AF_Engine2_Aggregator.mqh:77-170 — flat 2-pass weighted vote:
// baseW = [0.30, 0.30, 0.25, 0.15]; pass1 majority; pass2 1.5x boost;
// final dir = +1 iff bias>=0.20 && buy>=0.50 (mirror for -1); else WAIT.
// Entry/SL/TP on the M15 slot only.
// legacy v4.x (Definition B) — ComputeSignal gate chain:
// buyGate = buyCtx && (!InpRequireSweep||sweepBull)
// && (!InpRequireCHoCH||chochBull)
// && (!InpEntryOnFVGorOB||buyEntry) && !inPremium
// with sweepBull/chochBull freshness <= InpSeqWindow=40 and
// buyCtx = (g_bias>0) && alignBull (3-HTF stack D1/H4/H1).
```
Observations (verified in source):
```text
1. NO setup entity exists in Engine 2: no struct, no array of setups, no
setup_id, no formation timestamp, no event linkage. The word "setup" in
the current code appears only in: the E-agent comment/rule
(AF_Engine2_Agents.mqh:584, 647-651) and the renderer's "TRADE SETUP"
panel label (AF_Engine3_Render.mqh:272-278) which renders the final
aggregated signal + levels.
2. The E-rule is a fuzzy weight contribution: min(zone,conf) * (0.30/total).
It does not gate anything; it does not emit anything; it cannot be
observed outside the E-agent's AFSignalOut.
3. E-vote saturation (D-11): when all fired E-rule legs agree, the fuzzy
evaluator normalizes by fired-rule weights, so the E bias saturates at
+/-1.0 even when the setup leg is absent (zone missing, CS-T04) — the
presence/absence of the setup is NOT visible in the E vote.
4. The aggregator can produce BUY/SELL from any single TF (T6 unit test
asserts N-only -> BUY; MTF-T19/T20/T22). High score has no setup
dependency (CS-T05/CS-T21).
5. SeqWindow=40 exists ONLY in the ML path (f7 expiry; EA
AlgoForge_Backtest_Baseline.mq5) and in the legacy v4.x gates. No
SeqWindow constant exists in AF_Defines.mqh for Engine 2.
6. The legacy v4.x gate chain (Definition B) is the only code in the
repository that implements a hard-gated causal setup sequence with a
state machine ("waiting for sweep" -> "waiting for CHoCH" -> "confirmed -
wait pullback"). It is NOT part of the current Engine-2 runtime.
7. Training has no setup unit: FEATURE_CONTRACT has 19 per-bar features;
P3.1c "candidate setup" strata are diagnostic masks (f9==1&f7>0 etc.)
with median gap 1 bar (no dedup by construction).
```
---
## D. CONFORMANCE MATRIX (Phase C)
| Requirement | Specification | Code Location | Actual Behavior | Verdict |
|---|---|---|---|---|
| Setup definition | E-agent M15 rule ZONE + CONFIRMATION (CS-1); legacy B chain recorded (CS-2) | AF_Engine2_Agents.mqh:647-651; legacy v4.x ComputeSignal | Rule exists as fuzzy weight contribution; NO setup entity anywhere | **SPECIFICATION AMBIGUOUS** (two definitions: A fuzzy-rule vs B hard-gate; A canonical per P3-S.7) |
| Required components | zone>0 AND conf>0 same-bar (A); HTF-align/sweep/CHoCH/OB-FVG/not-premium (B) (CS-20/21) | E-rule min(zone,conf); legacy gates | A: no hard gates, OR legs; B: hard gates in legacy only | **PARTIALLY CONFORMING** (to A; legacy B not in current runtime) |
| Causal sequence | same-bar only (A); ordered chain (B) (CS-4/5) | E-rule same-bar; legacy ordered | No cross-bar order in Engine 2; order only in legacy | **PARTIALLY CONFORMING** (A conforms; B absent from runtime) |
| H4 role | context + vote 0.30; no gate (CS-13, S-N) | AFAgentNarrative (H4) | H4 vote; can produce BUY alone (no setup) | **CONFORMING** (to A) |
| M30 role | context + vote 0.30; no filter (CS-14, S-C) | AFAgentContext (M30) | M30 vote; no setup coupling | **CONFORMING** (to A) |
| M15 role | the setup layer (E-rule); can create setup alone in A (CS-15) | AFAgentEntry (M15) | E-rule same-bar; E alone -> BUY (CS-T12) | **CONFORMING** (to A) |
| M3 role | confirmation + vote 0.15; NOT required (CS-16, S-P) | AFAgentPriceAction (M3) | M3 vote; no setup requirement (CS-T06) | **CONFORMING** (to A) |
| Hard requirements | zone>0 AND conf>0 (A); nothing else | E-rule | Only the same-bar conjunction; no other hard requirement | **CONFORMING** (to A) |
| Score/confluence | score != setup (CS-22) | AFAggregator::Compute | high score without setup possible (CS-T05/T21) -> SETUP-CONSTRUCTION DRIFT | **NON-CONFORMING** (D-9: score is treated as the signal; "setup" label on dashboard = signal) |
| Setup onset | NOT DEFINED (CS-7) | no onset code | no onset timestamp/object | **SPECIFICATION AMBIGUOUS** |
| Setup completion | NOT DEFINED (CS-9) | no completion code | no FORMING/CANDIDATE/CONFIRMED states | **SPECIFICATION AMBIGUOUS** |
| Deduplication | NONE in A (CS-23) | no dedup code | rule fires every bar while conditions hold (CS-T13) | **NON-CONFORMING** (D-10 SETUP-IDENTITY GAP; repeated emission, no identity) |
| Lifecycle | NONE in A (CS-26) | no lifecycle code | no expiry/invalidation/reactivation/consume (CS-T14/T15) | **SPECIFICATION AMBIGUOUS** (absent by design; ambiguous vs B) |
| Expiration | SeqWindow=40 = f7 expiry + legacy gates (CS-28) | EA f7 fix; v4.x gates; NOT Engine 2 | Engine 2 rule has no expiry (CS-T14); f7 expires at 41 (CS-T18/T19) | **PARTIALLY CONFORMING** (f7 conforms; Engine 2 setup has no window) |
| Closed-bar causality | as-of <= t (CS-30) | AFEngine1MTF closed-bar lock | all inputs closed bars; future mutation cannot change past (CS-T17) | **CONFORMING** |
| Consumer behavior | aggregator consumes votes; display shows signal (CS-22) | AFAggregator; AFR_DrawAll | consumers receive direction+score+confidence+levels; NO setup identity | **PARTIALLY CONFORMING** (D-10: SETUP-IDENTITY GAP) |
| Runtime/training | setup exists in neither runtime (as entity) nor training (CS-23) | EA/ML path; FEATURE_CONTRACT | parity N/A BY ABSENCE for setup; f7/f9 strata are per-bar masks | **CONFORMING** (N/A by absence; no conflicting setup layer) |
---
## E. CONFIRMED FINDINGS (Phase D — DOCUMENT ONLY, no code changes)
```text
D-8 SETUP-SEMANTIC DIVERGENCE [HIGH]
Source : DESIGN.md §9 / P3-S.7 S-E (Definition A) vs legacy v4.3/v4.4/v4.5
ComputeSignal (Definition B)
The repository contains two materially different Candidate Setup
definitions: (A) the E-agent fuzzy rule "ZONE + CONFIRMATION" (soft,
same-bar, OR legs, no gates) and (B) the legacy hard-gated chain
(HTF-align -> sweep -> CHoCH -> OB/FVG tap -> not-premium ->
score>=threshold, SeqWindow=40). P3-S.7 established (A) as the current
project model; (B) is reference. Not resolved in this session.
D-9 SETUP-CONSTRUCTION DRIFT [HIGH]
Source : AFAggregator::Compute; AF_Engine3_Render.mqh:272-278
Function: aggregator + "TRADE SETUP" dashboard panel
The runtime can emit BUY/SELL with NO setup contribution at all (any
single TF, verified by unit test T6 and CS-T05/T11/T21). The dashboard
labels the aggregated signal "TRADE SETUP" even when no E-rule setup
fired. High score is NOT equivalent to a valid Candidate Setup.
Impact: consumers (display/backtest/ML path) cannot distinguish "signal
with setup" from "signal without setup".
Proposed repair (NOT applied): separate a discrete setup layer
(identity + lifecycle) from the vote signal, or relabel the dashboard.
D-10 SETUP-IDENTITY GAP [HIGH]
Source : AF_Engine2_Agents.mqh (E), AF_Engine2_Aggregator.mqh, Engine 3
No setup_id / formation timestamp / originating liquidity event /
originating zone / M15 entry event / M3 confirmation event exists.
The same setup conditions can fire on consecutive bars (CS-T13) with no
dedup; downstream consumers receive direction+score+confidence only.
Impact: repeated emissions; no dedup; no lifecycle; no per-setup
outcome measurement possible.
Proposed repair (NOT applied): define a setup identity layer if the
project semantics require it (deferred to P3-S.9).
D-11 E-VOTE SATURATION MASKS SETUP ABSENCE [MEDIUM]
Source : AFFuzzyEval::Finalize + AFAgentEntry::Compute
Because the fuzzy evaluator normalizes by FIRED-rule weights, the E vote
saturates at bias +/-1.0 whenever all fired rules agree — including
when the setup leg is absent (zone missing, CS-T04). The setup
presence/absence is invisible in the E vote and therefore in the final
signal.
Impact: the E-rule's contribution cannot be observed downstream; the
"setup" is semantically opaque.
Proposed repair (NOT applied): expose the setup predicate as a separate
output field.
D-12 SEQUENCE FRESHNESS ABSENT IN ENGINE 2 [MEDIUM]
Source : AF_Defines.mqh (no SeqWindow for Engine 2); E-rule
The legacy chain enforces sweep->CHoCH->entry freshness (SeqWindow=40);
Engine 2 has no age bound, no cross-bar ordering, no expiry. A CHoCH
state 500 bars old still confirms the E-rule (CS-T14 class).
Impact: Definition-A setups have no freshness semantics; the f7 40-bar
expiry applies only to the ML path.
Proposed repair (NOT applied): decide whether Engine 2 needs a setup
freshness window.
D-13 CONFLICT POLICY ABSENT AT SETUP LEVEL [MEDIUM]
Source : aggregator (carried from P3-S.7 D-2 / S-X)
Contradictory H4/M30 or M15/M3 directions resolve arithmetically
(CS-T09/T10); there is no BLOCK/WAIT/OVERRIDE policy and no "setup
blocked by conflict" concept. In legacy B, conflict fails the gate
(buyCtx requires alignment).
Impact: two different conflict semantics coexist (A: arithmetic,
B: gate-fail).
Proposed repair (NOT applied): adjudicate in P3-S.9.
D-14 LEGACY GATE CHAIN NOT PORTED TO ENGINE 2 [INFORMATIONAL]
Source : v4.3:975-982, v4.4:1066-1073, v4.5:1010-1011 vs Engine 2
The hard-gated setup sequence (RequireSweep/RequireCHoCH/
EntryOnFVGorOB/RequireHTFAlign/SeqWindow) exists only in the legacy
indicators. Engine 2 replaced it with the flat vote + E-rule. The
design decision that led to this replacement is not documented in
DESIGN.md beyond "4 independent agents + aggregator".
Impact: the current runtime cannot express the legacy institutional
gate even as an option.
Proposed repair (NOT applied): document or port in P3-S.9 if intended.
```
---
## F. SEMANTIC AMBIGUITIES
```text
A-5 Setup onset (CS-7) : Definition A defines no onset.
A-6 Setup completion (CS-9) : Definition A defines no completion.
A-7 Setup lifecycle (CS-26) : Definition A defines no lifecycle.
A-8 Cross-bar causal order (CS-4): Definition A defines none.
A-9 Canonical definition : A (Engine 2, per P3-S.7) vs B (legacy);
not adjudicated.
A-10 Setup identity (CS-23) : whether a setup_id is needed not decided.
```
---
## G. VERDICT (Phase E)
```text
OVERALL: SPECIFICATION AMBIGUOUS (with NON-CONFORMING components)
Setup definition : SPECIFICATION AMBIGUOUS (A fuzzy-rule vs B
hard-gate; A canonical per P3-S.7; D-8)
Required components : PARTIALLY CONFORMING (A: zone+conf conjunction;
B legacy gates not in runtime)
Causal sequence : PARTIALLY CONFORMING (same-bar only in A;
ordered chain only in legacy)
MTF hierarchy : PARTIALLY CONFORMING (roles labeled correctly;
decision = flat vote; D-1 carried)
Hard requirements : CONFORMING to A (zone>0 AND conf>0 same bar);
no other hard requirements exist
Scoring : NON-CONFORMING (score treated as signal;
"TRADE SETUP" label on dashboard = signal;
D-9 SETUP-CONSTRUCTION DRIFT)
Setup identity : NON-CONFORMING (none exists; D-10 SETUP-IDENTITY
GAP)
Lifecycle : SPECIFICATION AMBIGUOUS (none in A; freshness
only in B)
Deduplication : NON-CONFORMING (none; per-bar repeated
emission; CS-T13)
Expiration : PARTIALLY CONFORMING (f7 40-bar expiry
conforms; Engine 2 setup has no expiry)
Consumer behavior : PARTIALLY CONFORMING (consumers receive
direction+score+confidence, no setup identity)
Runtime/training parity : CONFORMING (N/A BY ABSENCE — no setup layer in
either; f7/f9 strata are per-bar masks)
Cross-primitive consistency: NON-CONFORMING (X-6..X-10; two setup
definitions, three zone roles, two conflict
semantics)
```
Interpretation:
```text
The ONLY question this session must answer is: "When should SniperGold be
allowed to say 'this is one Candidate Setup', and does the current
implementation actually do that according to the project's formal
specification?"
Answer: The project has TWO formal candidates — the E-agent fuzzy rule
(Definition A: ZONE + CONFIRMATION, same bar, OR legs) and the legacy
hard-gated chain (Definition B). Under the canonical Definition A (per
P3-S.7), "this is one Candidate Setup" is TRUE exactly when the E-rule
conjunction fires at a bar — but the implementation does NOT materialize it
as ONE setup: it has no identity, no onset, no completion, no lifecycle, no
dedup, no freshness window, and its contribution is invisible downstream
(E-vote saturation). The implementation therefore does NOT actually "create
Candidate Setups" as distinct entities — it creates per-bar vote states that
can exceed thresholds, and the dashboard calls that "TRADE SETUP".
STATE/EVENT/ZONE/CONFIRMATION/SETUP/ENTRY/TRADE are kept distinct in this
specification (CS-1..CS-32, R-1..R-5): the current implementation collapses
SETUP into a vote contribution and collapses the SIGNAL label into the
"setup" name, which is the central non-conformance.
```
---
## H. CROSS-PRIMITIVE CONSISTENCY MATRIX (brief §33)
| Concept | Role in Candidate Setup (A) | Required? (A) | Produces Event? | Produces Zone? | Confirmation? |
|---|---|---|---|---|---|
| Liquidity Sweep | confirmation leg (OR) | no (with CHoCH alt.) | YES (per-bar; f7 onset+40 in ML) | NO | YES (one leg) |
| CHoCH/MSS | confirmation leg (OR) | no (with sweep alt.) | YES (per-bar; f8 persistent) | NO | YES (one leg) |
| FVG | zone leg (OR) | no (with OB alt.) | YES (formation) | YES | NO |
| OB | zone leg (OR) | no (with FVG alt.) | YES (formation) | YES | NO |
| Displacement | confirmation boost | no | YES (per-bar candle attr) | NO | PARTIAL (boost only) |
| H4 | context + vote 0.30 | no | (structure events per-TF) | NO | NO (vote) |
| M30 | context + vote 0.30 | no | (zones per-TF) | YES (context) | NO (vote) |
| M15 | the setup layer (E-rule) | YES (zone+conf) | YES | YES (OB/FVG) | YES (the rule) |
| M3 | confirmation + vote 0.15 | no | (candle patterns) | NO | NO (vote only) |
Flagged contradictions (recorded, NOT resolved):
```text
X-6 Liquidity Sweep: ML contract = M15 EVENT with 40-bar expiry vs Engine 2
= per-TF stateless STATE detector (no expiry). Two event semantics.
X-7 CHoCH: legacy B REQUIRES sweep-before-CHoCH; Definition A treats them
as same-bar OR alternatives.
X-8 OB/FVG: legacy B REQUIRES a zone tap; Definition A makes the zone one
leg of a same-bar conjunction; the ML path has NO zone requirement.
X-9 Displacement: Engine 2 = confirmation weight boost; P3-S.6 = E-agent
confirmation input. Label conflict.
X-10 M3: no project document makes M3 a setup requirement; legacy v4.x does
not use M3 at all.
```
---
## I. PREVIOUS BUG-CLASS CHECK (brief §31 pattern)
```text
detector correct -> consumer wrong : CONFIRMED at the SETUP level
(the E-rule detector exists but no consumer can observe a setup; D-9/D-10).
correct state -> wrong as-of timestamp : NOT FOUND (closed-bar lock; CS-T17).
correct TF -> wrong cache slot : NOT FOUND in production consumers
(single macro source; latent by-convention risk carried from P3-S.7 D-3).
correct setup semantics -> flat vote : CONFIRMED (D-1 carried; D-9).
setup identity missing : CONFIRMED (D-10).
```
---
## J. BUG REGISTER (documented only — NOT fixed)
| BUG-ID | Severity | Source | Function | Spec requirement | Actual behavior | Impact | Proposed repair |
|--------|----------|--------|----------|------------------|-----------------|--------|-----------------|
| BUG-P3S8-001 | HIGH | AF_Engine2_Aggregator.mqh + Engine 3 | aggregator / dashboard | CS-22: score != setup; a setup must be distinguishable from a bare vote signal | BUY/SELL can fire with no setup; dashboard labels signal "TRADE SETUP" | consumers cannot tell setup-signals from vote-signals | expose setup predicate/identity separately; relabel dashboard |
| BUG-P3S8-002 | HIGH | AF_Engine2_Agents.mqh | AFAgentEntry / AFFuzzyEval | CS-1: setup = zone AND confirmation; should be observable | E vote saturates at +/-1.0 with or without the setup leg | setup presence invisible downstream | output the setup predicate as a field |
| BUG-P3S8-003 | MEDIUM | Engine 2 (whole) | E-rule / aggregator | CS-23: dedup/identity required for "one setup" semantics | no setup_id; per-bar repeated emission | no dedup, no lifecycle, no per-setup outcome | define setup identity layer (P3-S.9) |
| BUG-P3S8-004 | MEDIUM | AF_Defines.mqh / E-rule | none | CS-28: freshness window semantics | no SeqWindow equivalent in Engine 2; CHoCH state never expires | Definition-A setups have no freshness | adjudicate window policy (P3-S.9) |
---
## K. NEXT GATE
```text
After the Candidate Setup verdict:
STOP the semantic audit chain.
P3-S.9 = CROSS-PRIMITIVE CONSOLIDATED REPAIR / ARCHITECTURE REVIEW
(only after reviewing the full P3-S.2..P3-S.8 evidence).
DO NOT repair code now; DO NOT return to ML; DO NOT retrain.
```
---
## L. CHECKPOINT & PROVENANCE (P3-S.8)
```text
Forge HEAD (session start) : 533c8c6647a552d01a1a290cb2d0505f94887666 (P3-S.6)
Branch / remote : main == origin/main (SniperGold_ML.git)
Working tree : P3-S.7 artifacts untracked (intact); nothing else
P3-S.7 artifacts : intact
FEATURE_CONTRACT : NOT modified
No production change : AF_Engine1_MTFData / AF_Engine2_Agents /
AF_Engine2_Aggregator / AF_Engine2_Display /
AF_Engine3_Render / f7-f18 / FVG / OB / CHoCH /
Displacement / ML / legacy v4.x : NOT touched
Human verification : CANCELLED
```