Skip to content

v2 audit (Code): umbrella for AppMonetizationKit M1–M5 + N1–N6 #80

Closed

Description

@wei18

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

Activity

  1. added
    v2-audit
    architecture
    on May 21, 2026
  2. added a commit that references this issue on May 22, 2026
    3a963de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architecturev2-audit

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions