# Protocol 022, revision 2 (planned): a plaids pilot. Does the cat circuit combine two gratings differently from a relay, and do its connections change that?
Status: DECLARED, revision 2, 2026-10-26T23:15:38Z, before any plaid run. Its SHA-256 is recorded in HANDOFF. Any later change needs a new declared revision.          Date: 2026-10-26

## History
- **Revision 0** ("does the cortex hold a step's input?") was withdrawn after review and never declared (`work/controller-022/review-r0.md`).
- On 26 October the owner chose option B, a plaids pilot.
- **Revision 1's draft** (`docs/specs/2026-10-26-protocol-022-plaids.md`) was superseded after a four-lens review: 48 findings, 4 high (`work/controller-022/plaids/review-r1-draft-findings.json`). Its intact-minus-lesion additivity only restated that the lesioned layer 4 is untuned and saturated.
- **This revision comes from a judge panel** (`wf_63792160-2d2`, output `work/controller-022/plaids/design-panel-r2.json`). Three independent designs were each scored by two judges.
  - It takes the "spike" design whole: measures, intervals, rule and texts. Its statistics were calibrated on resampled whole-step noise from protocol 017's exports.
  - It adds the judges' fixes, and from the "mechanism" design a separate job that exports the connection lists.
- **What it uses:**
  - **No lag share ρ from protocol 021.** One understand reader opened `work/controller-021/probe-phase-105/probe-timing-check.json`, which holds ρ and lead-share fields, and saw its values in tool output. It did not use or repeat them, and nothing in this design depends on them. Later readers and reviewers are told not to open that file.
  - It was written while unattended run 001 of the live loop occupied the server, and before any plaid run.
- **The code review** (`wf_370b899e-e82`, findings in `work/controller-022/plaids/build-review-r2.json`) kept 41 findings, 3 of them high, on the spec and on the code built for it. The amendments are listed in `work/controller-022/plaids/disposition-r2.md`, with the disposition of the judges' recommendations and of revision 1's high and medium findings.

## Goal and what the pilot can and cannot show
**The question as this pilot can answer it.** In one instance of the 2 mm reduction of LSV1M (`pynn_seed` 5), at protocol 017's timing, does the intact circuit combine two superimposed drifting gratings differently from a relay? Here a relay means the sum of the circuit's own above-blank responses to each grating alone. Three measures on the intact network answer it. Each is exactly 0 for a relay, whatever the network's tuning, gain or contrast saturation:
- **XOS**, cross-orientation suppression: how far layer 4 cells' response to their preferred grating plus an orthogonal one falls below the sum of their responses to each alone, in units of their response to the preferred grating. It is measured only where the orthogonal grating alone barely moves them from the blank level, in either direction;
- **Dc**, dominance: at unequal contrasts, whether the cells preferring the stronger grating keep a larger share of their single-grating response than those preferring the weaker one. A gain shared by both groups cancels, including uniform suppression.
- **ds**, readout shift: whether the controller's frozen readout of a plaid of gratings 45° apart points further toward the stronger grating than the sum of its readouts of the two gratings. It is in the controller's signal unit, where 45° is 1 and the decision threshold is 0.25.

**A GO does not need a plaid-specific cortical mechanism.**
- The LGN stage saturates each cell's drive, and the LGN to layer 4 synapses depress strongly (U 0.75, recovery 125 ms). Both act before the cortex, identically in the intact and lesioned networks.
- How much of an intact XOS or Dc the input stage produces is unknown. One approximate synthetic feedforward pipeline (the "afferent" designer's, rerun by a judge) gave a group XOS of +0.20 to +0.26. That was at 12.5/12.5 and 25/25 %, in a relay matched only to the intact blank rate, whose orthogonal grating alone drove the test groups at 0.24 to 0.40 of the test response. Under that cross drive this pilot's XOS would not even be estimable.
- So a GO describes the whole model circuit (input stage and cortex) at these contrasts and this timing. It does not show that the intracortical connections compute it. Suppression or dominance of the afferent drive appears in group spikes only where cells are tuned, and in this model tuning needs the connections: median OSI 0.60 intact against 0.06 lesion. The follow-up's afferent-conductance reading is what estimates the input stage's share.

**What the pilot can say about the connections:**
- **The readout reading.** It compares the intact and plain-lesion readouts of the same plaids on identical LGN input. Both readouts carry orientation, and ds is gain-invariant. It is a total effect, which includes the lesion's lost tuning and its 7 to 8 times higher layer 4 rate.
- **The connection lists.** A separate job exports them, so that a declared follow-up can rebuild each layer 4 cell's afferent, recurrent and inhibitory conductances offline. That follow-up never changes this pilot's outcome.

Neither outcome is a claim about cat V1. Simulation only.

## Design
- **Engine and timing:** as in protocol 017.
  - 0.8 cpd and 2 Hz. Each step is 30 frames (210 ms) of stimulus, then 21 frames (147 ms) of mean-luminance blank; 7 ms frames.
  - A 504 ms mean-luminance lead-in, with `FELISYN_WARMUP_MS=0`.
  - One presentation, no chunking, no LGN cache.
- **Stimulus version 3** (`work/controller-022/plaids/server/controller_experiments.py`, tested). A step is [θ, c], whose frames are identical to version 2, or [θ1, c1, θ2, c2], a plaid G(θ1, c1) + G(θ2, c2) − L.
  - Both components start at phase 0 at each onset.
  - Steps with c1 + c2 above 100 % are refused when the experiment is built.
- **Conditions:** intact, and the plain lesion (017's five overrides, all twelve intracortical projections at zero weight, the input unchanged). Both use network instance A and the identical sequence file.
- **Contrast ladder: 15, 30 and 60 %.**
  - 15 % is near the intact preferred group's estimated c50 of 15 to 20 %, from 017's instance A anchors.
  - Plaid components are at most 30 %, so every summed contrast is at most 60 %. 60 % appears only as a single grating, the parallel control for the 30 + 30 plaid.
- **Stimulus set** (`make_plaid_sequence_r2.py`, written to `sequence-r2.json`):
  - **Warm-up**, not analysed: [45°, 30 %] once, as the first step.
  - **Block A**, the orthogonal pair 45° and 135° (the controller's s = −1 and s = +1):
    - blank × 8;
    - singles 45@15, 135@15, 45@30 and 135@30, × 8 each;
    - singles 45@60 and 135@60, × 4 each;
    - plaids [45,15,135,15], [45,30,135,30], [45,30,135,15] and [45,15,135,30], × 8 each.
  - **Block B**, a pair 45° apart, 90° and 135° (s = 0 and s = +1), whose single-grating readouts are matched:
    - singles 90@15 and 90@30, × 4 each;
    - plaids [135,30,90,15] and [135,15,90,30], × 4 each.
    - The 135° singles are shared with block A.
  - **Totals:** 15 analysed conditions, 96 analysed steps plus the warm-up: 97 steps, 35.1 s of model time, 5,019 frames.
- **Order:** the declared order is the file `sequence-r2.json` itself (SHA-256 `41ecee87b2b4de64ae31e65a4bf8c0cde8f512b1b057b6d32fa6bd805312878c`, seed 231), built by this rule:
  - The warm-up comes first, then four quarters of 24 analysed steps.
  - Each condition's repeats are spread over the quarters as evenly as possible (8 repeats give 2 per quarter, 4 give 1), then shuffled within each quarter with `random.Random(seed)`.
  - Seeds 231, 232 and so on are tried, and the first with no condition three times in a row, across quarter boundaries too, is kept.
  - The seed used, the transition table and each condition's mean previous contrast are reported.
  - The order leaves some stimulus-history imbalance that no shuffle of this set removes. With 4 repeats, mean previous contrast ranges from 22.5 to 48.75 %; the two block B plaids differ most (22.5 % against 48.75 %). S12's covariate fit reports its effect, and ds pools the two block B plaids.
- **Windows:**
  - the group window G = [20, 230) ms after onset, from the earliest layer 4 response to just before the offset burst at 235 to 245 ms;
  - the readout window D = [40, 300) ms, 017's frozen decoder window.
- **Cell groups:** layer 4 excitatory cells whose `orientation_pref` lies within ±15° of 45°, 90° or 135° (instance A: 915, 721 and 1,071 cells). The neuron tables must be identical in both exports. Layer 4 inhibitory groups are formed the same way, descriptive only.
- **Definitions:**
  - Y_g(k) is the mean count per cell of group g in G at step k. R_g(j) is its mean over condition j, B_g = R_g(blank), and D_g(j) = R_g(j) − B_g.
  - The readout z(k) = Σ_n c_n(k) w_n sums over all layer 4 excitatory cells: counts in D, with 017's balanced weights (`pipeline.decoder_weights`).
  - ζ(j) is the mean z over condition j minus the mean over the blanks. Projections always use the complex conjugate.

### Primary measures (intact network; they decide the outcome)
- **P1 XOS** is the mean over (g, c) in {45°, 135°} × {15, 30 %} of XOS(g, c) = [D_g(own single at c) + D_g(other single at c) − D_g(equal orthogonal plaid at c)] / D_g(own single at c). That is the drop below the relay's prediction, in units of the test response.
  - It is exactly 0 for a relay, at any cross drive. Where the orthogonal grating alone leaves the group at the blank level, it equals the classic test-referenced form 1 − D_g(plaid) / D_g(own single).
  - **Reported beside it (S1):** the classic form (which a relay sets to minus the cross drive), the relay-denominator form 1 − D_g(plaid) / [D_g(own) + D_g(other)] (also 0 for a relay, but noisier), and the cross drive.
  - **Why this form:** the code review's verifier compared the forms on identical simulated pilots. The relay-denominator form lost power (P(GO) by XOS at 1.5 times the margin fell from 0.94 to 0.85 at exponent 2, and from 0.86 to 0.57 at exponent 3), because its denominator adds the noisy D_g(other). This form keeps the relay at exactly 0 with the test response as its denominator.
  - It is valid only if:
    - every D_g(own single at c), its denominator, is at least 0.30 counts per cell, with its bootstrap 0.5 % quantile above 0;
    - the cross drive, the mean over the four cells of D_g(other single) / D_g(own single), lies inside ±0.10 (two-sided).
  - 017's instance A gives cross drives of −0.04 to +0.01 intact and 0.66 to 0.82 lesion.
- **P2 Dc** is the mean over the two unequal block A plaids of Dc(p) = (As⁺ − Aw⁺) / (As⁺ + Aw⁺).
  - A_g(p) = D_g(p) / [D_g(45° single at its contrast in p) + D_g(135° single at its contrast in p)], and A⁺ = max(A, 0).
  - s is the group preferring the higher-contrast component, and w the other group.
  - It is valid only if each of the four additive denominators is at least 0.30 counts, with its bootstrap 0.5 % quantile above 0, and As⁺ + Aw⁺ is at least 0.20.
- **P3 ds** is the mean over the two block B plaids of ds(p) = σ(p) · arg(ζ(p) · conj(ζ_lin(p))) / 2 / (π/4).
  - ζ_lin(p) = ζ(135° single at its contrast in p) + ζ(90° single at its contrast in p).
  - σ(p) is the sign of arg(ζ(higher-contrast single) · conj(ζ_lin(p))), so a positive value points toward the higher-contrast grating.
  - It is valid only if |ζ_lin(p)| and |ζ(p)| are at least 1,500 (about 3 per-step SDs), with bootstrap 0.5 % quantiles of at least 750.
- **Undefined cases:** a primary that fails its validity condition is "not estimable" and makes the pilot NOT INTERPRETABLE; the failing quantity is reported. Negative numerators are kept: XOS may exceed 1 and A may be negative. Only Dc uses A⁺.

### Secondary measures (declared, each with a 95 % interval; no decision role)
- **S1:** every component of P1 to P3, per group, contrast and order, and the differences between orders or groups.
- **S2:** the additivity A for every plaid and group, in both runs.
- **S3:** the parallel control, in both runs, for (g, c) in {45°, 135°} × {15, 30 %}.
  - The exchange rate π(g, c) = [R_g(c+c plaid) − R_g(own c)] / [R_g(own 2c) − R_g(own c)], and S_par = 1 − D_g(c+c plaid) / D_g(own 2c).
  - Reported as "saturated, uninformative" where R_g(own 2c) − R_g(own c) is below 0.15 counts, or its interval includes 0.
- **S4:** the lesion network.
  - P1 to P3 are computed identically. XOS is reported as "not a suppression index here" when its cross-drive condition fails, with the cross-drive value.
  - Also the test-referenced XOS, π, and the paired readout difference dds = ds_intact − ds_lesion from the same bootstrap draws.
- **S5, decisions:**
  - for every plaid step, the side under 017's rule (buy, sell or hold) of the decoded angle, against the side of the linear prediction from condition means;
  - the share of steps whose side differs, and the strength |z| / Σc;
  - for the equal orthogonal plaids, |z| / Σc and the shares of buy, sell and hold.
- **S6, LGN spike additivity:**
  - for each block A plaid, X_ON and X_OFF separately, cells pooled, in window G;
  - compared with the linear-rectifier reference E|1 + r e^{iψ}| / (1 + r), which is 0.637 at r = 1 and 0.709 at r = 0.5.
  - Labelled "upstream of thalamocortical depression; not the drive layer 4 receives".
- **S7:** layer 4 inhibitory groups, XOS and A, in both runs.
- **S8:** contrast-response curves per group and run (0, 15, 30 and 60 %), with a descriptive Naka-Rushton fit.
- **S9:** rates per sheet in the lead-in, the blanks and each condition.
- **S10, phase geometry:** groups 45° and 135° split into quartiles of the cosine of each plaid's relative phase at the cell's receptive-field centre (`x_um`, `y_um` at 1,000 µm per degree), with A per quartile.
- **S11:** the measures in the other window (group measures in D, readout in G), and in the onset [20, 70), sustained [70, 230) and offset [230, 300) windows.
- **S12, sensitivity:** P1 to P3 refitted with the previous step's summed contrast as a multiplicative covariate, and with a linear time trend.

### Intervals
- **Unit of resampling: the whole step,** never the cell. A step means all cells, all groups, both windows and the readout together.
  - The cells are this whole network, not a sample, and their fluctuations are shared: in 017's probe a group mean varies 4 to 5 times more between repeats than independent cells predict.
  - The same step draw is used for the intact and lesion runs, which share every LGN spike and the stimulus history.
- **Pooled noise:**
  - For each run and summary (Y_g in each window; the readout's components along and across its condition's mean direction), residuals from all 96 analysed steps are pooled.
  - They are leverage-corrected: e_k = (Y(k) − R(j(k))) · √(n_j / (n_j − 1)).
  - A variance function s²(µ) = a² + b²µ² is fitted to e² by non-negative least squares, and standardised residuals u_k = e_k / s(R(j(k))) form one pool per summary.
- **Each bootstrap replicate:**
  - draws 96 step indices with replacement, with the same draw for every summary and both runs;
  - sets Y*(k) = R(j(k)) + s(R(j(k))) · u(k*);
  - recomputes every condition mean and measure.
- **Settings:**
  - 10,000 replicates, seed 2202;
  - percentile intervals: 95 % for reporting and the connection readings, 90 % for the relay-like test;
  - two-sided bootstrap p-values for Holm, p = 2 · min(P*(θ* ≤ 0), P*(θ* ≥ 0)).
  - A misfit check (each condition's raw residual variance against the fitted function) is reported, never acted on.
- **Calibration, from the panel's spike designer:**
  - Synthetic pilots of exactly this design were built from whole-step residual vectors of instance A exports, and analysed by this procedure.
  - Coverage of the 95 % intervals was 0.945 (XOS), 0.949 (Dc) and 0.948 (ds); the lesion measures and dds gave 0.935 to 0.97.
  - Under noise the analysis does not model it was 0.92 to 0.96: plaid noise 1.4 times and blank noise 0.4 times the fitted function, t3 tails, a ±5 % drift, and a previous-contrast effect.
  - These intervals cover the step-to-step noise of this one instance only.

### Decision rule
- **Primary family:** P1, P2 and P3. Holm at family-wise 0.05.
- **Minimal effect of interest:** δ = 0.10 for each.
  - XOS: a tenth of the preferred response.
  - Dc: a 22 % larger additivity for the stronger component's cells.
  - ds: 4.5°, which is 0.4 of the controller's 0.25 decision threshold.
- **Outcomes,** checked in this order, each with a fixed text:
  1. **NOT INTERPRETABLE** if any of these holds:
     - a refusal on the contract, the sequence or the intact export (an unreadable or partial intact export included);
     - the intact run failed twice (one rerun of each run under the identical contract is allowed, named `-a2`; an attempt killed for memory is not rerun);
     - a primary is not estimable;
     - the intact run fails the 30 % validation check (below).

     Text: "The pilot cannot be read as declared: ⟨condition⟩. No reading about plaids is made. The data and the failure are kept; a rerun needs a new declared revision."
  2. **GO** if at least one primary is Holm-significant and its estimate is at least 0.10 in absolute value.

     Text: "In this one network instance the intact circuit combined two superimposed gratings differently from a relay of its single-grating responses, by at least the declared margin: ⟨one sentence per triggering measure, with estimate and 95 % interval⟩. This is a property of the whole model circuit (input stage and cortex) at these contrasts and this timing, and the input stage alone was expected to produce part of it. It does not show that the intracortical connections compute it: the shared input stage is non-linear, and suppression or dominance of the afferent drive shows in spikes only in tuned cells, which need the connections. A confirmatory protocol on fresh network instances follows, declared before its runs."

     Sentences for each measure:
     - XOS > 0: "an orthogonal grating lowered layer 4 cells' response to their preferred grating (cross-orientation suppression), XOS = x";
     - XOS < 0: "an orthogonal grating raised it (facilitation), XOS = x";
     - Dc > 0: "at unequal contrasts the cells preferring the stronger grating kept more of their single-grating response than those preferring the weaker one (winner-take-more, as normalisation predicts), Dc = x";
     - Dc < 0: "the cells preferring the weaker grating kept more (loser-take-more), Dc = x";
     - ds > 0: "the controller's frozen readout of a plaid of gratings 45 degrees apart pointed x signal units further toward the stronger grating than the sum of its readouts of the two gratings";
     - ds < 0: "the readout pointed x signal units toward the weaker grating".
  3. **RELAY-LIKE** if all three primaries are estimable and each 90 % interval lies inside (−0.10, +0.10). This is an intersection-union test, so no adjustment is needed.

     Text: "In this one network instance layer 4 and the controller's readout combined two superimposed gratings like a relay of their single-grating responses: XOS x, Dc y, ds z (90 % intervals), all inside ±0.10. This does not show that no smaller departure exists, nor that other instances, contrasts, timings or steady-state measures behave the same. No confirmatory plaid protocol follows for the controller."
  4. **INCONCLUSIVE** otherwise.

     Text: "The pilot neither shows a combination that differs from a relay by at least the margins nor rules one out (intervals in the report). The plaid line pauses; a continuation would be a new declared revision sized with the noise measured here, not with these estimates."
- **The primary stands, and only the connection readings are missing,** if the lesion run failed twice, a refusal fires on the lesion export, the lesion fails its 30 % check, the LGN spike trains differ between the runs, or the neuron tables differ.
- **Connection readings** are made only under GO, RELAY-LIKE or INCONCLUSIVE, and only when neither of the conditions just listed holds. Otherwise they are "missing", with the reason. They choose the confirmatory design, never the outcome.
  - **The readout readings need an intact effect first:** ds_int's 95 % interval must exclude 0 and |ds_int| must be at least 0.10. Otherwise the reading is NOT APPLICABLE, with the text: "The intact readout did not depart from a relay by the declared margin, so no connection reading is made at the readout."
  - **CONNECTION-DEPENDENT AT THE READOUT** if the 95 % interval of dds = ds_int − ds_les excludes 0 with ds_int's sign, and ds_les's 90 % interval lies inside ±0.10.

    Text: "In this one network instance, without the intracortical connections the readout combined the same plaids like a relay and differed from the intact readout: removing all twelve projections changes how the controller's readout weighs two signals. This is a total effect that includes the lesion's lost tuning and 7 to 8 times higher rate."
  - **SAME DIRECTION WITHOUT THE CONNECTIONS** if ds_les's 95 % interval excludes 0 with ds_int's sign and |ds_les| is at least 0.10.

    Text: "In this one network instance, without the intracortical connections (at a 7 to 8 times higher layer 4 rate and without its tuning), the readout departed from a relay in the same direction, ds_les = x. The lesion's own saturation can produce this, so it does not show that the intact readout's departure comes from the feedforward path."
  - **UNRESOLVED** otherwise.
  - **The group measures** carry a fixed text when the lesion's cross drive is at least 0.10: "Without the connections layer 4 cells respond to both gratings (the orthogonal grating alone drives them at x of the preferred response), so the plain lesion cannot show suppression or dominance in group spikes; this pilot does not answer whether the connections compute the intact network's XOS or Dc." Below 0.10, the lesion's group measures are reported in S4 without a reading.
- **Simulated operating characteristics** on noise from 017's exports, re-checked by the analysis code's own calibration (`test_plaid_stats.py`; the values are filled in from that re-check, `OPERATING-CHARACTERISTICS` below).
  - **The asserted gates decide, not the quoted figures:** false GO under a relay at most 0.05 in every declared scenario, and coverage of the 95 % intervals at least 0.93 for every measure that enters a reading (P1 to P3, the lesion's ds and dds). The lesion's descriptive XOS and Dc (S4, never read in an untuned lesion) must still cover at least 0.90. If a re-check misses a quoted figure, the text is corrected before freezing.
  - **OPERATING-CHARACTERISTICS: the full calibration of the final code** (26 Oct; `work/controller-022/plaids/calibration-full-r2.log`, `53318a26…`; 6 scenario tests, all passing; 2,000 to 4,000 synthetic pilots per scenario, built from whole-step residuals of 017's exports):
    - **False GO under a relay:**
      - 1.45, 2.4 and 3.55 % with probe noise at exponents 1.5, 2 and 3; 1.1, 1.3 and 2.8 % with milestone 2 noise;
      - 1.8 to 2.4 % with cross drives of +0.05, −0.05 and −0.08/−0.02;
      - 1.85 to 2.8 % under the four kinds of noise the analysis does not model.
      - All are at most 5 %.
    - **Coverage of the primaries' 95 % intervals:** 0.934 to 0.966 in every scenario.
    - **P(GO) with one measure at 1.5 times the margin** (probe noise), at exponents 1.5, 2 and 3:
      - XOS 0.89, 0.87 and 0.68;
      - Dc 0.92, 0.88 and 0.66;
      - ds 0.91, 0.92 and 0.87.
      - At exactly the margin (exponent 2) it is 0.43 to 0.50, as built.
      - Under divisive normalisation it is 1.00.
    - **Under a relay:** RELAY-LIKE 0.08 to 0.55 (lowest with a steep curve), INCONCLUSIVE 0.44 to 0.89, NOT INTERPRETABLE at most 0.023.
    - **Connection readings:**
      - with an intact relay they are NOT APPLICABLE in 98.7 to 99.5 % of pilots; CONNECTION-DEPENDENT fires in at most 0.55 % and SAME DIRECTION in at most 0.35 %;
      - with an intact ds of 0.15 and a relay lesion: CONNECTION-DEPENDENT 80 %, UNRESOLVED 12 %, NOT APPLICABLE 8 %;
      - with an intact ds of 0.15 and a saturating untuned lesion (its own ds +0.11): SAME DIRECTION 33 %, CONNECTION-DEPENDENT 2 %, UNRESOLVED 58 %.
    - **The panel's earlier figures,** before the code review's changes: false GO 0.6 to 2.9 %, and P(GO) at 1.5 times the margin 0.88 to 0.97 at exponent 2.
- **What a GO hands on, declared now:** the triggering measure exactly as defined here, its conditions, and δ = 0.10. The confirmatory sample size comes from the pilot's noise parameters only, never from its estimates.

### The 30 % validation check (in the pilot, declared now)
- **Intact:** the 30 % singles at 45° and 135° (8 repeats each) must reproduce 017's instance A values in G within a ratio of 0.80 to 1.25. The reference is the 017 probe's own-group means: 2.97 counts per cell at 45° and 2.18 at 135°.
- **Lesion:** the same, against smoke run 2's 9.80 and 10.24. Those are single steps, but the lesion's per-step CV of about 3 % keeps a single-step reference well inside the band.
- **LGN:** the X_ON and X_OFF mean counts per cell in G at 30 % (45° and 135° singles) must be within 0.90 to 1.10 of 017's probe values, 8.06 and 5.73 counts (38.4 and 27.3 Hz).
- **The references come from runs with a different stimulus history** (017's probe order). The bands are wide enough for that, and S12 reports the history effect.
- **Consequence:** an intact failure makes the pilot NOT INTERPRETABLE. A lesion failure removes only the connection readings.
- **The 90° check is dropped:** 4 pilot repeats against a 3-step reference cannot hold a 0.80 to 1.25 band at a per-step CV of about 13 %.

### Connection export job (a data product for the follow-up; never part of the outcome)
- **What it runs,** in `/opt/felisyn/controller-022/model-2mm`: `FELISYN_MODE=export-connections FELISYN_CONN_DIR=… python ../v4/run_controller.py nest 4 param_spont/defaults ⟨reduction⟩ m22p-connections-a1`.
  - The folder `v4/` holds byte-identical copies of `run_controller.py` and `lgn_cache.py`, with `controller_experiments.py` version 4 and `export_connections.py`. `run_controller.py` imports the stimulus code from its own folder, so this is how the job gets version 4 while the pilot runs get version 3.
  - It uses the same files, seeds and environment as the intact run, with no lesion overrides. 017's logs give identical connection counts for intact and lesion, so the lesion only changes weights.
  - A hook in a version 4 of `controller_experiments.py`, `create_experiments`, sees the mode, exports, then raises `SystemExit(0)` before any experiment.
  - The tier 2 check confirms on the pinned Mozaik that `run_workflow` builds the model before it calls `create_experiments`. If that fails, the job is not run.
- **What it writes,** for the 10 projections onto layer 4 excitatory and inhibitory cells (4.31 M connections, the counts in 017's log):
  - `name.npz` with pre and post population indices (int32), weight in µS (float64) and delay in ms (float32);
  - one projection at a time, read straight from NEST in chunks of at most 100,000 connections with `nest.GetStatus(conns[a:b], ['source', 'target', 'weight', 'delay'])`. PyNN's own conversions from its pinned `nest/projections.py` are then applied: weight × 0.001, sign removed for inhibitory receptors, and ids mapped to population indices. NEST builds a full status dictionary per connection, so reading a whole projection at once (as `proj.get` does) would need about 3.3 GiB for layer 4 to layer 4 alone.
  - The chunked reader is cross-checked against `proj.get` on the small `V1AffInhConnectionOn` (83,737 connections), and the result is recorded. Each projection's index entry is written as soon as it is done, with the process's peak memory, so a killed job keeps what it finished;
  - `index.json` with each projection's synapse parameters (a NEST GetStatus sample, and minimum and maximum of U, tau_rec, tau_psc and tau_fac), neuron parameters, population id ranges, every layer 4 annotation, kernel status, versions and SHA-256 per file.
- **Where it runs:**
  - **last in the queue**, in its own transient unit, with a 2 h timeout (RuntimeMaxSec 150 min) and `OOMPolicy=continue`;
  - about 0.3 to 0.6 h at normal speed, and up to about 1.5 h at the slowdown of 26 October.
  - **Memory** is about 0.6 GiB above the built network for the chunked reader. That is an estimate, not a measurement; the job records its peak per projection.
- **V0, structural checks on fetch** (`server/check_connections_v0.py`, frozen with the rest), reported only:
  - the counts equal the export job's own log and 017's log at the precision 017 printed (six significant digits for layer 4 to layer 4), and match each projection's mean inputs per target times the target count within rounding;
  - the post indices cover every cell;
  - the delays sit on the 0.1 ms grid within a float32 tolerance of 1e-4 ms, inside the ranges the parameter files give;
  - every synapse is `tsodyks_synapse` with U 0.75, tau_rec 125/30/70/20 ms and tau_fac 0, uniform within each projection;
  - every weight is finite and above 0. PyNN exports magnitudes, so this also catches a sign left on an inhibitory projection;
  - the report records the checker's own SHA-256;
  - `LGNAfferentOrientation` equals the exports' `orientation_pref` for every cell.

### Follow-up, declared now and run after the pilot: the conductance rebuild
Offline, from the recorded spikes and the exported lists, using NEST 3.4's `tsodyks_synapse` update (U, tau_rec and tau_psc as exported, tau_fac 0) and `aeif_cond_exp`, with the first 300 ms of each presentation excluded:
- **Blinded debugging.** The replay code is developed and validated only on 017's runs, in at most three recorded attempts, before it reads any pilot export. Every attempt and its validation numbers are kept.
- **V1, replay of 017's feedforward-only milestone 2 run** (same instance and timing), in which layer 4 receives only afferent input. It passes only if all of these hold:
  - per (cell, step) counts in [20, 230) and [40, 300) are identical in at least 98 % of pairs;
  - group-mean counts are within 1 % in every step;
  - at least 90 % of recorded spikes have a replayed spike within ±0.2 ms;
  - the total spike ratio is 0.99 to 1.01.
- **V2, the same on 017's intact-A run,** from all five lists onto layer 4 excitatory cells.
- **V3, the same criteria on the pilot's own lesion run,** before any reading on pilot data.
- **The readings,** in window G for the ±15° groups and the block A plaids. Ḡ_Y(X) is a group's mean conductance of type Y (afferent, intracortical excitatory E, inhibitory I) over the steps of condition X; P is a plaid, T the test grating's single, M the mask's single and B the blank.
  - **If V1 and V3 pass:** the afferent-conductance additivity A_aff = [Ḡ_aff(P) − Ḡ_aff(B)] / [(Ḡ_aff(T) − Ḡ_aff(B)) + (Ḡ_aff(M) − Ḡ_aff(B))] in both networks: the suppression in the drive layer 4 receives. Also the intact XOS minus the same measure on the afferent conductance.
  - **If V2 passes:**
    - MM1, m_I = the mean over the 12 group-and-plaid combinations of [Ḡ_I(P) − Ḡ_I(T)] / [Ḡ_I(T) − Ḡ_I(B)]: does the second grating raise the inhibition onto cells tuned to the first?
    - MM2, m_E: the same for the intracortical excitatory conductance. Does it lower it?
  - **Rules:** a denominator must be at least 3 standard errors, and a reading needs at least 9 of its 12 combinations. Intervals come from whole-step paired bootstrap draws, as above. MM1 and MM2 use Holm over two at 0.05, with δm = 0.10.
- These are exploratory, published as a versioned follow-up, and never change this pilot's outcome. A failed validation is reported as such, and those readings are not made.

## Server queue, guards and cost
- **Layout:** folder `/opt/felisyn/controller-022`. Version 3 sits beside the unchanged `run_controller.py` and `lgn_cache.py` of version 2, with version 4 used only by the export job. Every server file is hash-checked at launch with `sha256sum -c --strict`.
- **The queue, intact first:**
  - `felisyn-controller-022-pilot` runs intact (`m22p-intact-a1`), then lesion (`m22p-lesion-a1`), each under `timeout 12h`.
  - **Reruns:** one rerun per run is allowed (`-a2`), but not after a kill for memory (it would fail the same way), and no attempt starts after 24 h of queue time.
  - **Then the export job,** in its own unit `felisyn-controller-022-export`, with a 2 h timeout.
  - **Unit settings:** MemoryMax 6815744000 bytes, `OOMPolicy=continue`, RuntimeMaxSec 40 h (the 24 h start limit plus one 12 h attempt plus the export).
  - **Freeze link:** `start` and `resume` take the frozen manifest, whose SHA-256 is recorded in HANDOFF. They refuse unless every server file matches it, and write the manifest's SHA-256 into the runs folder.
  - The 19 model files come from protocol 017's frozen server list. The launcher first checks 017's `manifest.json` against its frozen SHA-256 (`383e67ef…`, HANDOFF).
- **Environment:** `FELISYN_STEP_FRAMES=30`, `FELISYN_GAP_FRAMES=21`, `FELISYN_WARMUP_MS=0`, `FELISYN_LEAD_MS=504`, `PYTHONDONTWRITEBYTECODE=1` and `MPLBACKEND=Agg`. `FELISYN_CHUNK_STEPS`, `FELISYN_LGN_CACHE` and `PYTHONOPTIMIZE` are unset.
- **Guards, at launch and before each run:**
  - refuse unless every `felisyn-*` unit other than the queue's own has the state string inactive or failed. The queue's own unit is excluded by name and by `$INVOCATION_ID`, so the check cannot match itself.
  - refuse below 6.6 GiB MemAvailable.
  - Resume mode keeps the runs folder and rechecks the hashes.
- **Receipts per run:**
  - the FELISYN_* environment;
  - `sha256sum` of the server files at start and end;
  - the `time -v` log;
  - MemoryPeak and `memory.events`.
- **Cost and memory**, from the cost model in `understand-reports.json`, for 97 steps and 5,019 frames, at 1.2 times 017's spike rate (one basis for both):
  - intact about 3.3 to 3.5 h, peaking at about 5.35 to 5.68 GiB;
  - lesion about 4.2 to 4.4 h, peaking at 5.84 to 6.19 GiB, close to the 6.35 GiB cap;
  - export 0.3 to 0.6 h.
  - In total about 7.8 to 8.5 h at normal speed.
- **The host's CPU steal changes only the time,** since the simulation is deterministic. On 26 October it slowed model stages by up to 2.45 times (the 4-thread NEST stage; `work/live/unattended-run-001.md`). At that slowdown the lesion run would take about 11 h, inside its 12 h timeout. Each run's receipt records `vmstat` steal at its start.
- The queue starts only after unattended run 001 and its stop drill.

## Non-goals and limits
- **No biological claim.** The pilot characterises the 2 mm reduction. Its counts over 210 ms after onset are dominated by the onset response, and cannot be compared with sustained (F1) cat measurements. Its LGN stage saturates less than cat LGN (half-saturation near 100 to 124 %) and has no pooled suppressive field, so its split between input and cortex is about the model only.
- **Nothing below 30 % contrast has been measured in this model.** The 15 to 20 % c50 is extrapolated from 017's 30 and 100 % anchors with an assumed Naka-Rushton exponent of 1.5 to 3. A steeper curve (exponent 4 to 5) would put the 15 % singles near or below the 0.30-count floor, and the pilot would be NOT INTERPRETABLE.
- **A true relay most often ends INCONCLUSIVE**, not RELAY-LIKE: RELAY-LIKE has a probability of 0.08 to 0.55, lowest with a steep contrast curve.
- **Only layer 4 is compared:** layer 2/3 is silent in the lesion.
- No confirmatory claim. One instance and one sequence; the intervals cover step-to-step noise only.
- A GO is expected from the input stage. The connections are addressed only by the readout reading (a total effect) and by the follow-up.
- **"The connections" means all twelve projections together.** Inhibition and recurrent excitation are separated only in the follow-up, and only if V2 passes.
- The contrasts (15 to 60 %, components at most 30 %) are characterisation values. A two-signal controller would need its own declared encoder with c1 + c2 ≤ 100 % and contrast independent of orientation.
- **The stimulus shapes what can be read:**
  - both components start at phase 0, so each plaid has one fixed spatial pattern (S10 reports phase geometry);
  - plaids move at the intersection-of-constraints velocity;
  - the readout is π-periodic.
- **The model's input stage differs from cat's,** where most monocular suppression is attributed to LGN saturation and rectification. In this model the LGN to layer 4 depression is a strong candidate. The literature summary says so.
- No decision, executor or token.

## Code and tests (new, versioned files only; nothing frozen is edited)
- **`make_plaid_sequence_r2.py`:**
  - the quarter-blocked order and seed search;
  - every refusal: plaids need both contrasts above 0 and at most 50 %, different orientations and a sum of at most 100 %; no unknown keys;
  - tests for the counts, the seed, the order rule and a stable SHA-256.
- **`controller/plaid_stats.py`**, pure and vectorised, ported from the spike designer's prototype:
  - condition means, residuals, NNLS variance functions and the readout frame;
  - the paired whole-step bootstrap, P1 to P3 and S1 to S4, validity checks, Holm, outcomes, connection readings and the fixed texts.
  - Its tests cover synthetic exports with known truths, every validity branch and every outcome branch. A calibration test re-checks coverage (at least 0.93) and false GO (at most 0.05) on 017-derived noise.
- **Details the spec does not state** are fixed by the frozen code and listed in `work/controller-022/plaids/analysis-choices-r2.md`, frozen with it.
- **`controller/analyze_plaids.py`**, the driver:
  - it reuses 017's frozen `load_run`, `chunk_bounds`, `decoder_setup`, `counts_searchsorted` (with `counts_by_step` as the independent recount), LGN digests, `pipeline.decoder_weights`, `population_vector_weighted` and `request`;
  - a new `check_run_plaids` checks that:
    - the steps equal the declared file;
    - step 30, gap 21, frame 7 and lead 72 frames;
    - 0.8 cpd and 2 Hz;
    - there is one presentation, with exactly one sequence segment per sheet, and the cache is disabled;
    - argv and run name match `^m22p-(intact|lesion)-a[12]$`;
    - the resolved weights and seeds equal 017's contract entries;
    - the neuron tables and spike trains are well formed.
  - A neuron-table mismatch between the runs is not a refusal; it removes the connection readings.
  - An export that cannot be opened or read is a refusal, with a declared result rather than a crash.
  - It also runs the 30 % validation check and writes `results.json`.
- **Server:**
  - `server/run_queue_022.sh`, `launch_022.sh` and `fetch_022.sh`;
  - `server/tier2_imagen_check.py`, run on the server's Python without NEST before the contract is frozen. It checks:
    - v3 frames equal v2 frames for every two-number step of 017, 021 and `sequence-r2.json`;
    - every pilot frame lies in [0, 2L], by explicit checks;
    - component amplitudes and the mean fit within 1e-9;
    - `generate_stimuli` builds one presentation;
    - `run_workflow` builds the model before `create_experiments`.
  - Version 4 of `controller_experiments.py`, the export hook only.
  - A local `test_queue_guard.sh` with a stub `systemctl`. It checks that the queue does not refuse itself, that it refuses while any other `felisyn-*` unit is active, the MemAvailable floor, and `OOMPolicy=continue`.
  - `deploy_live.sh` version 2 adds the new unit names to its guard. The run 001 version is kept.
- **Contract and freeze:** `make_contract_022r2.py` and `freeze_022r2.py`, a manifest with SHA-256 of every file above. Its hash is recorded in HANDOFF before the queue starts.

## Done when
- [ ] Revision 2 reviewed, revised and declared; its SHA-256 recorded in HANDOFF before any run
- [ ] All code above written and tested; the tier 2 check passes on the server; the contract frozen with hashes
- [ ] Both runs and the export job complete, or their failures are recorded
- [ ] The analysis is run once on the frozen contract; result package and journal note (an X draft only if the result is a serious achievement)
- [ ] `scripts/agent-verify.sh` passes
