Skip to content

refactor(persistence): convert LivePersistence to actor (closes #68) - #126

Merged
wei18 merged 1 commit into
mainfrom
refactor/m11-livepersistence-actor-2
May 23, 2026
Merged

wei18 merged 1 commit into
mainfrom
refactor/m11-livepersistence-actor-2

Conversation

@wei18

@wei18 wei18 commented May 23, 2026

Copy link
Copy Markdown
Owner

Wave 3 audit M11. Single-file class→actor conversion. Code Reviewer APPROVE. 82/82 tests, 0 caller diffs (nonisolated factory keeps AppComposition.live() sync).

Code Reviewer APPROVE 2026-05-24.

LivePersistence was the lone outlier among 6 actor-based persistence
modules: final class @unchecked Sendable + NSLock-guarded lazy init.
Lazy-init shape maps naturally to actor isolation.

Changes:
- final class @unchecked Sendable → actor
- Removed NSLock + lock.lock()/unlock() pairs
- 3 lazy slots (_gateway, _telemetry, _puzzleLoader) now actor-isolated
- All 9 PersistenceProtocol methods unchanged (already async throws)
- monetizationStateStore() factory annotated nonisolated — touches no
  actor state, returns fresh LiveMonetizationStateStore with @sendable
  gateway provider closure. Keeps AppComposition.live() sync.

Verification:
- swift build clean
- Filtered tests 82/82 pass
- 0 caller-site diffs (rg "LivePersistence" Packages/ → 7 hits, all
  string-match in AppComposition.live() init + test fixtures)
- bootstrap() re-entry: _gateway captured once at top, both awaits use
  local — no TOCTOU. Concurrent invocations safe via outer actor
  serialization + inner LivePrivateCKGateway idempotency.

§未決 (impl-notes)
- Per-instance gateway design: deliberate; LiveMonetizationStateStore
  gets fresh provider rather than sharing the facade's _gateway slot
- nonisolated factory: only escape hatch; documented inline

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@wei18
wei18 merged commit 4655461 into main May 23, 2026
@wei18
wei18 deleted the refactor/m11-livepersistence-actor-2 branch May 23, 2026 18:24
wei18 added a commit that referenced this pull request May 24, 2026
…lper (#127)

Two Wave 3 audit refactors landed together — original separate PRs
(#126 M11) merged with docs-only diff due to race-condition working-tree
clobber; this re-applies both code changes correctly.

M11 (closes #68) — LivePersistence final class + NSLock → actor
- final class @unchecked Sendable + NSLock → public actor
- 3 lazy slots actor-isolated (_gateway, _savedGameStore, _personalRecordStore)
- All 9 PersistenceProtocol methods unchanged (already async throws)
- monetizationStateStore() factory: nonisolated, returns fresh
  LiveMonetizationStateStore — keeps AppComposition.live() sync

M16 (closes #69) — extract utcDayString to SudokuEngine/UTCDay
- NEW SudokuEngine/UTCDay.swift (single source-of-truth + .gmt fallback,
  no swiftlint force-unwrap)
- Removed 4 duplicate copies:
  - GameCenterClient/SubmitGuards.utcDayString
  - GameCenterClient/AchievementEvaluator.utcDayString
  - Persistence/Live/SavedGameStore.dayPrefix (sibling variant)
  - PuzzleStore/PuzzleIdentity.utcDayString
- All call sites use UTCDay.string(from:)
- 2 test files updated (AchievementTests, SinkTests stub shims)

Bonus: foundations §Backlog +2 items
- GitHub Actions agent PR review (spec/design/code/discussion)
- Skill/context gap reflection (5 candidate skills)

Verification: swift build clean; filtered test 82/82 pass.

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

Inline-applied from CR review of PR #152:

- pr-diff-verification: drop fabricated PR #126 narrative; replace
  with generic pattern description covering 3 recurring failure modes
- monetization-sdk-integration:
  - fix FakeAdMobBridge path (Tests/AdsAdMobTests/, not MonetizationTesting/)
  - drop wrong PR #149 attribution (it's swiftformat, not the fatalError)
  - clarify Sources/MonetizationTesting/ scaffolding vs test-target fakes
  - tighten description for clearer auto-discovery trigger (CR B+ → A)
- subagent-conflict-detection: §派發契約 §9 → "item 9"
  (methodology uses narrative numbering, not formal §N sub-headings)

No content removed — only factual corrections + 1 description tighten.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
wei18 added a commit that referenced this pull request May 26, 2026
…tem) (#152)

* docs(skills): fill 4 repo-derived skills + foundations.md update (closes #11 5-of-5)

Closes the "補齊 repo skills/context 缺口" backlog entry from 2026-05-24
reflection. All 5 sub-items now landed:

(a) ✅ subagent-conflict-detection — pre-dispatch grep target file set
    vs in-flight subagent worktrees; prevents parallel-dispatch race
(b) ✅ pr-diff-verification — pre-push `git show --stat HEAD` cross-check
    vs commit message claims; encodes PR #126 incident + worktree-wipe
    lost-commits + push-wrong-ref footguns
(c) ✅ asc-ops-handoff — User-owned vs Leader-orderable vs hybrid
    taxonomy for App Store Connect / TestFlight / Apple Developer ops;
    references canonical docs (v2.5-readiness.md, ASCRegister, etc.)
(d) ✅ monetization-sdk-integration — foundations §9 break-glass
    exception process + isolation contract (single-file protocol seam,
    canImport gating, audit grep regex); encodes AdMob v13 upgrade +
    Production ID swap safety + macOS conditional gating incidents
(e) ✅ memory subdir reorg — already in place since 2026-05-25
    (user/feedback/project/reference dirs)

All 4 new skills live at `.claude/skills/<name>/SKILL.md` per
[[feedback-project-derived-skills-location]] (project-derived skills
are repo-level, not $HOME).

foundations.md §Backlog entry updated with ✅ marks + linked file refs.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* docs(skills): apply CR #152 nits — fix factual citations + tighten descriptions

Inline-applied from CR review of PR #152:

- pr-diff-verification: drop fabricated PR #126 narrative; replace
  with generic pattern description covering 3 recurring failure modes
- monetization-sdk-integration:
  - fix FakeAdMobBridge path (Tests/AdsAdMobTests/, not MonetizationTesting/)
  - drop wrong PR #149 attribution (it's swiftformat, not the fatalError)
  - clarify Sources/MonetizationTesting/ scaffolding vs test-target fakes
  - tighten description for clearer auto-discovery trigger (CR B+ → A)
- subagent-conflict-detection: §派發契約 §9 → "item 9"
  (methodology uses narrative numbering, not formal §N sub-headings)

No content removed — only factual corrections + 1 description tighten.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 <[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