Skip to content

v2.1.3: dev-hygiene cleanup (String(format:), flaky test, loose tests)#7

Merged
jpurnell merged 1 commit intomainfrom
feature/v2.1.3-cleanup
Apr 8, 2026
Merged

v2.1.3: dev-hygiene cleanup (String(format:), flaky test, loose tests)#7
jpurnell merged 1 commit intomainfrom
feature/v2.1.3-cleanup

Conversation

@jpurnell
Copy link
Copy Markdown
Owner

@jpurnell jpurnell commented Apr 8, 2026

Summary

Pure dev-hygiene patch release. Cleans up the technical debt that v2.1.1 and v2.1.2 work surfaced but didn't address.

Changes

1. Removed all String(format:) violations from Sources/ and Tests/

13 source files and 4 test files were silently using the banned C-style format ABI, which is on the Forbidden Patterns list in 01_CODING_RULES.md because of recurring SIGSEGV crashes when %s is given a Swift String.

Replacements use:

  • The project's existing value.number(N) extension (FloatingPointFormatStyle on iOS 15+/macOS 12+, NumberFormatter fallback)
  • A new private POSIX-locale NumberFormatter helper inside FloatingPointFormatter.swift (drop-in printf semantics for the smart-rounding paths)
  • String(value, radix: 16) with manual zero-padding for the one hex-formatting case in TemplateRegistry

2. Fixed the flaky PortfolioUtilitiesTests.Random returns are within reasonable range test

Previously used Double.random(in:) (the system RNG), which violates the mandatory deterministic-randomness rule from 09_TEST_DRIVEN_DEVELOPMENT.md and occasionally drew values 5σ+ outside the test's expected range. Refactored to use the existing TestSupport.SeededRNG (LCG, seed 42).

3. Tightened two pre-existing loose tests

  • Accelerate FFT: matches Pure Swift previously only checked peak bin location, which let the v2.1.0 4× scaling bug slip through. Now requires bin-for-bin equivalence at 1e-9 relative tolerance.
  • Parseval's theorem previously used 0.5 < ratio < 2.0 (2× margin in either direction). Tightened to 1e-12 relative tolerance — what the theorem actually guarantees.

Test plan

  • All 4817 tests pass (4720 prior + 97 from v2.1.2)
  • Zero compiler warnings
  • Zero String(format: matches in Sources/ and Tests/
  • Flaky test now uses seeded RNG and is fully deterministic
  • Tightened tests pass with strict tolerances

Compatibility

  • No public API changes. All edits are internal — string formatting in report generators, debug logs, and benchmark output, plus test refactors.
  • No production behavior changes. Output strings are now produced via FormatStyle/NumberFormatter instead of printf, but the rendered values are identical for the locale-neutral cases (which is all the existing call sites used).
  • Examples/ still has String(format:) violations and will be cleaned up in a separate PR. Examples are not part of the package build target and don't run in CI.

Why this release exists

The format-string detection check filed for quality-gate-swift at quality-gate-swift/development-guidelines/02_IMPLEMENTATION_PLANS/UPCOMING/StringFormatDetection.md would have failed against the BusinessMath production codebase with 17 hits the moment it shipped. v2.1.3 unblocks that check.

🤖 Generated with Claude Code

Removes the remaining 13 String(format:) violations in Sources/ and 4
in Tests/ — banned by 01_CODING_RULES.md because of recurring SIGSEGV
crashes when %s is given a Swift String. All call sites now use the
project's value.number(N) extension or, in FloatingPointFormatter.swift,
a private POSIX-locale NumberFormatter helper.

Fixes the previously-flaky PortfolioUtilitiesTests "Random returns are
within reasonable range" test that violated the mandatory deterministic-
randomness rule. Now uses TestSupport.SeededRNG with seed 42.

Tightens two pre-existing loose tests:
- accelerateMatchesPureSwift: was peak-bin-only, missed the v2.1.0 4×
  scaling bug. Now bin-for-bin equivalence at 1e-9 relative.
- parsevalsTheorem: was 0.5..2.0 ratio (2× margin in either direction).
  Now 1e-12 relative — what the theorem actually guarantees.

No public API changes, no production behavior changes. All 4817 tests
pass, zero compiler warnings.

Examples/ still has String(format:) violations and will be cleaned up
separately — not part of package build/CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jpurnell jpurnell merged commit 00e05ff into main Apr 8, 2026
4 checks passed
@jpurnell jpurnell deleted the feature/v2.1.3-cleanup branch April 8, 2026 04:14
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