v2.1.3: dev-hygiene cleanup (String(format:), flaky test, loose tests)#7
Merged
v2.1.3: dev-hygiene cleanup (String(format:), flaky test, loose tests)#7
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdbecause of recurring SIGSEGV crashes when%sis given a SwiftString.Replacements use:
value.number(N)extension (FloatingPointFormatStyleon iOS 15+/macOS 12+,NumberFormatterfallback)NumberFormatterhelper insideFloatingPointFormatter.swift(drop-inprintfsemantics for the smart-rounding paths)String(value, radix: 16)with manual zero-padding for the one hex-formatting case inTemplateRegistry2. Fixed the flaky
PortfolioUtilitiesTests.Random returns are within reasonable rangetestPreviously used
Double.random(in:)(the system RNG), which violates the mandatory deterministic-randomness rule from09_TEST_DRIVEN_DEVELOPMENT.mdand occasionally drew values 5σ+ outside the test's expected range. Refactored to use the existingTestSupport.SeededRNG(LCG, seed 42).3. Tightened two pre-existing loose tests
Accelerate FFT: matches Pure Swiftpreviously only checked peak bin location, which let the v2.1.0 4× scaling bug slip through. Now requires bin-for-bin equivalence at1e-9relative tolerance.Parseval's theorempreviously used0.5 < ratio < 2.0(2× margin in either direction). Tightened to1e-12relative tolerance — what the theorem actually guarantees.Test plan
String(format:matches inSources/andTests/Compatibility
FormatStyle/NumberFormatterinstead ofprintf, but the rendered values are identical for the locale-neutral cases (which is all the existing call sites used).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.mdwould have failed against the BusinessMath production codebase with 17 hits the moment it shipped. v2.1.3 unblocks that check.🤖 Generated with Claude Code