From e61ee5cfdc8074f2a4d578eb94bd8c5cc7a14c0e Mon Sep 17 00:00:00 2001 From: openresearch Date: Sat, 4 Jul 2026 21:09:03 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20COUCH=20gate=20=E2=80=94=20Kelvin=20wave?= =?UTF-8?q?=20regime=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The COUCH gate now has TWO stages (matching BraidStateN.lean): Stage A — Rossby/Kelvin regime: - Rossby drift ≠ 0 → Rossby regime (dispersive, active mixing) → PASS - Rossby drift = 0 → Kelvin regime (boundary-trapped, NO mixing) → FAIL The Kelvin regime is the degenerate case: perfectly balanced chiral distribution. Energy dissipation rate is ZERO (proven in rossby_energy_dissipation_rate: requires isActive=true). kelvinLabels8 (all achiral_stable) → drift=0 → Kelvin → FAIL rossbyLabels8 (alternating left/right) → drift≠0 → Rossby → PASS This is the 'q=1 degenerate' / 'rational surface' / 'stuck' case. Stage B — scarred contention: - scarred_count → self_loop → threshold (unchanged) A config passes COUCH iff BOTH stages pass. Updated both pipeline_core.py (Python) and chiral_cross_enrich.wgsl (GPU shader) with the Kelvin check. --- python/chiral_cross_enrich.wgsl | 19 +++++++++---- scripts/pipeline_core.py | 50 +++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/python/chiral_cross_enrich.wgsl b/python/chiral_cross_enrich.wgsl index 60947460..2956c091 100644 --- a/python/chiral_cross_enrich.wgsl +++ b/python/chiral_cross_enrich.wgsl @@ -113,21 +113,30 @@ fn compute_helical(step: u32) -> u32 { return ((step * GOLDEN_ANGLE) / Q16_ONE) % EXOTIC_CLASSES; } -/// COUCH stability: scarred count → self-loop → threshold check. +/// COUCH stability: two-stage check. +/// Stage A: Rossby/Kelvin regime (drift=0 → Kelvin → boundary-trapped → FAIL) +/// Stage B: scarred contention (self-loop < threshold) fn compute_couch(config_id: u32) -> u32 { + // Stage A: Rossby drift must be non-zero (Kelvin regime fails) + let drift = compute_rossby(config_id); + if (drift == 0) { + // Kelvin regime: boundary-trapped, no mixing, zero dissipation + // (proven: rossby_energy_dissipation_rate requires isActive) + return 0u; // COUCH FAILS — stuck like AVX-512 (self_loop=0.885) + } + + // Stage B: scarred contention check var scarred_count: u32 = 0u; for (var s: u32 = 0u; s < N_STRANDS; s = s + 1u) { if (get_chiral_type(config_id, s) == 1u) { // chiral_scarred scarred_count = scarred_count + 1u; } } - // self_loop = 57942 * scarred_count / 8 (Q16_16) let self_loop = (57942u * scarred_count) / N_STRANDS; - // COUCH stable if self_loop < threshold if (self_loop < COUCH_THRESHOLD) { - return 1u; // stable + return 1u; // COUCH PASSES — Rossby active + low contention } - return 0u; // unstable + return 0u; // COUCH FAILS — too much scarred contention } /// Main kernel: each thread processes one cross-enriched configuration. diff --git a/scripts/pipeline_core.py b/scripts/pipeline_core.py index dcc064b4..8331c552 100644 --- a/scripts/pipeline_core.py +++ b/scripts/pipeline_core.py @@ -257,16 +257,28 @@ class MultisurfacePacker(Filter): # ── Stage 5: COUCH — Geometric stability via Rossby drift ───────────── class COUCHFilter(Filter): - """COUCH gate: Rossby drift determines stability. + """COUCH gate: two-stage stability check. - Uses the ACTUAL rossbyDriftFromChirality from BraidStateN.lean: - left=+65536, right=-65536, scarred=+32768, achiral=0 + Stage A — Rossby/Kelvin regime check (from BraidStateN.lean): + - Rossby drift ≠ 0 → Rossby regime (dispersive, active mixing) → PASS + - Rossby drift = 0 → Kelvin regime (boundary-trapped, NO mixing) → FAIL - Non-zero drift → Rossby regime (active, dispersive) → COUCH passes - Zero drift → Kelvin regime (boundary-trapped) → COUCH may fail + The Kelvin regime is the degenerate case: perfectly balanced chiral + distribution (left+right cancel, no scarred). Energy dissipation rate + is ZERO (proven: rossby_energy_dissipation_rate requires isActive). + This is the "q=1 degenerate" / "rational surface" / "AVX-512 stuck" + case — the system can't mix. - Also computes helical_residue (winding number mod 28) from - HopfFibration.lean: ⌊k·ψ⌋ mod 28 where ψ=25042 (Q16_16). + rossbyLabels8 (BraidStateN.lean line 327): alternating left/right + → drift ≠ 0 → Rossby → dispersive → COUCH passes + kelvinLabels8 (BraidStateN.lean line 338): all achiral_stable + → drift = 0 → Kelvin → boundary-trapped → COUCH fails + + Stage B — Scarred contention check (from HCMR): + - scarred_count → self_loop proxy → threshold check + - High scarred count = high contention = AVX-512 regime + + A config passes COUCH iff BOTH stages pass. """ def __init__(self, threshold=Q16_THRESHOLD_COUCH): self.threshold = threshold @property @@ -274,18 +286,26 @@ class COUCHFilter(Filter): def apply(self, configs, ctx): result = [] for c in configs: - # Rossby drift (actual implementation from BraidStateN.lean) + # Stage A: Rossby/Kelvin regime drift, is_active = rossby_drift(c.chiral) c.rossby_drift = drift - # Helical residue (winding number mod 28, from HopfFibration.lean) + if not is_active: + # Kelvin regime: boundary-trapped, no mixing → COUCH FAILS + c.metadata["regime"] = "kelvin" + c.self_loop = Q16_AVX_SELFLOOP # stuck, like AVX-512 + continue + c.metadata["regime"] = "rossby" + + # Stage B: scarred contention + scarred_count = sum(1 for cl in c.chiral if cl == "chiral_scarred") + c.self_loop = (Q16_AVX_SELFLOOP * scarred_count) // max(len(c.chiral), 1) + if c.self_loop >= self.threshold: + continue # too much contention + + # Helical residue (winding mod 28, from HopfFibration.lean) step = c.metadata.get("step", 0) c.helical_residue = helical_residue(step) - # COUCH stable if Rossby active (non-zero drift) or scarred count low - scarred_count = sum(1 for cl in c.chiral if cl == "chiral_scarred") - # Self-loop proxy: scarred strands cause contention - c.self_loop = (Q16_AVX_SELFLOOP * scarred_count) // max(len(c.chiral), 1) - if c.self_loop < self.threshold: - result.append(c) + result.append(c) return result