fix(sync): stop full-catalog package wipe, enrich-stub 404s, and O(n·m) bulk deletes
Three bugs surfaced by a monitored 'sync --full' run: - sync --full's update step ran without ctx.fullSync, so the packages adapter resolved 'official' scope and tombstoned all 11k previously synced SwiftPackageIndex pages as stale (the crawl phase then re-fetched them from scratch). Thread fullSync into the update step, and mark official-scope discovery as partial so a subset inventory can never tombstone pages outside its scope (also fixes the standalone update command permanently wiping the catalog). - The Xcode-asset enricher matched corpus keys exactly, but the asset strips apostrophes from article slugs, so pages like metal/using-metal-to-draw-a-view's-contents were re-inserted as novel contentless duplicates under slugs that 404 publicly — and sample-code discovery trusted every role='sampleCode' document, producing guaranteed 'Fetch failed' warnings on every sync with no path to converge. Match apostrophe-insensitively in the enricher and skip enrichedFrom documents in sample-code discovery. - Deleting a document scans document_relationships (2.2M rows) for to_key = ? since v21 dropped idx_rel_to; the stale loop did that once per page in its own transaction — ~24B row visits for the 11k batch, pinning the sync at 99% CPU for tens of minutes. Add markPagesDeleted: one transaction, transient to_key index for the batch, dropped after.
G
Gigi committed
0128b0c18e192c4c08ec158931d50593dd2d7870
Parent: 1795b3e