refactor(anki): extract workflow services from integration facade

Split note-update and field-grouping orchestration out of AnkiIntegration so the facade remains focused on composition and shared policy wiring. This keeps mining behavior stable while creating focused workflow seams with dedicated regression coverage and clearer ownership docs.
This commit is contained in:
2026-02-21 13:23:53 -08:00
parent 54109deb94
commit 5cb0ee1591
7 changed files with 822 additions and 276 deletions

View File

@@ -1,10 +1,10 @@
---
id: TASK-76
title: Decompose anki-integration orchestrator into workflow services
status: To Do
status: Done
assignee: []
created_date: '2026-02-18 11:43'
updated_date: '2026-02-18 11:43'
updated_date: '2026-02-21 21:16'
labels:
- anki
- refactor
@@ -41,15 +41,40 @@ priority: high
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 `src/anki-integration.ts` reduced to orchestration/composition role
- [ ] #2 Extracted workflow modules have focused tests
- [ ] #3 Existing mining behavior remains unchanged in regression tests
- [ ] #4 Documentation updated with ownership boundaries
- [x] #1 `src/anki-integration.ts` reduced to orchestration/composition role
- [x] #2 Extracted workflow modules have focused tests
- [x] #3 Existing mining behavior remains unchanged in regression tests
- [x] #4 Documentation updated with ownership boundaries
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Execution started via writing-plans + executing-plans workflow.
Plan: docs/plans/2026-02-21-task-76-anki-workflow-services-plan.md
Baseline LOC (2026-02-21): src/anki-integration.ts=1315; existing anki-integration collaborators total=2271 (src/anki-integration/*.ts excluding facade).
Implemented workflow-service decomposition in `src/anki-integration.ts` by extracting `src/anki-integration/note-update-workflow.ts` (new-card update pipeline) and `src/anki-integration/field-grouping-workflow.ts` (auto/manual grouping merge orchestration).
Added focused workflow seam tests: `src/anki-integration/note-update-workflow.test.ts` and `src/anki-integration/field-grouping-workflow.test.ts`.
Updated ownership boundaries docs in `docs/anki-integration.md` under "Ownership Boundaries (TASK-76)".
Verification: `bun run build && node --test dist/anki-integration.test.js dist/anki-integration/note-update-workflow.test.js dist/anki-integration/field-grouping-workflow.test.js` (pass), and `bun run build && bun run test:core:dist` (pass).
LOC delta: `src/anki-integration.ts` 1315 -> 1143 (-172 LOC).
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Decomposed `AnkiIntegration` into workflow services by extracting note update and field-grouping orchestration into dedicated modules while keeping public APIs stable. Added focused workflow seam tests, documented ownership boundaries, and validated behavior with Anki-focused dist tests plus full `test:core:dist` gate.
<!-- SECTION:FINAL_SUMMARY:END -->
## Definition of Done
<!-- DOD:BEGIN -->
- [ ] #1 `bun run test:core:dist` passes with Anki-related suites green
- [ ] #2 No callsite API breakage outside planned changes
- [x] #1 `bun run test:core:dist` passes with Anki-related suites green
- [x] #2 No callsite API breakage outside planned changes
<!-- DOD:END -->