mirror of
https://github.com/panatgithub/AnkiHeadingSync.git
synced 2026-07-22 06:51:43 +00:00
删除已失效的 legacy sync use case、syncRegistry 持久化与旧 card pipeline,运行入口保持 ManualSyncService 主链。 Remove the obsolete legacy sync use cases, syncRegistry persistence, and old card pipeline while keeping the runtime on ManualSyncService.
4 KiB
4 KiB
Legacy Sync Cleanup Gap Report
Scope audited
- Runtime entry:
src/presentation/AnkiHeadingSyncPlugin.ts - Current manual-sync path:
ManualSyncService,ManualSyncCurrentFileUseCase,ManualSyncVaultUseCase,RebuildCardIndexUseCase - Legacy sync path:
ScanAndPlanSyncUseCase,ExecuteSyncPlanUseCase,SyncCurrentFileUseCase,SyncVaultUseCase,SyncRegistryRepository,DataJsonSyncRegistryRepository,HeadingSyncMarkerService,src/domain/sync/**,CardExtractionService - Mixed-use boundary:
DataJsonPluginConfigRepository,NoteFieldMappingService,domain/cardshared types
Findings
1. Current production runtime is already manual-sync only
src/presentation/AnkiHeadingSyncPlugin.tsinstantiates only:ManualSyncServiceManualSyncCurrentFileUseCaseManualSyncVaultUseCaseRebuildCardIndexUseCase- management use cases built on
pluginState
- No production initialization path constructs or invokes the legacy sync chain.
2. Legacy sync chain is isolated from the current runtime
- Production references to legacy use cases are confined to the legacy chain itself.
ScanAndPlanSyncUseCasedepends onCardExtractionService,SyncPlanningService, andSyncRegistryRepository.ExecuteSyncPlanUseCasedepends onHeadingSyncMarkerService,SyncRegistryRepository,SyncRegistry,SyncRecord, and legacy sync result types.SyncCurrentFileUseCaseandSyncVaultUseCaseare thin wrappers over the two legacy use cases.- Current manual-sync code does not import
src/domain/sync/**orDataJsonSyncRegistryRepository.
3. syncRegistry is legacy-only compatibility residue
DataJsonPluginConfigRepositorystill carriesPluginDataSnapshot.syncRegistry, but the repository only loads and savessettings.- Current runtime persistence uses
DataJsonPluginStateRepositoryandpluginState; it does not consumesyncRegistry. - The remaining
syncRegistryproduction references are inside the legacy chain and its repository.
4. Legacy identity modes are not part of current manual-sync state
embedded-note-id,legacy-card-key, andpending-note-id-writeare only present in legacy sync types, repository code, tests, and compatibility docs.- Current manual-sync persistence uses
pluginState.cards,pluginState.files,groupBlocks, andpendingWriteBack; it does not persist legacy identity modes.
5. Shared card-domain types must stay
- Confirmed current non-legacy usage exists for:
RenderedFieldsMediaAssetSourceFileSourceLocationCardTypeRenderResourceResolverCardKeyContentHash
- These are used by current manual-sync services, vault/Anki gateways, rendering, write-back, and test support.
6. Card.ts is only kept alive by legacy code plus one current type import
NoteFieldMappingServiceimportsCardonly for method signatures andCard["type"].- The service already has a smaller
RenderedCardInputshape, so current code can be decoupled fromdomain/card/entities/Card.ts. - After decoupling and legacy deletion,
Card.tscan be removed if no remaining references exist.
7. Legacy-only tests and docs remain
- Legacy-only tests currently cover:
ExecuteSyncPlanUseCaseSyncCurrentFileUseCaseSyncVaultUseCaseHeadingSyncMarkerServiceDataJsonSyncRegistryRepositorysrc/domain/sync/**CardExtractionService
- Several docs still describe the legacy chain as an implementation surface rather than archived context.
Cleanup implications
- Safe direct deletion candidates: legacy use cases, legacy repository port/implementation, marker service,
src/domain/sync/**, and legacy-only tests. - Mixed files requiring edits before or during deletion:
src/infrastructure/persistence/DataJsonPluginConfigRepository.tssrc/application/services/NoteFieldMappingService.ts- docs that still present the old chain as active
- Shared type modules under
src/domain/cardmust be preserved unless a concrete post-cleanup search shows zero remaining references.