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.
2.8 KiB
2.8 KiB
Module 2 Gap Report
Archived on 2026-04-21. This document describes the removed legacy syncRegistry-based sync chain. The active runtime path is now the ManualSyncService manual-sync pipeline.
Current State
- Card extraction only derives legacy card identity from heading structure and source position.
CardDrafthas noembeddedNoteIdfield.SourceLocationhas no block-end marker positioning data beyondblockEndLine.SyncRecordonly stores legacycardKey -> noteIdmappings.SyncPlanningServiceonly matches cards by legacycardKey.ExecuteSyncPlanUseCaseonly supports add/update driven by plan entries and never writes back into Markdown.VaultGatewaycannot replace Markdown content with optimistic concurrency.AnkiGatewaycannot batch-check note existence/model vianoteId.
Already Correct
- Card rendering is separate from extraction and can stay identity-agnostic.
- Sync registry persistence is already centralized in the shared plugin data snapshot.
- Execution already validates field mappings before side effects.
- Source scanning and sync execution are already split into
scan/planandexecutephases.
Missing For Module 2
Extraction
- Parse block-end
<!-- AHS:<noteId> -->markers. - Reject malformed or duplicated markers in the same heading block.
- Exclude marker lines from
bodyMarkdown. - Populate
embeddedNoteIdand marker positioning metadata.
Identity And Registry
- Extend
SyncRecordwithidentityModeand optionallegacyCardKey. - Keep legacy
cardKeylookup while adding embeddednoteIdlookup. - Preserve pending write-back state when Anki note creation succeeds but Markdown write-back fails.
Planning
- Prefer embedded
noteIdover legacycardKeywhen available. - Allow embedded-note-id cards to update even if the local registry entry is missing.
- Detect orphans independently for embedded-note-id and legacy-card-key records.
Execution
- Validate embedded
noteIdexistence/model before update. - Recreate missing embedded-note-id notes and replace the block-end marker.
- Write back a new marker for newly created notes.
- Reject basic/cloze type switches for embedded-note-id cards.
- Retry pending marker write-back on later legacy hits.
Infrastructure
- Add
VaultGateway.replaceMarkdownFile(path, expectedContent, nextContent). - Implement block-end marker replacement in the Obsidian gateway.
- Add
AnkiGateway.getNoteSummaries(noteIds)and AnkiConnect implementation.
Tests Missing
- Extraction tests for valid, duplicate, and malformed AHS markers.
- Planning tests for embedded
noteIdprecedence and mixed orphan detection. - Execution tests for write-back success/failure, recreation, and type-switch rejection.
- Gateway tests for
getNoteSummariesand optimistic Markdown replacement.