Navigation

Iteration 07 · 2026-06-09 · driver: native Claude Code /loop (laptop run)

Feature #6 — mann_kendall_z (PR #96)

← Dashboard · PR terrylica/mql5#96 · card 20 · cut off bootstrap #90

Done. The sixth ξ-confirmed candidate — the FIRST randomness/rank-trend feature — is a REAL continuous-float production column on fxview_cache.forex_bars: bit-exact Rust verified against a pinned Python SSoT, populated through the wired producer, with batch≡streaming parity and an independent 3-way FOSS corroboration. PR #96 open (base main; diff auto-cleans once #90 + #91 + #92 + #93 + #94 + #95 land).

What it computes

Normalized Mann-Kendall monotonic-trend Z (Mann 1945 / Kendall 1975, DOI:10.2307/1907187) of the per-bar mid-close level over the 200-bar strictly-trailing window — a rank-based, distribution-free measure of directional drift. Causal: the window is the 200 bars BEFORE bar i (current bar excluded). None on warmup (<200 trailing closes). Two SSoT subtleties pinned bit-for-bit to the probe k_mann_kendall (NOT pymannkendall): (1) sign conventionS = Σ_{i<j} sign(close[i]−close[j]) via np.triu(np.sign(np.subtract.outer(y,y)),1) (EARLIER−LATER, the negated textbook MK; since (S−sign(S))/√var is odd in S, an uptrend yields a NEGATIVE Z); (2) variancen(n-1)(2n+5)/18 with NO tie correction. Substrate = RAW mid-close level (NO log-return, NO weekend/Ouroboros gap-null — gaps are part of the level path, identical to hvg_clustering).

The chain — one SSoT, bit-exact to the column

LayerArtifactResult
Python SSoToracle_mann_kendall_z.py — bit-faithful reproduction of probe k_mann_kendall over the "close" 200-bar windowsha-pinned jsonl (12000 rows, 11200 finite) + .sha256 sidecar
Rust kernelorthogonal_extension_kernels::mann_kendall_z — integer-exact i64 pair-sign S + simple variance + (S−sign(S))/√var; no new dep (f64::sqrt)clippy clean; 8 unit tests pin probe-exact values
Differential parityvs the pinned oracle on the frozen fixture11200 == oracle, 12000 bars == rows, max|dev| 3.553e-15 (S exact, Z ≈1 ulp)
Producer columnBarOrthogonalExtV1 { mann_kendall_z } + BarRow + schema.sql Nullable(Float64) CODEC(Gorilla(8),ZSTD(1)) + feature_metadata.yamltest_schema_contract 4/4
Producer populateMannKendallZRollingState — 200-bar RAW close ring (no logret, no gap-null); read-before-push observe(close_mid) @ finalize
batch≡streamingstreaming observe() over the fixture per partition11200 == oracle, max|dev| 3.553e-15 (identical to batch)
3-way FOSSprobe-form vs clean-room nested-loop vs pymannkendall@MIT integer SPASS — 0 S-mismatches (3-way), 0 Z-mismatches, max|dev_Z| 0.000e+00 / 11200

3-way FOSS finding (it earned its keep — twice)

The integer S statistic is corroborated by THREE independent counters: the probe's np.triu(np.sign(outer)), a from-scratch clean-room O(n²) nested-loop pair-sign sum, and pymannkendall@MIT's tau-based .s (asserting pmk.s == −S_probe) — all agree integer-exact over 11200 windows; S_probe ≡ S_cleanroom Z-values agree bit-for-bit (max|dev| 0.000e+00). KEY FINDING: the "close" substrate is TIE-PERVASIVE100% of 200-close windows contain ties (ODB range-bar closes recur at discrete broker-tick levels), so pymannkendall's tie-corrected Z diverges from the SSoT simple-variance Z by up to ~1.7e-3. This is the load-bearing reason the probe (hence the kernel) uses the simple variance: adopting pymannkendall as the oracle would have made the production column materially WRONG. The 2-way Rust↔probe parity alone could not have surfaced this — the FOSS leg did. (cran/Kendall is GPL-2 and is NOT used; only pymannkendall@MIT + a clean-room-from-formula leg.)

Challenge-and-Held (inline; sub-agent dispatch skipped per the tick-3 signal)

Gates / scope

Next

Feature #7 — sevcik_fd (card 10, Sevcik fractal dimension of the close path; ε ~1e-9; FOSS ref neurokit2.fractal_sevcik, NOT antropy — per the bootstrap errata).

Presentation only — never the SSoT.