forked from chiki2bum2/SniperGold_ML
14 KiB
14 KiB
P3-S.17R.1 RESEARCH SWEEP EVENT CONTRACT REPAIR + FULL GATE WIRING — SNIPERGOLD_ML
Date : 2026-08-23
Session : P3-S.17R.1 — Research Sweep Event Contract Repair + Full Gate Wiring
Baseline : P3-S.17R close checkpoint 92e5bd6a8fa065c4be5509ad6c2100c1893739da
VERIFIED (authoritative workspace; local == origin/main, branch
main, origin = forge.mql5.io/chiki2bum2/SniperGold_ML.git).
Scope : RESEARCH-ONLY. XAUUSD M15 (Files/AlgoForge/Data), authorized scope
2017-01-03..2026-07-21 (194,985 bars), matching the P3-S.17 /
P3-S.17R runtime-parity baseline. NO Tickstory/Dukascopy.
Human verif: REMAINS CANCELLED (historical only). NO AUC/PF/backtest/opt/ML.
Verdict : PARITY ACHIEVED WITH CAVEATS — the research-side sweep EVENT
representation is byte-locked to the frozen MQL5 runtime
(2938/2938 onsets, 194,985/194,985 contract-active bars on the
full scope) and the H4/M30/M15 gate series are wired with the
runtime as-of semantics (full scope); the F3 Candidate Setup
chain reproduces runtime==research with identity on every
deterministic window. CAVEAT: the full-scope Candidate Setup
population still requires vectorized CHoCH/OB/FVG kernels
(documented future step, P3-S.17R §W), so the P3-S.17 re-audit
on the FULL population remains deferred.
Next gate : NOT training (P3-S.18 NOT ready). After full-scope vectorization,
re-run this parity suite on the complete scope, then the P3-S.17
re-audit on the reconciled population.
A. Latest SESSION_HANDOVER used
docs/SESSION_HANDOVER_2026-08-23_P3_S17R_RUNTIME_RESEARCH_PARITY.md
P3-S.17R = COMPLETE
Final verdict = PARITY BLOCKED
First divergence = Liquidity Sweep research proxy
Second blocker = H4/M30/M15 gate-series wiring
P3-S.18 = NOT READY
Next = P3-S.17R.1
P3_S17R_FINAL_SHA recorded = 8920fdb3 (ancestor of the close commit
92e5bd6 which is the prompt-stated checkpoint and current HEAD)
Reconciled with Git: HEAD == origin/main == remote HEAD == 92e5bd6; branch
main; working tree clean at start (4 untracked P3-S.17R.1 research artifacts
from an interrupted earlier attempt were adopted after verification).
B. Checkpoint
Start HEAD : 92e5bd6a8fa065c4be5509ad6c2100c1893739da (P3-S.17R close)
Branch : main == origin/main
Remote : https://forge.mql5.io/chiki2bum2/SniperGold_ML.git
Data : Files/AlgoForge/Data (XAUUSD_M15.npz 2017+; H4/D1/H1 npz;
M30 resampled 2xM15 from the same feed)
C. Original P3-S.17R blocker
PARITY BLOCKED because:
1. FIRST DIVERGENCE (sweep): the research-side proxy sweep
(`smc_semantic_common.sweep_state`) is a PERSISTENT LATCH: once set it
marks every subsequent bar active. On the deterministic 2,000-bar subset
the legacy latch produced 1,896 active sweep-state bars (~94.8%) while a
faithful P3-S.2 EVENT reading produces a handful of onsets. The frozen
contract (P3-S.2 §8/§9, P3-S.11) defines sweep as an EVENT {onset, dir,
valid_until, superseded} with W_sweep = 40 — NOT a latch without expiry.
2. SECOND BLOCKER (gates): the H4/M30/M15 gate series consumed by the F3
layer were not wired; the research full-population path ran with neutral
(all-zero) gates, so the Candidate Setup chain could not form.
D. Sweep proxy root cause
MEASURED (same 2,000-bar deterministic subset, first 2000 M15 bars of 2017):
legacy `smc_semantic_common.sweep_state` active bars : 1,896 / 2,000 (latch)
faithful P3-S.2/P3-S.11 EVENT port (sweep_event.py) : 25 onsets / 2,000
byte-locked runtime reference (sliding window) : 25 onsets / 2,000
ROOT CAUSE of the latch divergence:
- the legacy proxy stored `sweep_bar[]` as a last-onset persistent state and
exposed it as "sweep active" for EVERY bar >= onset (no expiry, no
validity window, no supersession semantics) — a STATE/EVENT convention
divergence (P3-S.17R §H classification).
ADDITIONAL FINDING (measurement-proxy correction):
- the P3-S.17R "58 onsets / 2,000" figure came from the PAR suite's sweep
port (spec_tests_runtime_research_parity.sweep_internal_pivots), which
uses a 4-left/4-right pivot approximation without the runtime's begin=100
warm-up. The faithful runtime pivot is internal len=5 with begin=100
(ProcessStructure) -> 25 onsets / 2,000. The 58 figure was itself an
approximation artifact; the byte-locked port supersedes it.
- the P3-S.17 audit's "84 onsets / 194,985" is a THIRD counting (its own
proxy); the faithful full-scope count is 2,938 onsets (~1.5% of bars).
E. Sweep repair
REPLACED the legacy latch with a true semantic research port:
ml/p3/smc_semantic/sweep_event.py
- internal swing pivot len=5, begin=100 warm-up (ProcessStructure)
- effective sweep window [p+6, p+8] (p+1..p+5 cannot match by pivot
confirmation; SPEC §4 consequence note)
- wick penetration + SAME-BAR close-back (buy-side swept -> -1,
sell-side swept -> +1)
- EVENT materialization {onset, dir, valid_until = onset + W_sweep(40),
superseded}
- per-bar contract-active view (age <= 40)
SEPARATION (F1 order): detection -> event materialization -> validity ->
supersession.
EMISSION-ORDER FIX (byte-lock):
- the runtime DetectLiquidityGrabs emits NEW events in ONSET-BAR order
(a sweep at bar b is visible at decision r = b), not in pivot order.
An EARLIER pivot with a LATER onset bar can precede a LATER pivot with an
EARLIER onset; the runtime emits BOTH (record highs in bar order). The
port now sorts raw onsets by (onset, pivot) before the record-high filter
-> reproduces the runtime's new-event sequence exactly. Pinned by SR-T15.
F. Sweep parity (real data, full authorized scope)
research event onsets : 2,938
runtime event onsets : 2,938 (byte-locked sliding-window reference)
exact matches : 2,938
runtime-only events : 0
research-only events : 0
contract-active bars : 194,985 / 194,985 exact (age <= 40)
event identity : onset + dir + valid_until + superseded IDENTICAL
=> SWEEP PARITY ACHIEVED (event-level byte-lock on the full scope).
The legacy latch (1,896/2,000 active) is gone from the setup path.
Output: ml/p3/setup_dataset/output/p3_s17r1_full_parity.json
(sweep_parity_detail); synthetic contract cases:
ml/p3/setup_dataset/output/p3_s17r1_sweep_parity.json (SR-T01..T15, 15/15).
G. H4 gate parity
H4 gate = Narrative agent dir (AFAgentNarrative, AF_Engine2_Agents.mqh) on the
H4 slot, as-of the newest CLOSED H4 bar with close_time <= decision-bar close
(runtime Engine-1 cache; canonical §L / P3-S.7 S-T; GR-T11 pins before /
exactly-at / after HTF close; GR-T12 pins no-future).
Research port: spec_tests_engine2_gates.py (frozen constants, fuzzy memberships,
rule weights, AF_E2_DIR_TOL=0.05, E2_MIN_BARS=80).
Full scope (in authorized window): 163,830 / 194,985 nonzero (+/-/0 split
recorded in full_parity.json). GR-T01..T03 (bullish/bearish/neutral) PASS.
H. M30 gate parity
M30 gate = Context agent dir (AFAgentContext) on the M30 slot, same as-of rule
(M30 bars resampled 2xM15 from the authorized feed).
Full scope: 178,764 / 194,985 nonzero. GR-T04..T06 (bullish/bearish/neutral)
PASS; GR-T07/T08 (H4/M30 agreement -> CANDIDATE_SETUP; conflict -> BLOCKED
H4_M30_CONFLICT) PASS.
I. M15 gate parity
M15 entry = Entry agent dir (AFAgentEntry) on the M15 decision bar itself.
Full scope: 145,220 / 194,985 nonzero. GR-T09/T10 (M15 agreement ->
CANDIDATE_SETUP; conflict -> BLOCKED M15_CONFLICT) PASS; GR-T13 (insufficient
history -> 0) PASS; GR-T14 (bull/bear symmetry) PASS.
J. Full Candidate Setup parity
Staged full chain (Data -> H4 -> M30 -> Sweep -> CHoCH -> OB -> FVG -> M15 ->
Candidate Setup) on 11 deterministic 2,000-bar windows spanning the scope
(22,000 bars sampled; SUB-A first-2000 per P3-S.17R convention + 10 windows):
window runtime research identity outcome
SUB-A 0..2000 0 0 match match
SUB-B 10000..11999 2 2 match match
30000..32000 0 0 match match
50000..52000 2 2 match match
70000..72000 0 0 match match
90000..92000 0 0 match match
110000..112000 0 0 match match
130000..132000 0 0 match match
150000..152000 0 0 match match
170000..172000 4 4 match match
190000..192000 0 0 match match
---------------------------------------------------------
total (sampled) 8 8 all all
F3 lifecycle trace on 90000..92000 (0 setups): 19 single-bar complete chains
exist, 13 blocked by an occupied forming slot, 6 chains started and were all
discarded at STRUCTURE_CONFIRMED by context/event lapse (volatile H4/M30
gates + event windows) — the frozen lifecycle working as designed, and the
research side reproduces it EXACTLY.
The PREVIOUS 0-population (P3-S.17) was an EXTRACTOR ARTIFACT:
(a) proxy latch sweep + over-marked zone mitigation proxies,
(b) neutral (all-zero) gates,
(c) a frame-vs-decision coordinate bug in the research runner that made
every event onset appear AFTER every decision bar.
With faithful detectors + real gate series + correct coordinates the
population is NON-ZERO and runtime==research.
K. P3-S.17 re-audit (authorized only after full runtime<->research parity)
NOT RUN. The full-scope Candidate Setup population requires vectorized
CHoCH/OB/FVG detection kernels (O(n^2) pure-Python ports are not tractable on
194,985 bars; documented future step in P3-S.17R §W.4). The parity
verdict here is ACHIEVED WITH CAVEATS precisely because the FULL-population
re-audit (de-overlap, class distribution, censoring, ambiguity, lifetime,
feature snapshot, reproducibility) must run on the complete scope. The
evidence so far (non-zero population on sampled windows, runtime==research)
indicates the previous zero WAS an extractor artifact, but the re-audit
numbers cannot be certified until the full-scope chain is computable.
L. Regression (research-only changes; re-run after the repair)
P3-S.2 Liquidity Sweep 17/17 PASS
P3-S.3 CHoCH/MSS 20/20 PASS
P3-S.4 FVG 20/20 PASS (namespace boundary holds; the new
FVG/OB-referencing research files
live in the spec_tests_* namespace
per the frozen P3-S.17R decision)
P3-S.5 Order Block 20/20 PASS
P3-S.6 Displacement 20/20 PASS
P3-S.7 MTF Alignment 22/22 PASS
P3-S.8 Candidate Setup 25/25 PASS
F1 Event Contract 8/8 PASS
F2 Zone Contract 20/20 PASS
F3 Candidate Setup Rt 25/25 PASS
F4 MTF Training Align 16/16 PASS
P3-S.16 Setup Dataset 20/20 PASS
P3-S.17R Runtime-Research 17/17 PASS
P3-S.17R.1 Sweep (SR) 15/15 PASS (T01..T14 + T15 emission-order)
P3-S.17R.1 Gate (GR) 14/14 PASS
No historical suite weakened or modified. Historical report outputs restored
(timestamp-only side effects reverted).
M. Production files unchanged
MQL5 detectors, AF_Engine2_Setup.mqh, AF_Engine2_Agents.mqh, AF_Defines.mqh,
AlgoForge_Backtest_Baseline.mq5, F1/F2/F3/F4 runtime, FEATURE_CONTRACT.md,
SniperGold_ML.mqh, weights, labels, legacy MLP, model artifacts: NONE modified.
Runtime is the PARITY REFERENCE, never altered.
N. Tickstory / Dukascopy status
DEFERRED (unchanged). Not the parity baseline. Future order:
SAME SOURCE runtime<->research parity -> valid Candidate Setup population
-> P3-S.17 re-audit -> only then independent data-source robustness study.
O. Final verdict
PARITY ACHIEVED WITH CAVEATS
runtime == research : YES on every computable scope (sweep events full
scope exact; gates full scope wired; Candidate Setup
identity + per-bar outcome on all sampled windows).
identities/states : correspond (setup_ids, states, funnel).
caveat : the full 194,985-bar Candidate Setup population (and
therefore the P3-S.17 re-audit) requires vectorized
CHoCH/OB/FVG kernels — a computational scope limit,
NOT a semantic divergence.
NOT ZERO POPULATION CONFIRMED (population is non-zero on the sampled scope).
NOT PARITY BLOCKED (no runtime-only/research-only divergence remains).
NOT RUNTIME/SPEC CONFLICT (the only boundary nuance — HTF close-time <=
decision-bar close vs the contract §L "close_time <= t" text — is
deterministic, pinned by GR-T11, and follows the runtime Engine-1 cache
per §14/§15; documented, not a blocker).
P. Forge commits
test: define P3-S.17R.1 sweep parity coverage (SR-T01..T15)
test: define P3-S.17R.1 gate parity coverage (GR-T01..T14)
research: repair sweep and gate research semantics (sweep_event.py,
spec_tests_engine2_gates.py, spec_tests_p3_s17r1_full_parity.py)
docs: record P3-S.17R.1 parity repair (report + handover)
Q. Final Forge HEAD
13a23df0d87e1cda0178b2924dae2a5c1e143b46 (P3_S17R1_FINAL_SHA; local == origin/main)
R. Working tree
CLEAN after push; local HEAD == origin/main.
S. P3-S.18 readiness
NOT READY. Training remains blocked. Before P3-S.18:
1. vectorize CHoCH/OB/FVG detection kernels for the full 194,985-bar pass,
2. re-run this staged parity on the COMPLETE scope (all 9 stages),
3. then the P3-S.17 re-audit on the reconciled full population.
The sweep byte-lock and the H4/M30/M15 gate wiring (this session's scope) are
done; the chain runs truthfully wherever it is computable.
End P3-S.17R.1 report. Verdict: PARITY ACHIEVED WITH CAVEATS.