Phase 1: Load Existing Stories
Progressive Loading for token efficiency:
Step 1: Orchestrator provides Story metadata (ID, title, status)
Step 2: Load FULL descriptions ONE BY ONE
```javascript
for each story_id:
get_issue(id=story_id) // ~5,000 tokens per Story
```
Token Rationale: 10 Stories Γ 5,000 = 50,000 tokens. Load sequentially to manage context.
Step 3: Parse 8 sections for each Story
- Story Statement (persona, capability, value)
- Context
- Acceptance Criteria (3-5 GWT)
- Test Strategy
- Technical Notes (Standards Research in Library Research subsection)
- Definition of Done
- Dependencies
Step 4: Extract metadata
- ID, number, title, status
- Persona, capability, value
- AC scenarios
- Standards Research (from Technical Notes)
Output: Array of N existing Story structures ready for comparison.
Phase 2: Compare IDEAL vs Existing
Algorithm: See [replan_algorithm_stories.md](references/replan_algorithm_stories.md)
Match by goal, persona, capability:
For EACH Story in IDEAL:
- Extract: Title, Persona, Capability
- Search existing: Fuzzy match title, check persona/capability overlap
- Result: Match β KEEP/UPDATE | No match β CREATE
For EACH existing Story:
- Extract: Title, Persona, Capability (from Story Statement)
- Search IDEAL: Fuzzy match
- Result: Match β KEEP/UPDATE | No match β OBSOLETE
Categorize operations:
| Operation | Criteria | Status Constraint | Action |
|-----------|----------|-------------------|--------|
| KEEP | Goal + Persona + Capability + AC + Standards Research same | Any | None |
| UPDATE | Match + (AC OR Standards Research OR Technical Notes changed) | Backlog/Todo β
In Progress/Review β οΈ
Done β | update_issue |
| OBSOLETE | No match + Feature removed | Backlog/Todo β
In Progress/Review β οΈ
Done β | update_issue(state="Canceled") |
| CREATE | In IDEAL + No match + New requirement | N/A | Generate doc + create_issue |
Edge Cases:
| Case | Action |
|------|--------|
| In Progress OBSOLETE | β οΈ NO auto-cancel, show warning |
| Done conflicts | Preserve Done, CREATE follow-up |
| Story Split (1 β 2+) | β οΈ UPDATE first + CREATE new |
| Story Merge (2+ β 1) | β οΈ UPDATE first + OBSOLETE rest |
| Ambiguous match (>70% similarity) | Show all, select highest |
Details: [replan_algorithm_stories.md](references/replan_algorithm_stories.md)
Phase 3: Show Operations Summary
```
REPLAN SUMMARY for Epic 7: OAuth Authentication
IDEAL PLAN:
- US004: Register OAuth client (Persona: Third-party developer)
- US005: Request access token β AC5 ADDED! β RFC 7636 PKCE ADDED!
- US006: Validate access token
- US009: Token scope management (NEW!)
EXISTING STORIES:
β US004 - Status: Done - KEEP
β US005 - Status: Todo - UPDATE
Changes: Add AC5, Add RFC 7636 to Technical Notes, Add 2 Integration tests
Diff (AC): + AC5 "Given public client, When request with PKCE..."
Diff (Technical Notes): + RFC 7636 (PKCE)
β US008 - Status: Todo - OBSOLETE (feature removed)
+ US009 - NEW (14h, 20 tests, OAuth 2.0 Scope standard)
OPERATIONS: 2 keep, 1 update, 1 cancel, 1 create
WARNINGS:
- β οΈ US005 (Todo): AC changed, Standards Research updated
- β οΈ US008 (Todo): Feature removed - check dependencies
Type "confirm" to execute.
```
Diffs show:
- AC changes (line-by-line)
- Standards Research changes (added/removed RFCs)
- Test Strategy changes (test counts)
Warnings for:
- Status conflicts (In Progress/Review affected)
- Story Split/Merge detected
- Ambiguous matches
Phase 4: User Confirmation
If autoApprove=true: Skip β Phase 5
Otherwise: Wait for "confirm"
Adjustment: User can request changes β Recategorize β Show updated summary β Loop until "confirm"
Phase 5: Execute Operations
Sequence: UPDATE β OBSOLETE β CREATE β Update kanban
UPDATE operations:
- Generate new Story document (load via Template Loading logic)
- Validate INVEST (same as ln-221-story-creator Phase 2)
update_issue(id, description=new_description)- Add comment: "Story updated: AC changed (AC5 added), Standards Research updated (RFC 7636)"
OBSOLETE operations:
update_issue(id, state="Canceled")- Add comment: "Story canceled: Feature removed from Epic Scope In. Reason: [details]"
CREATE operations:
- Generate Story document (same as ln-221-story-creator Phase 1)
- Validate INVEST
create_issue({title, description, project=Epic, team, labels=["user-story"], state="Backlog"})
Update kanban_board.md:
DELETE (OBSOLETE): Remove canceled Story lines, remove task lines if any, remove Epic header if empty
CREATE (NEW): Find ### Backlog β Search Epic group β Add Stories (2-space indent)
UPDATE Epic Story Counters: Last Story, Next Story
Return:
```
REPLAN EXECUTED for Epic 7
OPERATIONS SUMMARY:
β Kept: 2 Stories
β Updated: 1 Story (AC/Standards Research changed)
β Canceled: 1 Story (feature removed)
β Created: 1 Story (new requirement)
UPDATED: [ID: US005](url) - AC5 added, RFC 7636 PKCE added
CANCELED: US008 Custom token formats
NEW: [ID: US009](url) - Token scope management
WARNINGS: US005 (Todo) AC changed
β kanban_board.md updated
β Standards Research updates: RFC 7636 PKCE added to US005
NEXT STEPS:
- Review warnings
- Run ln-310-story-validator on updated/created Stories
- Use ln-300-task-coordinator to create/replan tasks
```