Skip to content

test: seeded adversarial-limb fuzz as a CI gate#125

Merged
mmurshed merged 1 commit into
mainfrom
tests/adversarial-fuzz
Jun 12, 2026
Merged

test: seeded adversarial-limb fuzz as a CI gate#125
mmurshed merged 1 commit into
mainfrom
tests/adversarial-fuzz

Conversation

@mmurshed

Copy link
Copy Markdown
Owner

Summary

Audit follow-up: the regression-protection gap behind all three 2026 silent wrong-answer bugs (MFA inverse twiddle #103, BZ odd-size #116, FastDivision MG top-equal in #120) was the same — uniformly random operands can't hit structured limb patterns, so the random sweeps stayed green while production paths returned wrong numbers.

Adds tests/unit/test_adversarial_fuzz.cpp (picked up by the existing glob, runs in the unit_tests ctest target, ~60 ms):

  • Division: 2000 cases with 0/1/max/2^63-biased limbs, dispatch vs KnuthDivision reference digit-for-digit + q*b + r == a and r < b; plus BZ/Newton/QSized-band shapes (incl. odd 1025×513 for the BZ padding path) via the identity.
  • Multiplication: 1000 cases vs classic schoolbook + NTT-band spot checks.
  • Square vs Multiply(a,a) across Karatsuba and CRT bands.
  • ToString/parse round-trip on adversarial limbs, both signs.

Deterministic seeds — reproducible CI, no flakes. The division distribution is exactly the one that surfaced the FastDivision MG bug.

Test plan

  • unit_tests: 285 passed, 0 failed (~0.2 s total)
  • Full ctest 4/4

🤖 Generated with Claude Code

Three silent wrong-answer classes shipped in 2026 (MFA inverse twiddle
#103, BZ odd-size fallback #116, FastDivision MG top-equal qhat in #120)
and none was catchable by uniformly random operands — each required a
structured limb pattern with ~zero probability under the existing random
sweeps.

Adds 5 deterministic fuzz tests to the unit suite (~60 ms total) using
the 0 / 1 / 2^64-1 / 2^63-biased limb distribution that surfaced the MG
bug: 2000 division cases cross-checked digit-for-digit against the
KnuthDivision reference plus the q*b+r==a identity, larger BZ/Newton/
QSized shapes (including odd sizes for the BZ padding path) via the
identity, 1000 multiplication cases vs classic schoolbook plus NTT-band
spot checks, Square vs Multiply(a,a), and ToString/parse round-trips.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mmurshed mmurshed merged commit 1aae367 into main Jun 12, 2026
4 of 5 checks passed
@mmurshed mmurshed deleted the tests/adversarial-fuzz branch June 12, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant