refactor(accounts): extract AccountRegistryLoader load-orchestration collaborator (Wave 3 / 3a-4) - #1367
Conversation
🏗️ CodeAtlas Ledger Analysis✅ All Checks Passed♿ Accessibility (via AccessLint)
✅ No accessibility issues detected 🏛️ Architecture Analysis
🔄 Dependency CyclesSee full report for cycle details. 📋 Architecture FindingsSee full report for detailed findings. 🔍 Reachability Analysis
ℹ️ No architecture-relevant files in this diff — reachability not evaluated. 📊 0 files analyzed | 📦 Download Full Report Powered by CodeAtlas Ledger |
🧪 Unit Test Results📊 View Full Interactive Report ❌ 3 TESTS FAILED8207 tests | 8063 passed | 3 failed | 139 skipped | ⏱️ 12m 12s | 📊 98.2% | 📈 45.1% coverage All 947 classes — 3 with failures (full matrix)
📊 Full interactive matrix: report ❌ Failed testsNames only — open the interactive report above for messages + stack frames. 📊 Testing Coverage BreakdownUnit Test Line Coverage (testable surfaces): 45.1% Total coverage incl. UI/lifecycle: 44.1% (17 files excluded from testable denominator — see
🔗 Interactive HTML Report | CI Run Details Counts above were produced by this CI run's xcresult parse — reproduce via the run link. 📦 Downloadable Artifacts
|
…collaborator (Wave 3 / 3a-4) Fourth and LARGEST 3a collaborator split: the catalog LOAD orchestration — the loadCatalogs stale-while-revalidate pipeline, the first-page/paginate network crawl + direct-GET fallbacks, CP-D1 preload + slim-snapshot hydrate/carve/write, the owned background-crawl task registry + its test-boundary drain choreography, and the loading-completion handler dedupe — moves out of AccountsManager into an injected AccountRegistryLoader. It ORCHESTRATES the already-extracted registryCache (3a-1) / registryStore (3a-2) / authDocLoader (3a-3). Behaviour-identical. `final class`, not actor (loadCatalogs/cancelAndDrainBackgroundWork called synchronously). Off develop (all three prior extractions merged). **AccountsManager 1910 → 955 LOC (−955).** New AccountRegistryLoader.swift (873 LOC). Across the four extractions the hub is now 2383 → 955. - Hub keeps thin facades (loadCatalogs, loadAccountSetsAndAuthDoc, preloadAccountsFromDiskCacheSync, the drain/join _*ForTesting seams, a settable snapshotResourceResolver forwarding property) + static shims (carveSlimFeed, buildAccountIndex) so AppContainer / CatalogCrawlScheduler / PalaceTestSetup / EVERY existing test are byte-identical — ZERO external edits (the single-module /rigorous-fix proof; confirmed by git status = 6 files only). - **Drain-flag set-point (architect finding 2):** the hub cancelBackgroundWork() / cancelAndDrainBackgroundWork(timeout:) facades set `_explicitCancelCalled = true` FIRST, then delegate; the loader's cancel/drain bodies do NOT set the flag and do NOT call back for it. `_explicitCancelCalled` + the live-instance registry STAY on the hub, preserving the byte-identical 3a-3 AuthDocumentLoader.isTornDown binding. A verbatim relocation here would have reintroduced the exact test-pollution regression this wave prevents. - 9 injected provider closures ([weak self]) incl. currentLibraryAccountProvider for the COPPA age-check (finding 3). lazy var (closures capture self — the authDocLoader precedent). Verified: god-class freeze re-baselined DOWN 1910 → 955; locator 304 → 302; shared-read 213; Palace-noDRM BUILD SUCCEEDED (production compile). Architect pre-review BLOCKED then APPROVED after 3 contract corrections (preload/snapshotResolver facades, hub-sets-drain-flag, 9th closure). **Scope:** the catalog load orchestration + owned-crawl + drain out of AccountsManager into an injected collaborator; Accounts area only, single-module. **Not done:** DRM PalaceTests + the FULL suite (the pollution-sensitive Cancellation / FirstRunDecode / CacheRead / LaunchSnapshot / StateMachineWiring pins + mutation gate) run in CI ONLY — worktree can't build the Adobe host. `currentUserAccountProvider`'s UNREACHABLE [weak self]==nil fallback uses TPPUserAccount.sharedAccount() (no non-hub TPPUserAccount exists; a strong capture would retain-cycle) — flagged for review. **Deferred:** the last two 3a collaborators (CredentialResolver, CurrentAccountStore). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
690d311 to
65e7831
Compare
What & why
Fourth and largest of the 3a
PalaceAccountscollaborator splits. The catalog LOAD orchestration — theloadCatalogsstale-while-revalidate pipeline, the first-page/paginate network crawl + direct-GET fallbacks, CP-D1 preload + slim-snapshot hydrate/carve/write, the owned background-crawl task registry + its test-boundary drain choreography, and the loading-completion handler dedupe — moves out ofAccountsManagerinto an injectedAccountRegistryLoader. It orchestrates the already-extractedregistryCache(3a-1) /registryStore(3a-2) /authDocLoader(3a-3). Behaviour-identical. Follows #1360/#1361/#1363/#1366 (all merged).The number
AccountsManager1910 → 955 LOC (−955). NewAccountRegistryLoader.swift(873 LOC). Across the four extractions this session the hub is 2383 → 955 (−60%).Design (architect-validated, single-module
/rigorous-fix)final class, not an actor —loadCatalogs/cancelAndDrainBackgroundWorkare called synchronously; the drain depends on a synchronousregistryStorebarrier read. Same rationale as the prior three collaborators.loadCatalogs,loadAccountSetsAndAuthDoc,preloadAccountsFromDiskCacheSync, a settablesnapshotResourceResolverforwarding property, all the drain/join_*ForTestingseams) + static shims (carveSlimFeed,buildAccountIndex), soAppContainer/CatalogCrawlScheduler/PalaceTestSetup/ every existing test are byte-identical.git status= 6 files only. That zero-edit surface is the single-module proof.cancelBackgroundWork()/cancelAndDrainBackgroundWork(timeout:)facades set_explicitCancelCalled = truefirst, then delegate; the loader's cancel/drain bodies do not set the flag._explicitCancelCalled+ the live-instance registry stay on the hub, preserving the byte-identical 3a-3AuthDocumentLoader.isTornDownbinding. A verbatim relocation here would have reintroduced the exact test-pollution regression this wave exists to prevent (caught at contract review).[weak self]provider closures incl.currentLibraryAccountProviderfor the COPPA age-check.lazy var(closures capture self — theauthDocLoaderprecedent).Verification
Review rigor
/rigorous-fix: fix-contract → architect pre-review BLOCKED (missing preload/snapshotResolver facades = ~21 broken sites; the drain-flag verbatim-relocation trap; a missing COPPA-age-check closure) → corrected → APPROVED → implement → 3× SoD (architect,qa_test,blast_radius). Session-spawned agent reviewers (the[Self-Approval]flag is the known false-positive), not an independent human review.Flagged for review
currentUserAccountProvider's unreachable[weak self]==nilfallback usesTPPUserAccount.sharedAccount()(the checklist discouragessharedAccount()in new code). It is never hit at runtime — the hub-owned loader is always alive when it calls the provider — and no non-hubTPPUserAccountexists (a strong capture would retain-cycle). Surfaced for the reviewers to rule on.Not in this PR
The last two 3a collaborators:
AccountCredentialResolver,CurrentAccountStore.Account._setStatewrite-side injection.🤖 Generated with Claude Code