fix: COUCH gate — Kelvin wave regime check

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.
This commit is contained in:
openresearch 2026-07-04 21:09:03 +00:00
parent 3cbf5a2560
commit e61ee5cfdc
2 changed files with 49 additions and 20 deletions

View file

@ -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.

View file

@ -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