ruvector/docs/research/miller-rabin-optimizations
Ofer Shaal 241738c986 docs(adr): ADR-151 + PRD §6 — Phase 0 findings, revised perf targets, Grok review
Phase 0 implementation revealed that the original PRD §6 targets
(50 ns / 200 ns for is_prime_u64 worst case) were structurally
unachievable in safe Rust on Apple-silicon. Apples-to-apples competitor
benchmark in the same binary on the same machine measured num-prime
0.4.4 at 884 ns vs ours at 15.63 µs — ~17.7× headroom recoverable via
Montgomery reduction in Phase 0.1, but not the ~300× the original target
implied. The 50 ns figure was a pre-implementation estimate that did not
survive contact with measured hardware.

ADR-151 (docs/adr/ADR-151-miller-rabin-prime-optimizations.md)
- Status promoted from "Proposed" to "Accepted (Phase 0 landed
  2026-04-16; performance targets revised)".
- New "Phase 0 Findings (2026-04-16)" section documenting what landed,
  measurements vs original targets, num-prime competitor baseline, the
  revised target band, and Phase 0.1 scope (Montgomery only).
- Explicit rejection of swapping to the empirical 7-witness set:
  Sinclair-12 is theorem-proven across all u64; the 7-witness sets in
  the literature are empirically tested up to 2^64 but not proven, and
  swapping invalidates the A014233(11) canary in the pseudoprime test.

PRD §6 (docs/research/miller-rabin-optimizations/PRD.md)
- Revision header noting the relaxation.
- is_prime_u64(p) worst-case row updated to ≤ 1 µs (was 50 ns) M-series
  / ≤ 4 µs (was 200 ns) WASM.
- New §6.1 "Empirical findings (Phase 0)" with the measurement table
  and the num-prime baseline data.

GROK-REVIEW-REQUEST.md (new, 424 lines)
- Self-contained briefing used to obtain external Grok review of the
  Phase 0 design and Phase 0.1 plan: §1 binding context, §2 implementation
  embedded verbatim, §3 measurements + competitor baseline, §4 four-section
  ask (correctness, perf plan ranked, architecture, validation
  methodology), §5 response format. Constraints block forbids
  "just use num-prime" answers and pins the canary witness set.
2026-04-16 14:41:02 -04:00
..
GROK-REVIEW-REQUEST.md docs(adr): ADR-151 + PRD §6 — Phase 0 findings, revised perf targets, Grok review 2026-04-16 14:41:02 -04:00
HANDOFF.md docs(adr): ADR-151 + PRD — Miller-Rabin prime optimizations (PIAL) 2026-04-16 12:34:47 -04:00
PRD.md docs(adr): ADR-151 + PRD §6 — Phase 0 findings, revised perf targets, Grok review 2026-04-16 14:41:02 -04:00