Skip to main content

E4:S11:T07 – Planning: Spec, Tests, Implementation Plan

Task: Migrate Embedded Tasks to Discrete Task Documents
Host Task: T07-migrate-embedded-tasks-to-discrete-documents.md (E4:S11:T07)
Status: TODO
Planning doc created: 2026-02-22


1. Specification

1.1 Goal

Convert all 784 embedded task references in Story documents into discrete Task documents (separate files), achieving full FR-016 compliance and enabling RW Step 1 to reliably locate all Task documents.

1.2 Functional Requirements

IDRequirementSource
FR-1All embedded tasks extracted and converted to discrete Task documentsTask doc, FR-016
FR-2All Story documents updated to reference discrete Task documents (no embedded content)Task doc
FR-3All Task documents follow canonical template structureTASK_TEMPLATE.md
FR-4All Task documents include required fields: Task ID, Scope, Input, Deliverable, Acceptance Criteria, Status, Version AnchorFR-016:R02, Task doc
FR-5Zero embedded tasks remaining (or clearly documented exceptions)Task doc
FR-6RW Step 1 can locate all Task documentsFR-016:R03
FR-7Validators pass for all migrated tasksTask doc
FR-8Migration preserves information (no loss)Migration plan
FR-9Task document naming: T\{task\}-\{slug\}.md (e.g., T01-task-name.md)Migration plan
FR-10Story checklist format: - [x] **E\{epic\}:S\{story\}:T\{task\}** – Name - [Link](path)Existing pattern

1.3 Embedded Task Detection Spec

Task boundary patterns:

  • Header: ### E\{epic\}:S\{story\}:T\{task\} – Task Name or ## E\{epic\}:S\{story\}:T\{task\}
  • Variants: **E\{epic\}:S\{story\}:T\{task\}**, T\{task\} – Name
  • Content: From header until next task header or ## section
  • Edge cases: Nested sections, incomplete tasks, tasks spanning multiple blocks

Task ID extraction:

  • Canonical: E\{epic\}:S\{story\}:T\{task\} (e.g., E4:S11:T07)
  • Abbreviated in context: T\{task\} when Epic/Story known from Story doc path

1.4 Task Document Structure (Canonical)

Per TASK_TEMPLATE.md and FR-016:

  • Frontmatter (lifecycle, created_at, etc.)
  • Task ID (Format, Full Task ID)
  • Scope
  • Input
  • Deliverable
  • Acceptance Criteria
  • Approach
  • Dependencies
  • References
  • Version Anchor (when complete)

1.5 Out of Scope

  • Creating new tasks (only migrating existing embedded)
  • Changing task content semantics (preserve or infer)
  • UKW/RW workflow changes beyond alignment with existing validators

2. Test Design

2.1 Test Categories

CategoryPurpose
Unit – ExtractionParse embedded task sections from Story docs
Unit – GenerationProduce valid Task documents from extracted data
Unit – Story updateReplace embedded with references correctly
Integration – ValidationPost-migration validators pass
Integration – RW Step 1Task location logic finds all Task docs
End-to-endFull migration of pilot Story produces valid result

2.2 Test Cases

TCNameBehavior under test
T1test_extract_embedded_task_simpleStory with ### E4:S11:T01 – Name yields one task with correct E/S/T
T2test_extract_embedded_task_multipleStory with 3 tasks yields 3 extracted tasks, correct boundaries
T3test_extract_handles_nested_sectionsTask with #### subsections: content captured until next task
T4test_extract_handles_missing_fieldsTask with minimal content: extract with placeholder/TODO for missing fields
T5test_generate_task_doc_required_fieldsGenerated Task doc has all required sections populated
T6test_generate_task_doc_namingFile name follows T\{task\}-\{slug\}.md convention
T7test_story_update_replaces_embeddedStory after update has checklist items with links, no embedded body
T8test_story_update_preserves_non_taskOverview, other sections unchanged
T9test_validation_no_embedded_remainingPost-migration scan finds zero embedded tasks in migrated Story
T10test_validation_all_refs_validAll Task doc links resolve
T11test_rw_step1_locates_taskvalidate_version_bump / RW Step 1 finds Task doc for migrated Story
T12test_migration_idempotentRe-running migration on migrated Story is safe (no duplication)

2.3 Test Data Strategy

  • Fixtures: Minimal Story docs with 1–3 embedded tasks (simple, nested, incomplete)
  • Expected outputs: Canonical Task docs + updated Story
  • Pilot Stories: Use 1–2 real Stories for integration tests (Epic 4 or 6)

3. Implementation Plan

3.1 Phase 1: Analysis and Tooling (Weeks 1–2)

StepActionDeliverable
1.1Current state analysisCatalog of all 784 embedded tasks by Epic/Story
1.2Extraction scriptextract_embedded_tasks.py – parse Story, yield task dicts
1.3Generation scriptgenerate_task_doc.py – task dict → Task doc file
1.4Story update scriptupdate_story_refs.py – replace embedded with checklist refs
1.5Validation scriptvalidate_migration.py – no embedded, refs valid, fields present
1.6Unit tests T1–T8Tests for extraction, generation, story update

3.2 Phase 2: Pilot Migration (Week 3)

StepActionDeliverable
2.1Select 1–2 pilot StoriesE.g., Epic 4 Story 11, Epic 6 Story 7 (subset)
2.2Run migration on pilotMigrated Task docs + updated Story
2.3Manual reviewRefinements, edge-case fixes
2.4Integration tests T9–T12Validation, RW Step 1, idempotency
2.5Refine scriptsBased on pilot learnings

3.3 Phase 3: Phased Rollout (Weeks 4–7)

StepActionDeliverable
3.1Migrate by EpicEpic 1 → Epic 2 → Epic 4 → Epic 5 → Epic 6 → …
3.2Validate after each EpicValidation report
3.3Fix issues before proceedingIterate as needed

3.4 Phase 4: Final Validation and Docs (Week 8)

StepActionDeliverable
4.1Full validationZero embedded, all refs valid, validators pass
4.2DocumentationMigration guide, exceptions (if any)
4.3Migration completion reportChecklist, metrics

3.5 Dependency Order

1.1 Current state analysis (informs extraction patterns)

1.2 Extraction script
1.3 Generation script
1.4 Story update script

1.5 Validation script
1.6 Unit tests

2.1–2.5 Pilot + integration tests

3.1–3.3 Phased rollout

4.1–4.3 Final validation + docs

4. Script Interfaces (Proposed)

4.1 extract_embedded_tasks.py

Input:  Story file path
Output: List[{epic, story, task, name, content, start_line, end_line}]

4.2 generate_task_doc.py

Input:  Task dict, output dir, template path
Output: Task doc file path

4.3 update_story_refs.py

Input:  Story file path, list of (task_id, task_doc_path)
Output: Updated Story content (or write to file)

4.4 validate_migration.py

Input:  Kanban root path
Output: Report {embedded_count, broken_refs, missing_fields, ...}
Exit: 0 if valid, 1 if issues

5. Files to Create/Modify

FileAction
packages/frameworks/workflow mgt/scripts/kanban/extract_embedded_tasks.pyCreate
packages/frameworks/workflow mgt/scripts/kanban/generate_task_doc.pyCreate
packages/frameworks/workflow mgt/scripts/kanban/update_story_refs.pyCreate
packages/frameworks/workflow mgt/scripts/kanban/validate_migration.pyCreate
packages/frameworks/workflow mgt/scripts/kanban/test_migrate_embedded_tasks.pyCreate
docs/.../migration-plan-embedded-to-discrete-tasks.mdUpdate (fill TBDs, link to scripts)

6. Success Criteria

  • Migration plan document complete (current state filled)
  • All 12 test cases pass
  • Zero embedded tasks in migrated Epics (or documented exceptions)
  • RW Step 1 locates all Task documents
  • validate_version_bump passes for migrated tasks
  • No information loss (manual spot-check)
  • Migration guide and completion report produced