Repository navigation
Description
Source: meetings/2026-05-21_appmonetizationkit-code-audit.impl-notes.md (Code Reviewer, Yellow)
Umbrella issue for 5 Medium findings + 6 Nits. B1 fixed in PR #73; B2 resolved by PR #71's LiveMonetizationStateStore first-launch seeding.
Medium
M1 — AdGate spec ↔ code drift on lastShownDate
design.md §How.3 rule #4 says "lastShownDate == today AND not yet dismissed → keep showing"; code's shouldShowBanner never reads lastShownDate (only writes it for telemetry). Either update spec or reintroduce a daily-cap check.
M2 — AdGate.mutate(_:) silently swallows persistence errors
AdGate.swift:121-132 discards store.saveState(state) errors. Inject optional onPersistenceError: (@Sendable (Error) -> Void)? closure so host can route to telemetry.
M3 — LiveStoreKit2IAPClient.purchase synthesizes empty displayPrice
Catalog desync → displayPrice = "" renders as "Thanks for purchasing for " in UI. At minimum log; consider "Restore Purchases will refresh" hint.
M4 — No timezone-shift test
AdGate Calendar injection is uncovered for "user dismisses at 23:30 UTC, then crosses date line to UTC-8" scenario. Add test.
M5 — No system-clock-manipulation defense
shouldShowBanner(now:) trusts caller's Date.now. Adversary moving clock back to 1970 bypasses 7-day grace. Cheap mitigation: persist lastSeenWallClock and refuse advance if now < lastSeenWallClock - tolerance. Or accept threat model + document.
Nits
N1 — AdPresentationAnchor: @unchecked Sendable over AnyHashable
Narrow to UUID if v2.3 wiring only uses UUIDs.
N2 — LiveAdMobBridge: final class + OSAllocatedUnfairLock vs actor
Once loadBanner is real (post-v2.3.5), re-evaluate actor trade-off.
N3 — AdPresentationAnchor: public import UIKit/AppKit
Only MonetizationCore Apple-UI leak. Gate resolver methods behind separate extension target if portability matters.
N4 — LiveStoreKitBridge.transactionUpdates() uses Task.detached(.background)
Refund/family-share events affect entitlement — bump to .utility.
N5 — Live vs Fake IAPClient.purchaseUpdates() multi-subscriber semantics differ
Live wraps fresh AsyncStream per call; Fake shares one. Rename or assert single-call.
N6 — ProtocolShapeTests doesn't exercise Sendable at compile time
Add assertSendable(AdGateState(...)), assertSendable(IAPProduct(...)).
Out of scope
- B1, B2 already resolved (PRs fix(v2): LiveAdMobBridge.loadBanner throws until real SDK wiring lands #73, feat(v2.3): Part A — Persistence + AppComposition + RouteFactory wiring #71)
- v2 stabilization milestone candidate
Activity
feat(v2.4+v2.5): StoreKit Config + Toast + purchaseUpdates + readines…
feat(v2): AppMonetizationKit audit M+N polish (closes #80) (#97)