# 01 — Technique proposals (Technique Designer, 2026-11-06)

Inputs read: `00_inventory.md/.json`, `multi_agent_opt/{CURRENT_BEST,ALREADY_TRIED,STATUS_GAPS,CLAIMS}.md`,
dataset-repo `CONTEXT_*`, `REAL_SWITCH_STRATEGY.md`, `experiments/decoder_lodo/{hmm_learned.py,antisym_transformer_experiment.py}`,
`direct_classifier.py`, `ensemble_clf_transformer_v2.py`, `score.py`, `e1_switch.synth_trial`,
`external_data/AASD/convert_aasd.py`. No training was run.

Machine-readable copy: `01_technique_proposals.json`. Handshake: `BOARD.md`.

## 0. What the targets mean today (read before picking a run)

| Target | Best honest number | Best number on disk | Why they differ |
|---|---|---|---|
| LODO mean H ≥ 0.85, Acc ≥ 78 | 0.798 / 73.3 (4 dec + 4 clf `sw2`, antisymmetric) | 0.884 / 83.4 (stem family) | stem family uses a column-0 / start-of-trial prior |
| AASD H > 0.63 | 0.645 / 54.05 Acc | same | real switches; Acc near chance |
| Carta H > 0.60 | 0.652 / 60.5 | same | |

**Measured today (new fact, 2026-11-06):** in all five training corpora `att_col` is **0 for 100 % of samples of 100 % of trials**
(AVGC 99, DTU 1080, KUL 320, UHD 120, USTC 360 trials). The synthetic LODO schedule (`e1_switch.draw_switch_times`) always starts
**unswapped** and keeps the first segment ≥ 30 s, with later gaps U(30, 90) s. So in LODO the label is mostly a function of
"time since trial start" plus a parity counter. The stem net (abs. position, zero pad, bias, `y=(att==0)`, 96-frame = 24 s window)
can read it, and this explains "first 24 s = constant column 0". On real switches (random start column, 10–25 s dwell) this
prior is wrong: the stem family gives Carta Acc 49–51 % (below the plain 4-logit mean, 58.7 %).

Consequences for every proposal below:
1. **Gates.** Every new model must pass, before any score is trusted: (a) column swap, `|f(x)+f(−x)| < 1e-5`; (b) position
   invariance: decisions after second 60 must not change when 60 s of other logits are prepended (≥ 99 % agreement);
   (c) `leakage_test.py` ≤ 0.969 s.
2. **Honest baseline for LODO is 0.798**, not 0.884. Getting a valid ≥ 0.85 needs about +5–6 points of frame accuracy
   in the evidence, not a better decision layer (150+ decision-layer variants are already closed).
3. Report LODO and AASD/Carta paired by seed. AASD/Carta labels are never used to pick hyperparameters.

Ranking criterion: expected gain on the **joint** objective (LODO honest H, AASD H, Carta H) per GPU hour, and novelty versus `ALREADY_TRIED.md` + inventory.

## 1. Candidates (ranked)

| Rank | ID | Name | Track | Effort | Expected effect (honest) | Main risk |
|---:|---|---|---|---|---|---|
| 1 | **T1** | Latency audit + causal within-trial **stimulus lag-bank** | evidence, inference-only | low (0.5 d code, ~3 GPU h) | AASD/Carta Acc +0…+6 if an alignment offset exists; LODO ±0.003 | no offset exists → near-zero gain (cheap to learn) |
| 2 | **T2** | **ESR-stem**: exactly odd, position-free, schedule-resynthesised logit stem | 2nd stage | medium (1 d code, ~2 GPU h) | LODO 0.82–0.85 honest; AASD/Carta H +0.005…+0.02 vs mean-4 | gains over 0.827 (symmetrised zip stem) may be small |
| 3 | **T3** | **Counterfactual-null** regulariser + causal null-debias of the classifier | evidence, train + inference | medium (diag 1 h, FT ~8 GPU h) | AASD/Carta Acc +0.5…+2; LODO ±0.005 | null term too strong → classifier collapses to 0 logits |
| 4 | T4 | **Lapse-aware label cleaning** from an offline bidirectional teacher | evidence, train | medium-high | LODO Acc +0.5…+1.5 (AVGC most); real +0…+1 | teacher confirms its own errors |
| 5 | T5 | **In-trial distractor ranking** (shared past-envelope reference) | evidence, inference-only | low | real Acc +0…+1 | net not trained on real-vs-distractor pairs |
| 6 | T6 | **Lookahead reallocation**: classifier-only stack at 0.97 s budget | evidence, retrain | medium | +0.003…+0.01 H on both | small effect, retrain 4 seeds |
| 7 | T7 | **Weight soup** across seeds × folds of the SPK-initialised classifier | evidence, inference-only | low | real +0…+1 Acc; LODO ±0.005 | non-linear-mode-connected → soup collapses |

Why the order: T1 is the cheapest test of the single hypothesis that could move AASD Acc from 52 % (near chance), and hidden
test sets come from different hardware (BioSemi, NeuroScan), so a lag-robust front end protects the submission whatever T1 finds.
T2 is the only way to keep a second-stage net (the source of the large LODO gains) without the column-0 shortcut. T3 attacks
stimulus-only (acoustic) evidence that antisymmetry cannot remove and that is likely to differ on Mandarin/babble external audio.

---

## 2. Candidate details

### T1 — Latency audit + causal within-trial stimulus lag-bank (LagBank-Sel)

**Hypothesis.** The classifier is very lag-sensitive: ±2 samples (±60 ms) of training jitter cost −0.03 H. AASD is aligned by
assuming that EEG epoch sample 0 = audio onset (`convert_aasd.py`, `env = envelope(start[t])[:n128]`); the mapping check only
verified *which* wav and *which* key, not the latency. Any fixed offset (trigger delay, epoch baseline, sound-card buffer)
would push a lag-sensitive classifier toward chance, which is what AASD shows (acc1 0.50–0.54). Hidden test sets use different
amplifiers (BioSemi vs NeuroScan) and labs, so a latency mismatch is plausible there too.

**Not a repeat.** Lag *jitter augmentation* (`lag2`) blurred training labels and is closed. A3 shifted *labels* (attention lag),
not stimuli. TRF lag-banks were Path-A evidence models. Here the frozen published classifiers are re-run on shifted stimuli and
the lag is selected per trial, causally, without labels.

**Step A (diagnostic, labels only read, nothing tuned):** acc1 and mean signed logit versus lag δ ∈ {−16…+16} samples at 32 Hz
(±500 ms) per dataset (5 LODO folds with fold checkpoints, AASD, Carta with all5 checkpoints), 4 seeds. Output a curve per
dataset. If AASD or Carta peaks at δ ≠ 0 by > 2 SE (subject bootstrap), that is a conversion offset. Fix it in the converter
(a data fix, recorded as such) and re-score every external baseline.

**Step B (technique, label-free, legal at test).**
- Shift without extra lookahead: δ > 0 pairs EEG[t] with stimulus[t − δ]; δ < 0 pairs EEG[t − |δ|] with stimulus[t]. Each
  window still ends at its own `t_end`, so no data after the current decision time are used.
- Per trial, causal score per lag: `s_δ(t) = EWMA_τ(d_δ(t)²)` (bias-corrected, normalised weights so there is no start-of-trial marker).
- Soft selection: `w_δ(t) = softmax_δ(β·(log s_δ(t) − log s_0(t)) − γ·|δ|)`, `d*(t) = Σ_δ w_δ(t)·d_δ(t)`. It is odd in d, so the column-swap test passes.
- The same δ is used for both streams, so antisymmetry holds.

**Hyperparameters** (choose on LODO inner folds by Acc then H, never on AASD/Carta): τ ∈ {30, 60, 120} s; β ∈ {2, 5, 10};
γ ∈ {0, 0.05, 0.2} per sample; lag grid step 2 samples (17 lags) for B, full 33 for A. HMM preset 0.994 / 0.8 and 0.998.

**Risk.** If no offset exists, Step B gives ~0 and can add selection noise. The γ prior toward 0 limits that. Cost is 17× inference.

### T2 — ESR-stem: Equivariant, position-free, Schedule-Resynthesised logit stem

**Hypothesis.** The stem's LODO gain has two parts: (i) legitimate temporal integration of the 4-seed evidence (multi-scale
context, learned lag/shape of the evidence around switches), and (ii) the column-0/start-of-trial shortcut. Removing (ii) by
construction and training on schedules that cover both regimes (synthetic 30–90 s and real-like 4–40 s dwell, random start
column, ramped transitions that mimic the measured ~4 s evidence lag) keeps (i). That should beat the HMM on both LODO and
real data, unlike B3 (EMA + tanh, trained on AASD/Carta) and the zip `sym` stem (trained on the shortcut schedule).

**Not a repeat.** Closed neighbours: `stem_ms96` and all its fine-tunes (non-odd, abs-pos, zero pad); `stem-synth-switch`
(denser in-window flips, still non-odd and with the col-0 first segment); dataset-repo `antisym_transformer_experiment.py`
(8 s window, 4 raw logits, learned abs-pos, original schedule); B3 learned rule (linear EMA readout, trained on real sets).
New here: the full 24-d ms stem made exactly odd, plus no position code, no zero pad, plus label/evidence **resynthesis** with
random start sign, broad dwell mixture and evidence ramps.

**Mechanics.**
- Aligned evidence `Dc = D · sgn(att==0)` from the LODO-train folds' 4-seed logits (`N.G["base"]["id"]`). After alignment,
  + always means "attended". The dips at the old switch points stay as natural lapses.
- K = 8 resynthesised copies per trial: start sign ±1 at random. Dwell ~ 0.5·LogUniform(4, 40 s) + 0.5·U(30, 90 s). Evidence
  multiplier `q̃(t)` ramps linearly from ±1 to ∓1 over r ~ U(0.5, 6) s starting at the switch. The label switches as a hard step at τ.
  `D' = Dc · q̃`. ms features (raw, hp60, hp120, z60, slope, mean) are all odd in D, so they are recomputed on D'.
- EMAs use normalised weights (as in `hmm_learned.ema_features`), so the first frames carry no "trial start" signature.
- Net: `g` = `LogitTransformer` with `pos` removed, conv stem with replicate left-pad, key-padding mask in attention.
  Output `f(x) = ½·(g(x) − g(−x))`, so it is exactly odd.

**Hyperparameters:** window 96 and 192 frames; d 64; 2 layers; lr 8e-4 cosine; 1500 steps; batch 512; EMA 0.995; switch-weight
2.5 (as v2); smoothness 0.05; K = 8. HMM grid {0.95, 0.99, 0.994, 0.998} × scale {0.8, 1.0} picked by inner LODO (acc74 rule).

**Risk.** Honest LODO may land at ~0.83 (below 0.85). Resynthesis ramps are a model of the lag, not measured on the training
corpora. Mitigation: report r = 0 versus ramp as an ablation.

### T3 — Counterfactual-null regulariser + causal null-debias (CF-Null)

**Hypothesis.** Antisymmetry removes column bias but not **stimulus-only** evidence: the net can prefer the stream that is louder
or more onset-rich, or a voice type, whatever the EEG says. In training corpora such cues can correlate with the attended
story. On Mandarin AASD and on babble-mixed Carta they do not, and they add noise and bias. Existing shortcut controls
(`shift_eeg`, `zero_eeg`) measured mean **accuracy** (~0.5), not the **variance** of the stimulus-only logit, which is what hurts.

**Not a repeat.** Not InfoNCE/contrast-AAD (attended vs unattended), not aux-env MSE, not DANN, not noise augmentation.
The new loss asks for "zero evidence when the EEG belongs to another moment or person", which is a counterfactual invariance.

**Step A (diagnostic, 1 GPU h):** with the published checkpoints compute `d_null(t) = f(EEG[t − L], A[t], B[t])` (L = 20 s,
same trial, past only) and `ρ = std(d_null)/std(d)`, plus the subject-level correlation of EWMA(d_null) with the label, on LODO and on
AASD/Carta. Proceed to Step B only if ρ ≥ 0.25 on at least one real set.

**Step B (train):** fine-tune the published `sw2` classifiers (4 seeds, held-* and all5) with
`L = BCE + λ·mean(f(E', A, B)²)`, where E' is EEG of another training trial (50 %) or the same trial shifted ≥ 20 s (50 %).
λ ∈ {0.1, 0.3} smoke, 4 × 250 steps, same optimiser as published.

**Step C (inference, legal):** `d̂(t) = (d(t) − EWMA_60s(d_null)(t)) / EWMA_60s(std d_null)(t)`, same trial, past EEG only.

**Risk.** λ too high gives under-confident logits. The diagnostic gate stops the run if the null is already small.

### T4 — Lapse-aware label cleaning (offline teacher → window weights)

**Hypothesis.** Labels in the 5 corpora are nominal: listeners are assumed to attend col 0 for the whole trial, but attention
lapses happen (AVGC: 10 min trials, gaze-controlled). An **offline, bidirectional** teacher is allowed at training time (rules restrict
inference only). It is a forward-backward HMM over the full-trial 4-seed out-of-fold logits, plus the decoder evidence. It marks lapse
segments where the posterior for the nominal stream stays < 0.3 for ≥ 5 s. Classifier windows there get weight w = posterior
(soft) instead of 1. This is confident learning on time-series labels.

**Not a repeat.** C3 *simulated* lapses by augmentation, and KD distilled the (shortcut) stem. Here real training windows are
re-weighted from out-of-fold evidence of the same corpus. Use OOF evidence only, to avoid self-confirmation.

**Effort:** medium-high (requires OOF logits for every training trial at every LODO level; nested-fold bookkeeping).
**Hyperparams:** posterior threshold {0.2, 0.3}, min lapse 5 s, weight floor 0.1; retrain 2 seeds first.

### T5 — In-trial distractor ranking

At inference, score each stream against a shared reference built from the trial's own past envelopes:
`e_A = mean_k[f(E, A, N_k)]`, `e_B = mean_k[f(E, B, N_k)]`, `d = e_A − e_B`, with N_k = A or B shifted ≥ 8 s into the past.
K = 4, using the antisymmetric pairwise net. It reduces failure when one stream is near-silent (pairwise comparison degenerates).
SparrKULee pretraining used match/mismatch with shifted own envelopes, so the backbone has seen such pairs. Causal and
inference-only. Pick K and the shift on LODO inner folds.

### T6 — Lookahead reallocation (classifier-only stack, 0.97 s budget)

Never run (G5 in `REAL_SWITCH_STRATEGY.md`). The external leaders are classifier-only (0.75 s lookahead); the decoder
consumes budget for small gain (4 clf alone 0.7932 vs with decoder 0.7949). Retrain 4 `sw2` seeds with `causal_future_s = 0.96`
(label position unchanged relative to the 1-s rule), drop the decoder, rerun `leakage_test.py`. The extra 0.21 s of EEG covers
the 100–250 ms neural response to the last stimulus samples.

### T7 — Weight soup across seeds × folds

All `sw2` classifiers share the SparrKULee init, so they are likely linearly mode-connected. For LODO fold X, average only the 4
held-X seed weights. For external, average 4 seeds × (5 held-* + all5) = 24 checkpoints (uniform, then greedy by LODO
inner H). If `vlaai_ws` contains BatchNorm layers, recompute their statistics on training windows after averaging. This is inference-only and
differs from SWA on the stem (closed) and from logit averaging (in stack). Gate: soup LODO acc1 within 0.5 pt of the logit
ensemble, otherwise drop.

---

## 3. Patch plans for the top 3

Paths: W = `/root/disk_3tb/eeg-thao`, R = `/root/disk_3tb/EEG-sAAD-Grand-Challenge-Training-Dataset/experiments/decoder_lodo`.
Python `R/../../.venv/bin/python`. GPU: `flock W/multi_agent_opt/gpu.lock`.

### 3.1 T1 LagBank-Sel

New file `W/lagbank_sel.py` (do not edit `direct_classifier.py`; import it as `DC`):

```python
import direct_classifier as DC, eval_external as E, score as S
LAGS_A = range(-16, 17)           # diag: ±500 ms @32 Hz
LAGS_B = range(-16, 17, 2)        # technique

def shifted_pair(x, S_, d):       # no extra lookahead: only cut, never extend
    if d > 0:  S2 = np.concatenate([np.zeros_like(S_[:d]), S_[:-d]]); return x, S2
    if d < 0:  k=-d; x2 = np.concatenate([np.zeros_like(x[:k]), x[:-k]]); return x2, S_
    return x, S_

def lag_logits(nets, x, S_, lags):  # (n_lag, n_hop) mean over seeds
    out = []
    for d in lags:
        xx, ss = shifted_pair(x, S_, d)
        out.append(np.mean([DC.logits(n, xx, ss)[0] for n in nets], 0))
    return np.stack(out)

def select(Ld, lags, tau_s, beta, gamma, hop_s=0.25):
    a = 1 - np.exp(-hop_s / tau_s)
    num = lfilter([a], [1, -(1-a)], Ld**2, axis=1); den = lfilter([a], [1, -(1-a)], np.ones_like(Ld), axis=1)
    ls = np.log(num/den + 1e-9); i0 = list(lags).index(0)
    z = beta*(ls - ls[i0]) - gamma*np.abs(np.array(lags))[:, None]
    w = softmax(z, axis=0); return (w * Ld).sum(0), w     # odd in Ld
```

- `--mode diag`: loop LODO folds (fold ckpts `R/models/fold_direct_clf__eaP_n5_t60_w10b3_ptSPK[_sN]_aug-sw2_wts__{DS}.pt`) on
  synthetic-switched held-out trials (replay `score.py` schedule like `direct_classifier.run_fold`) and all5 ckpts
  (`R/models/all5_direct_clf_w10b3sw2P_s{0..3}.pt`) on `E.ext_trials(ds)`. Write `W/results/research/lagbank_diag.csv`
  (ds, seed, lag, acc1, mean_signed, subj-bootstrap SE) + `lagbank_diag.png`.
- `--mode select`: cache `Ld` per trial (`W/cache/lagbank/{ds}/{key}.npy`, float16), grid (τ, β, γ) on LODO inner (for outer X:
  pick on the 4 other datasets), score with `score.score_dataset(..., pre_switched=True)`, external with `E.score(EV, mu, sd, p, 0.75)`.
  Emissions (μ, σ) from the selected LODO streams only.
- Gates: column swap (negate S order and check d* → −d*), `leakage_test.py` wrapper on the lag path (δ<0 path must stay ≤ 0.969 s).
- Outputs `W/results/research/lagbank_sel.{csv,json}`, report `W/multi_agent_opt/results_lagbank_sel.md`.

### 3.2 T2 ESR-stem

New file `W/stem_esr.py`, template `W/stem_ms96_group_dro.py` (keeps the LODO + all5 + external + fuse scaffolding).

```python
class OddStem(nn.Module):                      # from ensemble_clf_transformer_v2.LogitTransformer, pos removed
    def __init__(s, c_in, window, d=64, L=2):
        ...same dw/proj/DilatedResidual/enc/head/skip, NO self.pos ...
    def _g(s, x, kpm):                         # kpm: key padding mask (B,W) True=pad
        x = x + s.dw(replicate_left_pad(x, 8))
        h = s.proj(x); [h := blk(h) for blk in s.blocks]   # DilatedResidual with replicate pad
        h = s.enc(h, mask=s.mask, src_key_padding_mask=kpm)
        return s.head(h).squeeze(-1) + s.skip(x).squeeze(-1)
    def forward(s, x, kpm=None):
        a, b = s._g(torch.cat([x, -x]), None if kpm is None else torch.cat([kpm, kpm])).chunk(2)
        return 0.5 * (a - b)                     # exactly odd

def resynth(Dc, rng, fs=4.0):                   # Dc: (T,4) aligned (+ = attended)
    T = len(Dc); t = 0.0; sign = rng.choice([-1, 1]); q = np.empty(T); y = np.empty(T)
    while t < T/fs:
        dwell = rng.uniform(30, 90) if rng.random() < .5 else np.exp(rng.uniform(np.log(4), np.log(40)))
        ...fill y with sign for [t, t+dwell); q ramps from -sign to sign over r~U(0.5,6) s at t (no ramp at t=0)...
        t += dwell; sign = -sign
    return Dc * q[:, None], (y > 0).astype(np.float32)

def ms_features_odd(D): ...                     # as build_features, EMAs with normalised weights (hmm_learned.ema_features)
```

- Data: `N.G["base"]["id"][ds][key]` × `sgn(N.G["att"][ds][key]==0)`, train datasets only. K = 8 resynth copies built once per
  fold (4 Hz, small), mu/sd normalisation from those copies (sign-even, so it does not break oddness).
- `sample_batch`: windows inside a trial; for t < W − 1 pass `kpm` instead of zeros (no zero-pad signal).
- Loss: BCE (no `pos_weight`, classes balanced by construction) × `switch_weights` + 0.05·TV, as v2.
- Selection: HMM grid {0.95, 0.99, 0.994, 0.998} × {0.8, 1.0} by inner LODO (acc74); external at the frozen pick.
- Mandatory gates in code (fail hard): `assert_odd(model)`; `position_invariance(model, prepend=240 frames)` ≥ 0.99 agreement;
  column-swap on external evidence; then `leakage_test` surrogate (`R/audit_transformer_leakage.py` style).
- Ablations (same seed): no-resynth (original schedule, odd only), r = 0 (no ramp), dwell-short-only.
- Outputs `W/results/research/stem_esr.{csv,json}`, ckpts `W/models/stem_esr/`, report `W/multi_agent_opt/results_stem_esr.md`.

### 3.3 T3 CF-Null

Step A, new file `W/cfnull_diag.py` (inference only): for published ckpts compute `d` and `d_null` (EEG lag L = 20 s past,
zeros for t < L, masked from stats) on LODO held-out and AASD/Carta. Report ρ = std(d_null)/std(d), the per-subject mean of
EWMA(d_null)·sign(label), and acc1 of `d_null` alone. Gate: ρ ≥ 0.25 on AASD or Carta.

Step B, edit `R/direct_classifier.py` `fit()` behind a flag (default off, so the published path is unchanged):

```python
lam = D.get("augment", {}).get("clf_null_lambda", 0.0)
...
X, S, y = windows(...)
loss = bce(net(X, S), y)
if lam > 0:
    Xn = null_eeg(train, X, rs)       # 50 % other trial's EEG window, 50 % same trial shifted >= 20 s (use windows.last_ti)
    loss = loss + lam * net(Xn.to(DEV), S).pow(2).mean()
```

Run: `--init-from` published sw2 ckpt per seed/fold, `--aug-set clf_null_lambda=λ`, 4 × 250 steps, tag `_aug-sw2_cfnull`.
Smoke λ ∈ {0.1, 0.3} on seed 0, AVGC fold; select λ by the validation-subject BCE of the training datasets only (never AASD/Carta).
External via `eval_external_clf.py ... --tag _w10b3sw2cfnullP`.

Step C, `W/cfnull_debias.py`: causal debias + rescale of the 4-seed mean (τ = 60 s, L = 20 s), scored with and without Step B.
Gates: column swap, `leakage_test.py` (the null path uses only past EEG).

## 4. Acceptance rule (all candidates)

Keep a candidate only if, paired by seed: real H (AASD and Carta) +≥ 0.005 each **and** honest LODO −≤ 0.01, with gates (a)–(c)
passed. Decision to keep or drop belongs to the user. Record failures in `multi_agent_opt/ALREADY_TRIED.md`; do not re-run them.
