Pre-existing rustfmt drift across the workspace was blocking CI's
`Rustfmt` check on PR #373 + PR #377. Running plain `cargo fmt`
reformats 427 files; no semantic changes, no logic changes, no
behavior changes — just what rustfmt already wanted.
None of the touched files are in ruvector-rabitq, ruvector-rulake,
or the new mirror-rulake workflow — those were already fmt-clean
per the per-crate checks on commits 5a4b0d782, 5f32fd450, f5003bc7b.
Drift is in cognitum-gate-kernel, mcp-brain, nervous-system,
prime-radiant, ruqu-core, ruvector-attention, ruvector-mincut,
ruvix/* and sub-crates, plus several examples.
Verified post-fmt:
cargo check -p ruvector-rabitq -p ruvector-rulake → clean
cargo clippy -p ... -p ... --all-targets -- -D warnings → clean
cargo test -p ... -p ... --release → 82/82 pass
Intentionally does NOT touch clippy drift — many more warnings
(missing docs, precision-loss casts, too-many-args, unsafe-safety-
docs) spread across unrelated crates, each category a cross-cutting
design decision that deserves its own review.
With this commit Rustfmt CI goes green on PR #373 and PR #377.
Clippy will still fail — that's honest pre-existing state for a
separate dedicated PR.
Co-Authored-By: claude-flow <ruv@ruv.net>
Lands the deterministic Sinclair-12 Miller-Rabin u64 kernel and build-time
prime tables under crates/ruvector-collections/, per ADR-151.
Implementation
- src/primality_kernel.rs: shared MR core (mulmod via u128, powmod, witness
loop, prev/next prime). Single source of truth — include!d from both build.rs
and src/primality.rs to keep the build script and runtime kernel byte-identical.
- src/primality.rs: public API — is_prime_u32/u64, prev/next_prime_u64,
prev_prime_below_pow2(k), next_prime_above_pow2(k), ephemeral_prime(seed).
Probabilistic is_prime_u128 gated behind --feature unstable-u128 with
Russian-peasant mulmod, mod_add overflow-safe addition, and LCG-seeded
witness selection.
- build.rs: emits PRIMES_BELOW_2K[57] / PRIMES_ABOVE_2K[57] for k ∈ [8, 64].
ABOVE[64] is a 0 sentinel (no u64 prime > 2^64); k=64 BELOW special-cases
via mr_prev_prime_u64(u64::MAX).
Tests (76 pass; cross-check 0.00s)
- tests/primality_pseudoprimes.rs: pinned A014233 strong pseudoprimes
(entries 4, 5, 11) so any witness-set regression — including dropping
base-37 — fails loudly. SPP_FIRST_11 = 3_825_123_056_546_413_051 is the
canary for base-37 detection.
- tests/table_cross_check.rs: re-validates all 114 emitted table entries
against MR + sweep_odds_strictly_between (iterates the prime gap, not the
range — so even k=63 finishes instantly).
- Doc tests + 7 inline unit tests including u128 M_89 smoke.
Benches (criterion, M-series)
- is_prime_u64 worst case (u64::MAX − 58): 15.63 µs (3 runs ±2%)
- prev_prime_below_pow2 k=32 shard router: 7.48 ns
- next_prime_u64 ~1e9: 11.44 µs
- next_prime_u64 2^61 − 1 general path: 7.83 µs
Empirical floor finding: re-running with num-prime 0.4.4 in the same binary
on the same hardware measured num_prime::is_prime64(u64::MAX − 58) at 884 ns
vs ours at 15.63 µs — confirming the 50 ns PRD target was structurally
unachievable in safe Rust (~17.7× headroom recoverable via Montgomery in
Phase 0.1, but not 300×). PRD §6 and ADR-151 amended in a follow-up commit.