Fix daily check persistence after successful lookup - #37
Merged
Conversation
- Separate daily eligibility from success and review-attempt persistence - Add replaceable clock, state store, and App Store lookup dependencies - Cover failure, success, date transitions, and review scheduling - Document daily check and review attempt semantics Closes #14
HituziANDO
marked this pull request as ready for review
August 19, 2026 02:46
Co-authored-by: HituziANDO <2204870+HituziANDO@users.noreply.github.com>
Co-authored-by: HituziANDO <2204870+HituziANDO@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes daily scheduling persistence so daily version-check conditions only record a date after a successful App Store lookup (and review conditions record attempt dates), by extracting scheduling behind injectable clock/state-store dependencies and adding deterministic unit tests.
Changes:
- Introduces
DailySchedulewith injectableSUKClockandSUKSchedulingStateStore, plus an execution gate for concurrent version-check lookups. - Updates version-check and review-request conditions to separate eligibility evaluation from recording success/attempts; updates
SUKto record success only after a valid lookup response. - Adds scheduling-focused unit tests and documents the new persistence behavior in the README.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents updated daily scheduling semantics for version checks and review attempts. |
| Framework/SwiftyUpdateKitTests/SwiftyUpdateKitTests.swift | Adds deterministic tests covering success/failure, day transitions, concurrency, and review attempts. |
| Framework/SwiftyUpdateKit.xcodeproj/project.pbxproj | Adds DailySchedule.swift to Xcode project build phases. |
| Framework/Sources/VersionCheckCondition.swift | Adds success-recording + execution-control protocols; updates daily conditions to use DailySchedule. |
| Framework/Sources/SUK.swift | Refactors version check flow to inject lookup dependency and record success post-lookup; centralizes review-request attempt recording. |
| Framework/Sources/RequestReviewCondition.swift | Updates review conditions to use DailySchedule and record attempt dates. |
| Framework/Sources/ITunesSearchAPI.swift | Introduces AppStoreLookup abstraction and default ITunesAppStoreLookup. |
| Framework/Sources/DailySchedule.swift | New scheduling abstraction for daily eligibility, persistence, and execution gating. |
| .github/workflows/ci.yml | Updates CI simulator destination. |
Suppressed comments (1)
Framework/Sources/SUK.swift:346
- When the App Store response is missing a
version, this branch returns without callingnext(nil). That leaves callers with no completion signal (similar to the failure case), sonoop/newReleaselogic may never run on invalid payloads.
let storeVersion = lookUpResult.version
else {
// Ignore an error.
logf("version does not exist in the response data.", log)
executionController?.finishVersionCheck()
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Root cause
Daily conditions persisted the current date while evaluating eligibility, before the asynchronous App Store lookup completed. A failed lookup therefore consumed the daily allowance until the next day. Review conditions used the same combined evaluation-and-mutation pattern, which obscured that StoreKit only confirms a request attempt rather than presentation.
Impact
The existing public condition types remain source-compatible. Daily and launching-and-daily conditions now share the same transition rules, failed lookups remain retryable, and scheduling behavior can be tested without external services or the system clock.
Validation
Closes #14