feat(task-013): add draft assembly API, immutable versioning, and editor preview
This commit is contained in:
@@ -35,13 +35,13 @@ Development description: Assemble section scaffolds into a canonical Markdown/MD
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] TDD pre-requirement: before implementation, write one failing behavior test that assembles a draft from successful section scaffolds through the public API; proceed one draft behavior at a time and record evidence in `Result`.
|
||||
- [ ] Draft assembly includes all planned sections in order.
|
||||
- [ ] Draft includes metadata, FAQ, visual placeholders, evidence references, and unsupported claim warnings.
|
||||
- [ ] Draft version 1 is immutable after approval-relevant edits; edits create a new version.
|
||||
- [ ] Generic Markdown/MDX preview renders headings, links, tables, images/placeholders, and FAQ.
|
||||
- [ ] Editor can compare or select draft versions.
|
||||
- [ ] Draft assembly fails clearly if required section scaffolds are missing.
|
||||
- [x] TDD pre-requirement: before implementation, write one failing behavior test that assembles a draft from successful section scaffolds through the public API; proceed one draft behavior at a time and record evidence in `Result`.
|
||||
- [x] Draft assembly includes all planned sections in order.
|
||||
- [x] Draft includes metadata, FAQ, visual placeholders, evidence references, and unsupported claim warnings.
|
||||
- [x] Draft version 1 is immutable after approval-relevant edits; edits create a new version.
|
||||
- [x] Generic Markdown/MDX preview renders headings, links, tables, images/placeholders, and FAQ.
|
||||
- [x] Editor can compare or select draft versions.
|
||||
- [x] Draft assembly fails clearly if required section scaffolds are missing.
|
||||
|
||||
## Verification
|
||||
|
||||
@@ -51,9 +51,31 @@ Development description: Assemble section scaffolds into a canonical Markdown/MD
|
||||
|
||||
## Result
|
||||
|
||||
- Status: Pending execution.
|
||||
- TDD plan: To be filled during execution.
|
||||
- Red evidence: To be filled during execution.
|
||||
- Green evidence: To be filled during execution.
|
||||
- Refactor notes: To be filled during execution.
|
||||
- Verification output: To be filled during execution.
|
||||
- Status: Completed. Pre-requirement (RED) and implementation (GREEN) finished.
|
||||
- TDD plan:
|
||||
1. Keep the original RED pre-requirement behavior test for `POST /api/articles/{article_id}/draft/assemble`.
|
||||
2. Extend backend integration coverage for draft assembly payload completeness, immutable versioning, missing scaffold conflict, unsupported warning propagation, and not-found paths.
|
||||
3. Implement backend drafts application layer and public routes for assemble/list/get/patch.
|
||||
4. Extend shared API contracts (OpenAPI + generated TS types).
|
||||
5. Implement frontend draft editor with version selector, compare summary, and generic markdown preview parser/renderer.
|
||||
6. Add frontend model tests for preview parsing and version comparison.
|
||||
- Red evidence:
|
||||
- Pre-requirement test `apps/backend/tests/integration/test_draft_assembly_public_api.py::DraftAssemblyPublicApiTest::test_assemble_draft_from_successful_section_scaffolds` initially failed before implementation.
|
||||
- Observed RED error before implementation: `AssertionError: 201 != 404 : {"detail":"Not Found"}`.
|
||||
- Green evidence:
|
||||
- `POST /api/articles/{article_id}/draft/assemble` implemented and returns `201` with canonical draft payload.
|
||||
- `GET /api/articles/{article_id}/drafts`, `GET /api/articles/{article_id}/drafts/{draft_id}`, and `PATCH /api/articles/{article_id}/drafts/{draft_id}` implemented and covered.
|
||||
- Immutable versioning verified: patch creates `v2+`, base draft remains unchanged.
|
||||
- Missing required successful section scaffolds returns clear `409`.
|
||||
- Frontend generic preview parser renders headings, links, tables, images/placeholders, and FAQ blocks.
|
||||
- Frontend editor supports version selection and compare summary.
|
||||
- Refactor notes:
|
||||
- Added dedicated backend drafts service (`application/drafts.py`) and drafts route module to isolate draft logic from evidence/plan flows.
|
||||
- Extended `article_drafts` persistence model with canonical body and metadata lists (`faq_items`, placeholders, evidence refs, warnings, based_on_draft_id`) for explicit version snapshots.
|
||||
- Verification output:
|
||||
- `PYTHONPATH=/private/tmp/pupline-backend-deps python3 -m unittest apps/backend/tests/integration/test_draft_assembly_public_api.py` -> OK (5 tests)
|
||||
- `PYTHONPATH=/private/tmp/pupline-backend-deps python3 -m unittest apps/backend/tests/integration/test_parallel_production_public_api.py` -> OK (6 tests)
|
||||
- `PYTHONPATH=/private/tmp/pupline-backend-deps python3 -m unittest apps/backend/tests/integration/test_evidence_matrix_public_api.py` -> OK (2 tests)
|
||||
- `node apps/frontend/tests/draft_editor.model.test.mjs` -> OK
|
||||
- `node apps/frontend/tests/article_detail.model.test.mjs` -> OK
|
||||
- `pnpm --dir apps/frontend typecheck` -> OK
|
||||
|
||||
Reference in New Issue
Block a user