Task Breakdown: Data Generator
Feature ID: data-generator
Plan: ./plan.md
Status: Done (Retrospective)
Last updated: 2026-05-02
Phase 1 — DataRepository
- T1.
DataRepositoryclass atpackages/agent/src/data-generator/data-repository.tswith methods:clone,pull,commit,push,createBranch,switchBranch. - T2.
readConfig/writeConfigfor.works/works.yml— preserve unknown fields on write (forward-compat). - T3.
readItems/writeItem/removeItemfor theitems/work (one JSON file per slug). - T4.
readCategories/writeCategories/readTags/writeTags/readBrands/writeBrandsfor the corresponding YAML files. - T5. Unit tests for round-trip read/write per file format.
Phase 2 — Generation modes
- T6.
mergeItems(existing, newItems)utility preservingfeaturedandorderwhen slugs match; tests cover insert, update, no-op cases. - T7. CREATE_UPDATE mode: merge new items with existing, keep items not in this batch.
- T8. RECREATE mode: clear
items/work before writing new items; resetcategories.yml/tags.yml/brands.ymlto the pipeline output. - T9. Both modes increment
.works/works.yml.versionand updatemetadata.updated_at.
Phase 3 — Service orchestration
-
T10.
DataGeneratorServiceatpackages/agent/src/data-generator/data-generator.service.tswith the public methodinitialize(work, user, dto, opts: { logCollector, signal }): Promise<DataGeneratorResult>. -
T11.
initializeflow:- Resolve git token via
GitFacadeService. - Clone or pull data repository (create if missing for
mode === 'create'). - Read existing
.works/works.yml+ items + taxonomy. - Call
ItemsGeneratorService.generateItems()with full context. - Apply mode-specific merge.
- Write all files back to working tree.
- Commit + push (or commit + PR per work setting).
- Build
DataGeneratorResultwith stats + optional PR info.
- Resolve git token via
-
T12.
signal(AbortSignal) propagated into the items pipeline and into git operations so cancellation aborts in-flight work. -
T13.
logCollectorupdates streamed at every major step transition (clone, pipeline started, items merged, commit, push) — visible in the recent-logs panel.
Phase 4 — PR mode
- T14. Branch creation:
ever-update-<unix-timestamp>from the work's default branch. - T15. Commit changes on the new branch with a clear "Ever Works: Update work items" message.
- T16. Open PR via
GitFacadeService.createPullRequestwith a body summarising new/updated counts. - T17. Capture PR
{ branch, title, body, number, url }into theDataGeneratorResult.prUpdatefield for the markdown generator to reference.
Phase 5 — Error handling
- T18. Clone retry with exponential backoff (3 attempts).
- T19. Push retry with backoff; final failure surfaces as a structured error in the result.
- T20. PR creation falls back to direct commit if the user's git provider rejects PR creation.
- T21.
normalizeGeneratorErrortranslates raw exceptions intoWorkGenerationErrorcodes for consistent UI display.
Phase 6 — Pipeline integration
- T22. Hook into
TriggerGenerationOrchestrator.runso the data generator runs first; markdown + website generators run conditionally (only when items changed or already exist). - T23. Surface
hasExistingItemsflag so downstream generators know whether to run incremental updates.
Phase 7 — Tests
- T24. Unit tests for
DataGeneratorService.initializewith mockedDataRepositoryand mockedItemsGeneratorService. - T25. Unit tests for both modes (CREATE_UPDATE, RECREATE) verifying merge semantics.
- T26. e2e test that runs an end-to-end mock generation against a temp git repo on disk.
- T27. Cancellation test: AbortSignal during clone / pipeline / push leaves the data repo in a recoverable state.
Phase 8 — Docs
- T28. User-facing doc explaining repository structure and
modes (lives under
docs/features/). - T29. Cross-link from
markdown-generatorandwebsite-generatorspecs. - T30. Retrospective spec / plan / tasks (this set).
Phase 9 — Quality gates
- T31.
pnpm format && pnpm lint && pnpm test && pnpm buildgreen. - T32.
pnpm --filter ever-works-docs buildproduces no broken-link warnings.
Definition of Done
- Both generation modes produce identical outputs for a fixed input set
- PR mode + direct mode both shipped, configurable per work
- User-edited fields (
featured,order) preserved in CREATE_UPDATE - Cancellation propagates into clone, pipeline, and push without leaving the repo dirty
- Constitution gates in
spec.md§9 confirmed satisfied