Skip to content

feat(v2.3): Part A — Persistence + AppComposition + RouteFactory wiring - #71

Merged
wei18 merged 1 commit into
mainfrom
feat/v2.3-part-a-wiring
May 21, 2026
Merged

wei18 merged 1 commit into
mainfrom
feat/v2.3-part-a-wiring

Conversation

@wei18

@wei18 wei18 commented May 21, 2026

Copy link
Copy Markdown
Owner

Summary

v2.3 Part A lands the wiring of AppMonetizationKit (v2.0–v2.2) into the Sudoku App's composition root. Three sub-steps in one PR:

  • v2.3.1 — MonetizationStateStore: CloudKit Private record MonetizationState in userZone, actor-based, with first-launch seeding of firstLaunchAt.
  • v2.3.2 — AppComposition: +3 monetization deps + routeFactory (9-arg init); App SwiftUI target now depends on MonetizationCore, IAPStoreKit2, AdsAdMob, MonetizationTesting.
  • v2.3.3 — RouteFactory promotion: extracted from Wave 3 audit M4 — RootView.init shrinks from 5 → 2 args; navigation seam is now testable.

Plus PrivacyManifestTests updated for v2 manifest state (post #62) — assertions now lock in AdMob tracking declaration.

Audit B2 resolved by this PR

The Code Reviewer audit (Yellow) flagged firstLaunchAt was never bootstrapped — the 7-day grace clock would never start. LiveMonetizationStateStore.loadState() lines 78–82 now synthesize + persist firstLaunchAt = clock() on first miss. Audit Blocker B2: CLOSED.

Test verification

  • swift build: clean
  • swift test --filter "RouteFactory|MonetizationStateStore|Composition|Privacy": 26/26 pass
  • Full swift test --parallel: hit a pre-existing hang in non-Part-A snapshot test (separate issue — to be triaged post-merge); Part A's contributions are all green.

Audit reports landed in meetings/

Report Verdict Outstanding
Spec drift Yellow 2 S1 (v2/design §3↔§9 numbering)
AppMonetizationKit code Yellow 1 Blocker remaining (B1: loadBanner synthetic .loaded)
AppIcon brand Yellow 3 S1 (tinted asset, dark icon palette, macOS rounded-rect)

All to be addressed in follow-up PRs per Leader plan.

Follow-ups (queued)

  1. Spec doc fix PR (S1-1 + S1-2)
  2. Code B1 fix PR (loadBanner throws .loadFailed until v2.3.5)
  3. Icon macOS clipPath PR (24% radius)
  4. Tinted icon dedicated asset PR
  5. Design-system difficulty token extension + UI rollout
  6. Issues for remaining S2/M/N findings → v2 stabilization milestone

Test plan

  • Open in Xcode after tuist generate; verify RootView preview renders
  • Sign in to iCloud on device; cold launch; verify CloudKit MonetizationState record created with firstLaunchAt
  • Launch twice; verify firstLaunchAt is stable (not overwritten)
  • Triage pre-existing snapshot test hang in a separate issue

🤖 Generated with Claude Code

v2.3.1 — MonetizationStateStore + CloudKit Private impl
- NEW Persistence/MonetizationStateStore.swift (typealias to AdGateStateStore)
- NEW Persistence/Live/LiveMonetizationStateStore.swift (actor; CloudKit
  Private record "MonetizationState" in userZone; first-launch seeding
  bootstraps firstLaunchAt → resolves audit B2)
- LivePersistence: +monetizationStateStore() lazy factory
- PrivateCKGateway: +monetizationStateRecordType constant
- +8 tests (round-trip, seeding, nil-optionals, Codable, payload shape)

v2.3.2 — AppComposition wiring
- Package.swift: +AppMonetizationKit local dep on 4 sub-products
- Project.swift: +package + 3 product links on App target
- AppComposition: +3 monetization deps + routeFactory (9-arg init)
- Live.swift: wires LiveMonetizationStateStore → AdGate → LiveAdMobAdProvider
  + LiveStoreKit2IAPClient + LiveRouteFactory
- Preview.swift: Fake* harness for previews/tests
- SudokuApp.swift: RootView call shrunk to 2 args
- CompositionTests: +2 tests (monetization deps + routeFactory wired)

v2.3.3 — RouteFactory promotion
- NEW SudokuUI/Navigation/RouteFactory.swift (protocol + LiveRouteFactory)
- RootView.init: 5 args → 2 args (viewModel + routeFactory)
- +6 RouteFactoryTests (one per AppRoute case)
- RootViewTests: signature update + makeTestRouteFactory() helper

Plus PrivacyManifestTests updated for v2 manifest state (post #62):
- Renamed noThirdPartyTrackingDomains → adMobTrackingDeclared
- Assert tracking=true, 8+ domains, OtherUsageData/ThirdPartyAdvertising,
  UserDefaults API with reason CA92.1

Verification:
- swift build: clean (0 warnings on touched files)
- swift test --filter RouteFactory|MonetizationStateStore|Composition|Privacy:
  26/26 pass

Meeting logs:
- meetings/2026-05-21_v2.3-part-a-wiring.impl-notes.md (Part A delivery)
- meetings/2026-05-21_spec-drift-audit.impl-notes.md (Yellow, 2 S1)
- meetings/2026-05-21_appmonetizationkit-code-audit.impl-notes.md (Yellow,
  B1 only — B2 resolved by this PR)
- meetings/2026-05-21_app-icon-brand-audit.impl-notes.md (Yellow, 3 S1)
- meetings/2026-05-21_wave-3-issues-filed.impl-notes.md (#64–#69 filed)

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@wei18
wei18 merged commit cbc4987 into main May 21, 2026
@wei18
wei18 deleted the feat/v2.3-part-a-wiring branch May 21, 2026 13:05
wei18 added a commit that referenced this pull request May 22, 2026
Address all 5 Medium + 6 Nit findings from 2026-05-21 Code Reviewer audit
(B1 + B2 already merged in #73 + #71). Code Reviewer approved 2026-05-22
after one revision (test fix for M5 false-positive).

M1 — design ↔ code reconciliation
- docs/v2/design.md §How.3 removed misleading lastShownDate gating rule;
  clarified lastShownDate is recorded for telemetry only (matches code)

M2 — onPersistenceError closure
- AdGate.init(store:calendar:onPersistenceError:) — new optional closure
  parameter; MonetizationCore stays Telemetry-free, host wires the route
- Live wiring in SudokuKit/AppComposition/Live.swift fan-outs to Telemetry
- AdGate.mutate(_:) catch now invokes the closure (was a comment)
- Test: saveFailureSurfacesViaOnPersistenceError

M3 — empty displayPrice + catalog-desync telemetry
- LiveStoreKit2IAPClient: empty fallback now "—" (em-dash placeholder)
- New optional onCatalogDesync closure → Telemetry.errorOccurred

M4 — timezone-shift test
- AdGateLogicTests.dismissedTodayAcrossDateLineCrossing

M5 — system-clock-manipulation defense
- AdGateState.lastSeenWallClock: Date? (new optional field)
- AdGate.clockTamperTolerance = 24h
- shouldShowBanner refuses grace if now < lastSeen - tolerance
- Monotonic advance on show/dismiss/purchase paths
- LiveMonetizationStateStore CloudKit field add-via-write
- Tests: clockMovedBackwardsRefusesGraceAdvance (firstLaunch 2024-01-01),
  clockToleranceWithin24hStillShows (verified by flip-guard technique
  per Code Reviewer reject + revision)

N1 — AdPresentationAnchor narrowed AnyHashable → UUID; drop @unchecked
N2 — actor-vs-class re-eval deferred to post-v2.3.5 (noted)
N3 — AdPresentationAnchor resolver split into separate file (Foundation-
     only type vs UIKit/AppKit resolvers); enables future Linux exclude
N4 — LiveStoreKitBridge.transactionUpdates priority .background → .utility
N5 — FakeIAPClient single-consumer constraint — diagnostic tracking
     (purchaseUpdatesWasSubscribed) instead of crashing tests
N6 — ProtocolShapeTests.valueTypesRemainSendable compile-time Sendable
     coverage on AdGateState, IAPProduct, IAPPurchaseEvent variants,
     IAPPurchaseResult, AdBannerStatus, AdPresentationAnchor

Public surface stable: only optional init params + optional struct field
+ resolver file split. No SemVer-breaking additions.

Verification:
- AppMonetizationKit: 87/87 tests (was 82, +5)
- SudokuKit affected suites: 28/28 (HomeViewBanner saveCount assertion
  relaxed from == 1 → >= 1 per new wall-clock advance semantics)
- swift build clean both packages
- Isolation audit: 1 GoogleMobileAds import (LiveAdMobBridge.swift)

§未決 (impl-notes)
- M5 wall-clock advance writes on every shouldShowBanner — acceptable for
  v2; throttle in v2.x if CloudKit quota matters
- N5 Fake vs Live multi-subscriber semantics differ (diagnostic-only)
- AdPresentationAnchorRegistry still v2.2 backlog

Co-authored-by: Claude Opus 4.7 <[email protected]>
wei18 added a commit that referenced this pull request May 26, 2026
…entries (#155)

Two new foundations §Backlog entries from 2026-05-26 user discussion:

(A) Expand ViewModel interaction tests (no new dep):
    - Real gap: snapshot covers state, but tap → navigate / tap → mutate
      uncovered systematically
    - Reuse existing RouteFactory protocol (PR #71) + swift-testing
      protocol-injected fakes
    - FakeRouteFactory ~15 LOC + per-VM ~30-60 LOC tests
    - Trigger: navigation regressions / new View without interaction test

(B) Mockable framework evaluation (trigger-based, break-glass):
    - Replace hand-rolled fakes with @mockable macro
    - Third-party SDK — requires foundations §9 break-glass justification
    - Trigger: 5+ large fakes / 3+ boilerplate review nits / SwiftUI preview
      unification
    - Other applications documented: SwiftUI #Preview injection, record/replay
      capture mode, runtime mode switch, team naming convention

Closes the user's 2026-05-26 backlog framing question about UI interaction
test gap + Mockable evaluation.

Co-authored-by: Claude Opus 4.7 <[email protected]>
wei18 added a commit that referenced this pull request Sep 11, 2026
#1067)

Brings in the catalog-wide skill audit (PR #69), the phase-2 description
rewrites (#70, #71), and the three-review follow-ups (#72): 136 verified
corrections, iOS 26 / macOS 26 baseline, app-icon-rasterize retired
(27 → 26 Apple skills), Swift 6.2 MainActor default, and a SKILL.md format
gate. Pointer-only, matching the previous bumps.

Co-authored-by: Claude Fable 5.1 <[email protected]>
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