Skip to content

Commit ea5852a

Browse files
committed
board: record the PR #258 arc — neutralize-by-cfg beats remove
Two appends, no code: - EPIPHANIES.md: the #258 finding. The "dalek must be removed" conclusion was reached twice from a correct intrinsic count (57 sites) and a wrong inference — the whole vector backend sits behind one cfg at backend/mod.rs:42, so reachability, not porting, was the question. Records the verified counts, the one-line fix, the serial-costs-nothing argument, and the X25519 contributory-check tripwire. - vertical-simd-consumer-contract.md: the escalation ladder this mints for third-party deps — (1) grep for the backend gate and neutralize by cfg, (2) port onto ndarray::simd only for paths we execute, (3) remove only with a failed gate-grep cited. "Contains raw intrinsics" and "raw intrinsics are reachable" are different claims; the matryoshka invariant binds the second.
1 parent b127e25 commit ea5852a

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

.claude/board/EPIPHANIES.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,51 @@ inspiration, never authority.
124124
fabrications still on master) · #5 ASG canon spec · #7 ASG-leaf impl (extend
125125
`CamPlaneSplat`, don't reinvent) · `cam-pq-production-wiring` (cam_pq shipped, unrouted
126126
through `CamCodecContract`) · `UNUSED_INVENTORY_1.95` A1–A9 dead-code.
127+
128+
## 2026-07-28 — A dependency's SIMD surface is a reachability question, not a porting one (PR #258)
129+
**Status:** FINDING (verified — counts + cfg gate + build output all checked live)
130+
**Scope:** @simd-savant @workspace-primer domain:crypto domain:matryoshka
131+
132+
The same wrong conclusion was reached twice in one arc: "curve25519-dalek's
133+
vector backend carries raw intrinsics (`avx2/field.rs` reaches around
134+
`packed_simd.rs`), therefore the matryoshka pattern requires removing the
135+
dependency." It got as far as a merged removal commit (`3694a3c`) before the
136+
premise was checked. The counts were right; the conclusion was not:
137+
138+
- **Counts (verified):** 57 `_mm*` intrinsic calls in the AVX2 path
139+
(35 `backend/vector/avx2/field.rs` + 22 `backend/vector/packed_simd.rs`),
140+
under 52 `unsafe` occurrences in those two files. (`ifma/field.rs` adds 6
141+
more on a nightly-only path.)
142+
- **The gate (verified):** ALL of it sits behind ONE cfg —
143+
`curve25519-dalek-4.1.3/src/backend/mod.rs:42`,
144+
`#[cfg(curve25519_dalek_backend = "simd")] pub mod vector;` — and dalek's
145+
build.rs reads that cfg from `CARGO_CFG_CURVE25519_DALEK_BACKEND`.
146+
- **The fix (one line):** `.cargo/config.toml` rustflags
147+
`--cfg curve25519_dalek_backend="serial"` compiles the entire second SIMD
148+
surface out. Verified after `cargo clean -p curve25519-dalek`: the build
149+
emits `curve25519_dalek_backend="serial"` only.
150+
- **`serial` costs nothing we use:** X25519's Montgomery ladder
151+
(`montgomery.rs`) never references the vector backend; the vector path
152+
serves only Edwards multi-scalar / variable-base multiplication (batch
153+
verification, Ristretto protocols) — neither performed by
154+
`crates/encryption`.
155+
156+
**The rule this mints:** before porting a third-party crate's SIMD onto
157+
`ndarray::simd` — and *long* before removing the crate — grep for the
158+
backend's cfg/feature gate. "It contains raw intrinsics" and "raw intrinsics
159+
reach the binary" are different claims; the matryoshka invariant binds the
160+
second, not the first. PR #258 (merged `b127e25`) is the worked example: the
161+
removal reverted, Ed25519 kept, the surface neutralized by cfg, diff net
162+
additive.
163+
164+
**Carried tripwire (X25519 port):** `x448::x448()` returns `Option` and
165+
rejects low-order points; `x25519_dalek::x25519()` returns a bare
166+
`[u8; 32]` — RFC 7748's contributory check is OPTIONAL, so a mechanical port
167+
drops it silently. The test
168+
`channel::tests::low_order_peer_keys_are_refused_and_honest_ones_are_not`
169+
(both halves asserted, per the falsifiability rule) fails if it does.
170+
171+
Cross-ref: PR #258 body (the full correction narrative), `.cargo/config.toml`
172+
comment block (the in-tree record), lance-graph
173+
`E-VACUOUS-ASSERTION-IS-THE-HOUSE-STYLE-1` (the falsifiability rule the
174+
low-order test follows).

.claude/knowledge/vertical-simd-consumer-contract.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,32 @@ The `simd-savant` agent on the `lance-graph` side runs PRE-MERGE against every W
326326
327327
> **Is the consumer site cited in the PR description?**
328328
> Missing = reject. We're shipping primitives for known workloads, not speculative ones.
329+
330+
## Third-party dependencies: neutralize by cfg BEFORE porting, port BEFORE removing (2026-07-28, PR #258)
331+
332+
The matryoshka invariant — all SIMD lives once, audited, inside
333+
`ndarray::simd` — binds what **reaches the binary**, not what a dependency's
334+
source tree *contains*. When a third-party crate carries its own intrinsics,
335+
the escalation ladder is:
336+
337+
1. **Grep for the gate.** Most crypto/perf crates gate their vector backend
338+
behind one cfg or feature (`curve25519-dalek`:
339+
`#[cfg(curve25519_dalek_backend = "simd")] pub mod vector;` at
340+
`backend/mod.rs:42`, selected by build.rs from
341+
`CARGO_CFG_CURVE25519_DALEK_BACKEND`). One rustflags line in
342+
`.cargo/config.toml` compiles the whole surface out. Cost: zero code.
343+
Verify with a clean rebuild that the cfg actually flips
344+
(`cargo build -v | grep <cfg name>`).
345+
2. **Port onto `ndarray::simd`** only if the intrinsics are load-bearing for
346+
a path we actually execute (the `vendor/chacha20` precedent — the ARX
347+
lane IS our hot path).
348+
3. **Remove the dependency** only if neither applies — and then the claim
349+
"can't be neutralized" must cite the failed gate-grep, not the intrinsic
350+
count.
351+
352+
PR #258 is the cautionary worked example: an intrinsic count (57 sites, real)
353+
was read as a porting obligation, escalated straight to step 3, and a merged
354+
removal commit had to be reverted once the step-1 gate was found. "Contains
355+
raw intrinsics" and "raw intrinsics are reachable" are different claims;
356+
audit the second. Full record: board `EPIPHANIES.md` 2026-07-28 entry +
357+
the `.cargo/config.toml` comment block.

0 commit comments

Comments
 (0)