owflow 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +448 -283
- package/dist/agents/bottleneck-analyzer.md +332 -333
- package/dist/agents/code-quality-pragmatist.md +353 -354
- package/dist/agents/code-reviewer.md +238 -239
- package/dist/agents/codebase-analysis-reporter.md +245 -246
- package/dist/agents/docs-operator.md +22 -23
- package/dist/agents/e2e-test-verifier.md +447 -448
- package/dist/agents/gap-analyzer.md +501 -502
- package/dist/agents/implementation-completeness-checker.md +219 -220
- package/dist/agents/implementation-planner.md +308 -309
- package/dist/agents/information-gatherer.md +690 -691
- package/dist/agents/production-readiness-checker.md +278 -279
- package/dist/agents/project-analyzer.md +403 -403
- package/dist/agents/reality-assessor.md +365 -366
- package/dist/agents/research-planner.md +449 -450
- package/dist/agents/research-synthesizer.md +402 -403
- package/dist/agents/solution-brainstormer.md +256 -257
- package/dist/agents/solution-designer.md +371 -372
- package/dist/agents/spec-auditor.md +297 -298
- package/dist/agents/specification-creator.md +333 -334
- package/dist/agents/task-classifier.md +449 -450
- package/dist/agents/task-group-implementer.md +283 -284
- package/dist/agents/test-suite-runner.md +194 -195
- package/dist/agents/user-docs-generator.md +508 -509
- package/dist/commands/reviews-code.md +90 -90
- package/dist/commands/reviews-pragmatic.md +99 -99
- package/dist/commands/reviews-production-readiness.md +113 -113
- package/dist/commands/reviews-reality-check.md +110 -110
- package/dist/commands/reviews-spec-audit.md +114 -114
- package/dist/commands/work.md +280 -280
- package/dist/configuration/agents-config.d.ts +2 -0
- package/dist/configuration/agents-config.js +8 -44
- package/dist/configuration/commands-config.d.ts +23 -0
- package/dist/configuration/commands-config.js +17 -17
- package/dist/configuration/skills-config.d.ts +2 -0
- package/dist/configuration/skills-config.js +3 -3
- package/dist/hooks/hooks-diagnostics.d.ts +3 -0
- package/dist/hooks/hooks-diagnostics.js +21 -0
- package/dist/hooks/hooks-persistence.d.ts +17 -0
- package/dist/hooks/hooks-persistence.js +207 -0
- package/dist/hooks/hooks-registry.d.ts +6 -0
- package/dist/hooks/hooks-registry.js +104 -0
- package/dist/hooks/hooks-wrapper.d.ts +25 -0
- package/dist/hooks/hooks-wrapper.js +318 -0
- package/dist/hooks/internal/before-tool.d.ts +6 -0
- package/dist/hooks/internal/before-tool.js +13 -0
- package/dist/hooks/internal/session-compaction.d.ts +9 -0
- package/dist/hooks/{session-compaction.js → internal/session-compaction.js} +9 -7
- package/dist/hooks/runtime/circuit-breaker.d.ts +23 -0
- package/dist/hooks/runtime/circuit-breaker.js +39 -0
- package/dist/hooks/runtime/failure-policy.d.ts +15 -0
- package/dist/hooks/runtime/failure-policy.js +49 -0
- package/dist/hooks/runtime/process-executor.d.ts +33 -0
- package/dist/hooks/runtime/process-executor.js +147 -0
- package/dist/hooks/runtime/status-recorder.d.ts +27 -0
- package/dist/hooks/runtime/status-recorder.js +111 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +111 -40
- package/dist/skills/agents-md-generator/SKILL.md +223 -223
- package/dist/skills/codebase-analyzer/SKILL.md +162 -162
- package/dist/skills/codebase-analyzer/references/code-analysis.md +63 -63
- package/dist/skills/codebase-analyzer/references/combined.md +31 -31
- package/dist/skills/codebase-analyzer/references/context-discovery.md +63 -63
- package/dist/skills/codebase-analyzer/references/file-discovery.md +51 -51
- package/dist/skills/codebase-analyzer/references/migration-target.md +23 -23
- package/dist/skills/codebase-analyzer/references/pattern-mining.md +22 -22
- package/dist/skills/dev-analyze/SKILL.md +115 -115
- package/dist/skills/dev-bugfix/SKILL.md +452 -452
- package/dist/skills/dev-finalize/SKILL.md +118 -118
- package/dist/skills/dev-implement/SKILL.md +167 -167
- package/dist/skills/dev-plan/SKILL.md +147 -147
- package/dist/skills/dev-spec/SKILL.md +182 -182
- package/dist/skills/dev-tdd-red/SKILL.md +94 -94
- package/dist/skills/dev-verify/SKILL.md +153 -153
- package/dist/skills/development/SKILL.md +260 -260
- package/dist/skills/diagrams-mermaid/SKILL.md +183 -159
- package/dist/skills/diagrams-mermaid/references/reference.md +220 -148
- package/dist/skills/docs-manager/SKILL.md +379 -379
- package/dist/skills/docs-manager/docs/INDEX.md +199 -199
- package/dist/skills/docs-manager/docs/standards/backend/api.md +25 -25
- package/dist/skills/docs-manager/docs/standards/backend/migrations.md +22 -22
- package/dist/skills/docs-manager/docs/standards/backend/models.md +25 -25
- package/dist/skills/docs-manager/docs/standards/backend/queries.md +22 -22
- package/dist/skills/docs-manager/docs/standards/frontend/accessibility.md +25 -25
- package/dist/skills/docs-manager/docs/standards/frontend/components.md +28 -28
- package/dist/skills/docs-manager/docs/standards/frontend/css.md +16 -16
- package/dist/skills/docs-manager/docs/standards/frontend/responsive.md +28 -28
- package/dist/skills/docs-manager/docs/standards/global/coding-style.md +25 -25
- package/dist/skills/docs-manager/docs/standards/global/commenting.md +10 -10
- package/dist/skills/docs-manager/docs/standards/global/conventions.md +31 -31
- package/dist/skills/docs-manager/docs/standards/global/error-handling.md +22 -22
- package/dist/skills/docs-manager/docs/standards/global/minimal-implementation.md +22 -22
- package/dist/skills/docs-manager/docs/standards/global/validation.md +28 -28
- package/dist/skills/docs-manager/docs/standards/testing/test-writing.md +25 -25
- package/dist/skills/docs-manager/references/agents-md-template.md +29 -29
- package/dist/skills/docs-manager/references/index-md-template.md +73 -73
- package/dist/skills/flow-init/SKILL.md +234 -234
- package/dist/skills/flow-init/references/architecture-template.md +45 -45
- package/dist/skills/flow-init/references/roadmap-templates.md +93 -93
- package/dist/skills/flow-init/references/tech-stack-template.md +70 -70
- package/dist/skills/flow-init/references/vision-templates.md +75 -75
- package/dist/skills/goal-development/SKILL.md +96 -96
- package/dist/skills/goal-migration/SKILL.md +114 -114
- package/dist/skills/goal-performance/SKILL.md +126 -126
- package/dist/skills/goal-research/SKILL.md +118 -118
- package/dist/skills/html-renderer/SKILL.md +173 -173
- package/dist/skills/html-renderer/references/index.html +318 -318
- package/dist/skills/html-renderer/references/styles.css +388 -388
- package/dist/skills/html-renderer/references/tokens.json +104 -104
- package/dist/skills/implementation-plan-executor/SKILL.md +378 -378
- package/dist/skills/implementation-verifier/SKILL.md +307 -307
- package/dist/skills/migration/SKILL.md +268 -268
- package/dist/skills/migration-analyze/SKILL.md +126 -126
- package/dist/skills/migration-finalize/SKILL.md +161 -161
- package/dist/skills/migration-fix/SKILL.md +155 -155
- package/dist/skills/migration-implement/SKILL.md +131 -131
- package/dist/skills/migration-plan/SKILL.md +131 -131
- package/dist/skills/migration-spec/SKILL.md +135 -135
- package/dist/skills/migration-spec/references/migration-strategies.md +430 -430
- package/dist/skills/migration-target/SKILL.md +134 -134
- package/dist/skills/migration-target/references/migration-types.md +489 -489
- package/dist/skills/migration-verify/SKILL.md +184 -184
- package/dist/skills/orchestrator-framework/SKILL.md +65 -65
- package/dist/skills/orchestrator-framework/references/command-namespacing.md +7 -7
- package/dist/skills/orchestrator-framework/references/confirm-or-revise-exception.md +20 -20
- package/dist/skills/orchestrator-framework/references/delegation-rules.md +54 -54
- package/dist/skills/orchestrator-framework/references/dispatcher-handoff.md +27 -27
- package/dist/skills/orchestrator-framework/references/fix-loop-contract.md +65 -65
- package/dist/skills/orchestrator-framework/references/gate-contract.md +122 -122
- package/dist/skills/orchestrator-framework/references/orchestrator-creation-checklist.md +51 -51
- package/dist/skills/orchestrator-framework/references/orchestrator-patterns.md +235 -235
- package/dist/skills/performance/SKILL.md +267 -267
- package/dist/skills/performance-analyze/SKILL.md +129 -129
- package/dist/skills/performance-analyze/references/performance-optimization-guide.md +271 -271
- package/dist/skills/performance-finalize/SKILL.md +117 -117
- package/dist/skills/performance-implement/SKILL.md +114 -114
- package/dist/skills/performance-plan/SKILL.md +112 -112
- package/dist/skills/performance-spec/SKILL.md +145 -145
- package/dist/skills/performance-verify/SKILL.md +164 -164
- package/dist/skills/research/SKILL.md +249 -249
- package/dist/skills/research-brainstorm/SKILL.md +120 -120
- package/dist/skills/research-brainstorm/references/brainstorming-techniques.md +84 -84
- package/dist/skills/research-converge/SKILL.md +130 -130
- package/dist/skills/research-design/SKILL.md +146 -146
- package/dist/skills/research-design/references/design-techniques.md +40 -40
- package/dist/skills/research-finalize/SKILL.md +125 -125
- package/dist/skills/research-fork/SKILL.md +190 -190
- package/dist/skills/research-gather/SKILL.md +133 -133
- package/dist/skills/research-plan/SKILL.md +141 -141
- package/dist/skills/research-plan/references/research-methodologies.md +710 -710
- package/dist/skills/research-quick/SKILL.md +139 -139
- package/dist/skills/research-synthesize/SKILL.md +127 -127
- package/dist/skills/rule-reviewer/SKILL.md +334 -334
- package/dist/skills/standards-discover/SKILL.md +260 -260
- package/dist/skills/standards-discover/references/aggregation-strategy.md +76 -76
- package/dist/skills/standards-discover/references/code-pattern-prompt.md +68 -68
- package/dist/skills/standards-discover/references/config-analyzer-prompt.md +67 -67
- package/dist/skills/standards-discover/references/docs-extractor-prompt.md +65 -65
- package/dist/skills/standards-discover/references/external-analyzer-prompt.md +75 -75
- package/dist/skills/standards-update/SKILL.md +207 -207
- package/dist/templates/orchestrator-state-base.yml +17 -17
- package/dist/templates/orchestrator-state-development.yml +95 -95
- package/dist/templates/orchestrator-state-migration.yml +95 -95
- package/dist/templates/orchestrator-state-performance.yml +64 -64
- package/dist/templates/orchestrator-state-research.yml +67 -67
- package/dist/tools/fork_task.d.ts +17 -0
- package/dist/tools/fork_task.js +21 -11
- package/dist/tools/verify_template.d.ts +11 -0
- package/dist/tools/verify_template.js +32 -17
- package/dist/tui/hooks-dialogs.d.ts +20 -0
- package/dist/tui/hooks-dialogs.js +181 -0
- package/dist/tui/hooks-presenter.d.ts +15 -0
- package/dist/tui/hooks-presenter.js +70 -0
- package/dist/tui/hooks-sidebar.d.ts +10 -0
- package/dist/tui/hooks-sidebar.js +104 -0
- package/dist/tui/primitives.d.ts +21 -0
- package/dist/tui/primitives.js +47 -0
- package/dist/tui.d.ts +12 -0
- package/dist/tui.js +129 -0
- package/dist/types/hook-types.d.ts +125 -0
- package/dist/types/hook-types.js +76 -0
- package/dist/types/opencode-types.d.ts +13 -0
- package/dist/utils/file-util.d.ts +2 -0
- package/dist/utils/file-util.js +6 -6
- package/dist/utils/fork-task.d.ts +27 -0
- package/dist/utils/fork-task.js +18 -23
- package/dist/utils/plugin-info.d.ts +3 -0
- package/dist/utils/plugin-info.js +8 -10
- package/dist/utils/workflow-paths.d.ts +17 -0
- package/dist/utils/workflow-paths.js +18 -0
- package/dist/utils/yaml-structure.d.ts +7 -0
- package/dist/utils/yaml-structure.js +7 -11
- package/package.json +68 -48
- package/dist/hooks/before-tool.js +0 -19
|
@@ -1,430 +1,430 @@
|
|
|
1
|
-
# Migration Strategies Reference
|
|
2
|
-
|
|
3
|
-
> **Design Documentation**: This file serves as **design documentation** for developers and Agents implementing migration workflows. It provides conceptual patterns and decision frameworks for selecting and executing migration strategies.
|
|
4
|
-
|
|
5
|
-
**Purpose:** Pattern guide for migration execution strategies (incremental, rollback, dual-run)
|
|
6
|
-
|
|
7
|
-
This reference provides decision criteria and implementation patterns for the three core migration strategies supported by the migration workflow.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Table of Contents
|
|
12
|
-
|
|
13
|
-
1. [Overview](#overview)
|
|
14
|
-
2. [Incremental Migration](#incremental-migration)
|
|
15
|
-
3. [Rollback Planning](#rollback-planning)
|
|
16
|
-
4. [Dual-Run Strategy](#dual-run-strategy)
|
|
17
|
-
5. [Strategy Selection Decision Tree](#strategy-selection-decision-tree)
|
|
18
|
-
6. [Combined Strategies](#combined-strategies)
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Overview
|
|
23
|
-
|
|
24
|
-
Migration strategies define **how** to execute the transition from current to target state. The migration workflow supports three core strategies, which can be combined:
|
|
25
|
-
|
|
26
|
-
| Strategy | Purpose | Risk Level | Use When |
|
|
27
|
-
| --------------- | --------------------------------------- | ----------- | -------------------------------------------- |
|
|
28
|
-
| **Incremental** | Migrate piece-by-piece with checkpoints | Low-Medium | Large migrations, complex changes |
|
|
29
|
-
| **Rollback** | Plan undo procedures for each phase | Medium | Critical systems, data migrations |
|
|
30
|
-
| **Dual-Run** | Run old and new systems in parallel | Medium-High | Zero-downtime requirements, data sync needed |
|
|
31
|
-
|
|
32
|
-
### Key Principles
|
|
33
|
-
|
|
34
|
-
1. **Risk Mitigation**: Choose strategies that minimize risk for your context
|
|
35
|
-
2. **Composability**: Strategies can be combined (e.g., incremental + rollback)
|
|
36
|
-
3. **Checkpoint-Based**: All strategies emphasize verification points
|
|
37
|
-
4. **Reversibility**: Plan how to undo changes before making them
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Incremental Migration
|
|
42
|
-
|
|
43
|
-
### Concept
|
|
44
|
-
|
|
45
|
-
**Definition**: Break migration into smaller phases, complete one phase fully before starting next
|
|
46
|
-
|
|
47
|
-
**Pattern**:
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
Current State → Phase 1 → Verify → Phase 2 → Verify → Phase 3 → Verify → Target State
|
|
51
|
-
↑ ↑ ↑
|
|
52
|
-
Checkpoint Checkpoint Checkpoint
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### When to Use
|
|
56
|
-
|
|
57
|
-
**Strong Indicators**:
|
|
58
|
-
|
|
59
|
-
- Large migration scope (>50 files, >5,000 lines affected)
|
|
60
|
-
- Multiple independent subsystems to migrate
|
|
61
|
-
- Complex breaking changes requiring staged adaptation
|
|
62
|
-
- Team needs to learn new technology during migration
|
|
63
|
-
|
|
64
|
-
**Avoid If**:
|
|
65
|
-
|
|
66
|
-
- Small, isolated change (<10 files)
|
|
67
|
-
- Tight deadline requiring fast completion
|
|
68
|
-
- No logical breakpoints in migration
|
|
69
|
-
|
|
70
|
-
### Implementation Pattern
|
|
71
|
-
|
|
72
|
-
**Phase Definition**:
|
|
73
|
-
|
|
74
|
-
1. **Identify Natural Boundaries**: Modules, layers, features that can migrate independently
|
|
75
|
-
2. **Define Dependencies**: Which phases must complete before others
|
|
76
|
-
3. **Set Verification Criteria**: How to validate each phase succeeded
|
|
77
|
-
4. **Plan Checkpoints**: Git tags, deployment points, rollback triggers
|
|
78
|
-
|
|
79
|
-
**Example - Framework Migration (Vue 2 → Vue 3)**:
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
Phase 1: Core dependencies (package.json, build config)
|
|
83
|
-
↓ Verify: App still builds and runs
|
|
84
|
-
Phase 2: Shared components (buttons, forms, layouts)
|
|
85
|
-
↓ Verify: Component tests pass
|
|
86
|
-
Phase 3: Feature modules (user management, dashboard)
|
|
87
|
-
↓ Verify: Feature tests pass
|
|
88
|
-
Phase 4: Router and state management
|
|
89
|
-
↓ Verify: Navigation and data flow work
|
|
90
|
-
Phase 5: Cleanup (remove compatibility shims)
|
|
91
|
-
↓ Verify: Full test suite passes
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**Task Group Structure**:
|
|
95
|
-
|
|
96
|
-
```markdown
|
|
97
|
-
### Task Group 1: Phase 1 - Core Dependencies
|
|
98
|
-
|
|
99
|
-
- [ ] 1.1 Write tests for compatibility layer
|
|
100
|
-
- [ ] 1.2 Upgrade core packages
|
|
101
|
-
- [ ] 1.3 Update build configuration
|
|
102
|
-
- [ ] 1.4 Verify app builds and runs
|
|
103
|
-
- [ ] 1.5 Run Phase 1 checkpoint tests
|
|
104
|
-
|
|
105
|
-
### Task Group 2: Phase 2 - Shared Components
|
|
106
|
-
|
|
107
|
-
[continues with next phase after Phase 1 verified]
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Benefits
|
|
111
|
-
|
|
112
|
-
- **Lower Risk**: Problems isolated to current phase
|
|
113
|
-
- **Easy Rollback**: Revert to previous phase checkpoint
|
|
114
|
-
- **Learning Curve**: Team learns as they progress
|
|
115
|
-
- **Progress Visibility**: Clear milestones
|
|
116
|
-
|
|
117
|
-
### Challenges
|
|
118
|
-
|
|
119
|
-
- **Longer Duration**: More phases = more time
|
|
120
|
-
- **Compatibility Layers**: May need temporary bridges between old/new
|
|
121
|
-
- **Coordination**: Larger teams need phase synchronization
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Rollback Planning
|
|
126
|
-
|
|
127
|
-
### Concept
|
|
128
|
-
|
|
129
|
-
**Definition**: Document undo procedures for each migration phase before executing
|
|
130
|
-
|
|
131
|
-
**Pattern**:
|
|
132
|
-
|
|
133
|
-
```
|
|
134
|
-
Before Phase 1: Define rollback procedure
|
|
135
|
-
Execute Phase 1
|
|
136
|
-
If failure: Execute rollback procedure → Back to known good state
|
|
137
|
-
If success: Continue to Phase 2
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### When to Use
|
|
141
|
-
|
|
142
|
-
**Strong Indicators**:
|
|
143
|
-
|
|
144
|
-
- Production systems (downtime is costly)
|
|
145
|
-
- Data migrations (data loss risk)
|
|
146
|
-
- Critical business functionality
|
|
147
|
-
- Compliance/regulatory requirements
|
|
148
|
-
- First-time migration (learning experience)
|
|
149
|
-
|
|
150
|
-
**Always Use For**:
|
|
151
|
-
|
|
152
|
-
- Data migrations (required)
|
|
153
|
-
- Production deployments (required)
|
|
154
|
-
- Architecture migrations affecting multiple systems
|
|
155
|
-
|
|
156
|
-
### Implementation Pattern
|
|
157
|
-
|
|
158
|
-
**Rollback Plan Structure** (`analysis/rollback-plan.md`):
|
|
159
|
-
|
|
160
|
-
```markdown
|
|
161
|
-
# Rollback Plan: [Migration Name]
|
|
162
|
-
|
|
163
|
-
## Rollback Overview
|
|
164
|
-
|
|
165
|
-
- **Rollback Complexity**: Simple | Moderate | Complex
|
|
166
|
-
- **Data Loss Risk**: None | Minimal | Moderate | High
|
|
167
|
-
- **Rollback Time Estimate**: [minutes/hours]
|
|
168
|
-
|
|
169
|
-
## Phase 1: [Phase Name] Rollback
|
|
170
|
-
|
|
171
|
-
**Trigger**: [What indicates rollback needed]
|
|
172
|
-
**Procedure**:
|
|
173
|
-
|
|
174
|
-
1. [Undo step 1]
|
|
175
|
-
2. [Undo step 2]
|
|
176
|
-
**Verification**: [How to verify rollback succeeded]
|
|
177
|
-
**Data Recovery**: [How to restore data if modified]
|
|
178
|
-
|
|
179
|
-
## Phase 2: [Phase Name] Rollback
|
|
180
|
-
|
|
181
|
-
[Same structure for each phase]
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
**Rollback Categories**:
|
|
185
|
-
|
|
186
|
-
| Category | Example | Procedure |
|
|
187
|
-
| --------------------------- | ------------------- | ------------------------------------------- |
|
|
188
|
-
| **Code Rollback** | Framework upgrade | `git revert [commit]`, redeploy |
|
|
189
|
-
| **Data Rollback** | Schema migration | Restore from backup, revert migrations |
|
|
190
|
-
| **Config Rollback** | Environment changes | Restore old config files, restart |
|
|
191
|
-
| **Infrastructure Rollback** | Platform migration | Switch DNS back, restore old infrastructure |
|
|
192
|
-
|
|
193
|
-
**Rollback Testing Strategy**:
|
|
194
|
-
|
|
195
|
-
- **Non-Destructive Test**: Test rollback in non-prod first
|
|
196
|
-
- **Documented Steps**: Exact commands/procedures
|
|
197
|
-
- **Validation Criteria**: How to verify rollback succeeded
|
|
198
|
-
- **Time Estimate**: How long rollback takes (critical for production)
|
|
199
|
-
|
|
200
|
-
### Benefits
|
|
201
|
-
|
|
202
|
-
- **Confidence**: Knowing you can undo increases willingness to proceed
|
|
203
|
-
- **Recovery Speed**: Pre-planned procedures faster than improvised
|
|
204
|
-
- **Risk Management**: Downside risk clearly understood
|
|
205
|
-
- **Audit Trail**: Documented for compliance/retrospectives
|
|
206
|
-
|
|
207
|
-
### Challenges
|
|
208
|
-
|
|
209
|
-
- **Planning Overhead**: Requires upfront effort
|
|
210
|
-
- **Testing Rollback**: Hard to test without actually migrating
|
|
211
|
-
- **Data Rollback Complexity**: Can't always undo data changes cleanly
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## Dual-Run Strategy
|
|
216
|
-
|
|
217
|
-
### Concept
|
|
218
|
-
|
|
219
|
-
**Definition**: Run old and new systems in parallel, gradually shift traffic from old to new
|
|
220
|
-
|
|
221
|
-
**Pattern**:
|
|
222
|
-
|
|
223
|
-
```
|
|
224
|
-
Old System (100% traffic) → Dual-Run (Old + New in parallel) → New System (100% traffic)
|
|
225
|
-
↓
|
|
226
|
-
Synchronize data/state
|
|
227
|
-
Verify consistency
|
|
228
|
-
Gradual cutover (10% → 50% → 100%)
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### When to Use
|
|
232
|
-
|
|
233
|
-
**Strong Indicators**:
|
|
234
|
-
|
|
235
|
-
- Zero-downtime requirement (24/7 systems)
|
|
236
|
-
- Data migration with live writes during migration
|
|
237
|
-
- Need to compare old vs new behavior in production
|
|
238
|
-
- Large user base (gradual rollout safer)
|
|
239
|
-
- Regulatory requirement for parallel validation
|
|
240
|
-
|
|
241
|
-
**Avoid If**:
|
|
242
|
-
|
|
243
|
-
- Systems can't coexist (e.g., Vue 2 and Vue 3 in same app)
|
|
244
|
-
- Data synchronization too complex
|
|
245
|
-
- Cost of running both systems prohibitive
|
|
246
|
-
- Migration scope too small to justify overhead
|
|
247
|
-
|
|
248
|
-
### Implementation Pattern
|
|
249
|
-
|
|
250
|
-
**Dual-Run Phases**:
|
|
251
|
-
|
|
252
|
-
**Phase 1: Setup Dual Environment**
|
|
253
|
-
|
|
254
|
-
- Deploy new system alongside old
|
|
255
|
-
- Configure routing/load balancer for split traffic
|
|
256
|
-
- Set up data synchronization mechanism
|
|
257
|
-
|
|
258
|
-
**Phase 2: Shadow Mode** (new system receives traffic but doesn't affect users)
|
|
259
|
-
|
|
260
|
-
- 100% traffic to old system
|
|
261
|
-
- Duplicate writes to new system (shadow)
|
|
262
|
-
- Compare old vs new results
|
|
263
|
-
- Identify discrepancies, fix new system
|
|
264
|
-
|
|
265
|
-
**Phase 3: Gradual Cutover**
|
|
266
|
-
|
|
267
|
-
- 10% traffic → new system (monitor closely)
|
|
268
|
-
- 50% traffic → new system (A/B test)
|
|
269
|
-
- 100% traffic → new system (full cutover)
|
|
270
|
-
|
|
271
|
-
**Phase 4: Old System Decommission**
|
|
272
|
-
|
|
273
|
-
- Keep old system running for 7-30 days (rollback safety net)
|
|
274
|
-
- After validation period, decommission old system
|
|
275
|
-
|
|
276
|
-
**Dual-Run Plan Structure** (`analysis/dual-run-plan.md`):
|
|
277
|
-
|
|
278
|
-
```markdown
|
|
279
|
-
# Dual-Run Plan: [Migration Name]
|
|
280
|
-
|
|
281
|
-
## Synchronization Strategy
|
|
282
|
-
|
|
283
|
-
**Sync Direction**: Old → New | Bidirectional | New → Old
|
|
284
|
-
**Sync Mechanism**: [Database replication | Message queue | API calls]
|
|
285
|
-
**Sync Frequency**: [Real-time | Batch every X minutes]
|
|
286
|
-
**Conflict Resolution**: [Last-write-wins | Manual resolution | Application logic]
|
|
287
|
-
|
|
288
|
-
## Cutover Plan
|
|
289
|
-
|
|
290
|
-
| Phase | Old Traffic % | New Traffic % | Duration | Success Criteria |
|
|
291
|
-
| ------ | ------------- | ------------- | -------- | ------------------------------ |
|
|
292
|
-
| Shadow | 100% | 0% (shadow) | 3-7 days | No errors in new system |
|
|
293
|
-
| Pilot | 90% | 10% | 3-7 days | Error rate <0.1% in new |
|
|
294
|
-
| Ramp | 50% | 50% | 3-7 days | Performance metrics equivalent |
|
|
295
|
-
| Full | 0% | 100% | - | All users migrated |
|
|
296
|
-
|
|
297
|
-
## Monitoring
|
|
298
|
-
|
|
299
|
-
- **Key Metrics**: [Response time, error rate, data consistency]
|
|
300
|
-
- **Alerting**: [Thresholds that trigger rollback]
|
|
301
|
-
- **Comparison Dashboards**: [Old vs new side-by-side]
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
**Data Synchronization Patterns**:
|
|
305
|
-
|
|
306
|
-
| Pattern | Description | Use When |
|
|
307
|
-
| ------------------------------- | ---------------------------------------------- | ----------------------------------------------- |
|
|
308
|
-
| **Write-Through** | Writes go to both old and new | Gradual migration, data validation |
|
|
309
|
-
| **Replication** | Database-level replication (one-way) | Read-heavy systems, database migrations |
|
|
310
|
-
| **Event Streaming** | Publish changes to message queue, both consume | Event-driven architectures |
|
|
311
|
-
| **Dual-Write + Reconciliation** | Write to both, periodic reconciliation job | Complex data models, conflict resolution needed |
|
|
312
|
-
|
|
313
|
-
### Benefits
|
|
314
|
-
|
|
315
|
-
- **Zero Downtime**: Users never experience outage
|
|
316
|
-
- **Gradual Validation**: Catch issues with small % of traffic first
|
|
317
|
-
- **Easy Rollback**: Just shift traffic back to old system
|
|
318
|
-
- **Real-World Testing**: Test new system with actual production load
|
|
319
|
-
|
|
320
|
-
### Challenges
|
|
321
|
-
|
|
322
|
-
- **Complexity**: Running two systems is operationally complex
|
|
323
|
-
- **Cost**: Double infrastructure during migration period
|
|
324
|
-
- **Data Consistency**: Synchronization bugs can cause data issues
|
|
325
|
-
- **Monitoring Overhead**: Need to watch both systems simultaneously
|
|
326
|
-
|
|
327
|
-
---
|
|
328
|
-
|
|
329
|
-
## Strategy Selection Decision Tree
|
|
330
|
-
|
|
331
|
-
Use this decision tree to select appropriate strategies:
|
|
332
|
-
|
|
333
|
-
```
|
|
334
|
-
START: What's the migration scope?
|
|
335
|
-
│
|
|
336
|
-
├─ Small (<10 files, <1 day effort)
|
|
337
|
-
│ └─ Strategy: Big-Bang (single phase, direct migration)
|
|
338
|
-
│
|
|
339
|
-
├─ Medium (10-50 files, 2-5 days effort)
|
|
340
|
-
│ └─ Is system critical?
|
|
341
|
-
│ ├─ Yes → Incremental + Rollback
|
|
342
|
-
│ └─ No → Incremental only
|
|
343
|
-
│
|
|
344
|
-
└─ Large (>50 files, >5 days effort)
|
|
345
|
-
└─ Can system tolerate downtime?
|
|
346
|
-
├─ Yes → Incremental + Rollback
|
|
347
|
-
└─ No → Incremental + Rollback + Dual-Run
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
**Special Cases**:
|
|
351
|
-
|
|
352
|
-
- **Data Migration**: Always use Rollback + Dual-Run (if possible)
|
|
353
|
-
- **First-Time Team Migration**: Use Incremental (learning curve)
|
|
354
|
-
- **Architecture Migration**: Consider Dual-Run (old/new systems coexist)
|
|
355
|
-
- **Breaking Changes**: Use Incremental (adapt gradually)
|
|
356
|
-
|
|
357
|
-
---
|
|
358
|
-
|
|
359
|
-
## Combined Strategies
|
|
360
|
-
|
|
361
|
-
### Common Combinations
|
|
362
|
-
|
|
363
|
-
**Incremental + Rollback** (Most Common):
|
|
364
|
-
|
|
365
|
-
- Break into phases (Incremental)
|
|
366
|
-
- Document rollback for each phase (Rollback)
|
|
367
|
-
- Use for: Most medium-large migrations
|
|
368
|
-
|
|
369
|
-
**Incremental + Rollback + Dual-Run** (Maximum Safety):
|
|
370
|
-
|
|
371
|
-
- Break into phases (Incremental)
|
|
372
|
-
- Document rollback (Rollback)
|
|
373
|
-
- Run old/new in parallel (Dual-Run)
|
|
374
|
-
- Use for: Critical systems, data migrations, zero-downtime requirements
|
|
375
|
-
|
|
376
|
-
**Example - Database Migration (MySQL → PostgreSQL)**:
|
|
377
|
-
|
|
378
|
-
```
|
|
379
|
-
Strategy: Incremental + Rollback + Dual-Run
|
|
380
|
-
|
|
381
|
-
Phase 1: Setup PostgreSQL + Replication
|
|
382
|
-
Rollback: Drop PostgreSQL instance, stop replication
|
|
383
|
-
Dual-Run: MySQL (primary), PostgreSQL (replica)
|
|
384
|
-
|
|
385
|
-
Phase 2: Dual-Write Mode
|
|
386
|
-
Rollback: Stop writes to PostgreSQL, keep MySQL only
|
|
387
|
-
Dual-Run: Write to both, read from MySQL
|
|
388
|
-
|
|
389
|
-
Phase 3: Shadow Read Mode
|
|
390
|
-
Rollback: Revert read queries to MySQL only
|
|
391
|
-
Dual-Run: Write to both, read from PostgreSQL (shadow)
|
|
392
|
-
|
|
393
|
-
Phase 4: Cutover
|
|
394
|
-
Rollback: Switch connection strings back to MySQL
|
|
395
|
-
Dual-Run: Write to both, read from PostgreSQL (primary)
|
|
396
|
-
|
|
397
|
-
Phase 5: Decommission MySQL
|
|
398
|
-
Rollback: Re-activate MySQL, switch back
|
|
399
|
-
Dual-Run: PostgreSQL only (MySQL kept for 30 days)
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
### Strategy Complexity Matrix
|
|
403
|
-
|
|
404
|
-
| Combination | Complexity | Duration Overhead | Risk Reduction |
|
|
405
|
-
| --------------------------------- | ---------- | ----------------- | -------------- |
|
|
406
|
-
| Incremental only | Low | +20-40% | Medium |
|
|
407
|
-
| Incremental + Rollback | Medium | +30-50% | High |
|
|
408
|
-
| Incremental + Dual-Run | High | +50-80% | High |
|
|
409
|
-
| Incremental + Rollback + Dual-Run | Very High | +80-120% | Very High |
|
|
410
|
-
|
|
411
|
-
**Guidance**: Choose simplest strategy that adequately mitigates your risks. Over-engineering increases complexity without proportional benefit.
|
|
412
|
-
|
|
413
|
-
---
|
|
414
|
-
|
|
415
|
-
## Summary
|
|
416
|
-
|
|
417
|
-
**Key Takeaways**:
|
|
418
|
-
|
|
419
|
-
1. **Incremental** = Lower risk through phased execution
|
|
420
|
-
2. **Rollback** = Safety net for critical systems
|
|
421
|
-
3. **Dual-Run** = Zero downtime for live systems
|
|
422
|
-
4. **Combine strategies** based on risk, scope, and requirements
|
|
423
|
-
5. **Document procedures** before executing migration
|
|
424
|
-
|
|
425
|
-
**Read by**:
|
|
426
|
-
|
|
427
|
-
- `migration-spec`: select the migration strategy and produce the rollback/dual-run plans
|
|
428
|
-
- `migration-plan`: structure the implementation plan by strategy (per-task-group rollback steps)
|
|
429
|
-
- `migration-implement`: execute according to the selected strategy
|
|
430
|
-
- `migration-verify`: test rollback procedures non-destructively and run the compatibility checks
|
|
1
|
+
# Migration Strategies Reference
|
|
2
|
+
|
|
3
|
+
> **Design Documentation**: This file serves as **design documentation** for developers and Agents implementing migration workflows. It provides conceptual patterns and decision frameworks for selecting and executing migration strategies.
|
|
4
|
+
|
|
5
|
+
**Purpose:** Pattern guide for migration execution strategies (incremental, rollback, dual-run)
|
|
6
|
+
|
|
7
|
+
This reference provides decision criteria and implementation patterns for the three core migration strategies supported by the migration workflow.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
1. [Overview](#overview)
|
|
14
|
+
2. [Incremental Migration](#incremental-migration)
|
|
15
|
+
3. [Rollback Planning](#rollback-planning)
|
|
16
|
+
4. [Dual-Run Strategy](#dual-run-strategy)
|
|
17
|
+
5. [Strategy Selection Decision Tree](#strategy-selection-decision-tree)
|
|
18
|
+
6. [Combined Strategies](#combined-strategies)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
Migration strategies define **how** to execute the transition from current to target state. The migration workflow supports three core strategies, which can be combined:
|
|
25
|
+
|
|
26
|
+
| Strategy | Purpose | Risk Level | Use When |
|
|
27
|
+
| --------------- | --------------------------------------- | ----------- | -------------------------------------------- |
|
|
28
|
+
| **Incremental** | Migrate piece-by-piece with checkpoints | Low-Medium | Large migrations, complex changes |
|
|
29
|
+
| **Rollback** | Plan undo procedures for each phase | Medium | Critical systems, data migrations |
|
|
30
|
+
| **Dual-Run** | Run old and new systems in parallel | Medium-High | Zero-downtime requirements, data sync needed |
|
|
31
|
+
|
|
32
|
+
### Key Principles
|
|
33
|
+
|
|
34
|
+
1. **Risk Mitigation**: Choose strategies that minimize risk for your context
|
|
35
|
+
2. **Composability**: Strategies can be combined (e.g., incremental + rollback)
|
|
36
|
+
3. **Checkpoint-Based**: All strategies emphasize verification points
|
|
37
|
+
4. **Reversibility**: Plan how to undo changes before making them
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Incremental Migration
|
|
42
|
+
|
|
43
|
+
### Concept
|
|
44
|
+
|
|
45
|
+
**Definition**: Break migration into smaller phases, complete one phase fully before starting next
|
|
46
|
+
|
|
47
|
+
**Pattern**:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Current State → Phase 1 → Verify → Phase 2 → Verify → Phase 3 → Verify → Target State
|
|
51
|
+
↑ ↑ ↑
|
|
52
|
+
Checkpoint Checkpoint Checkpoint
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### When to Use
|
|
56
|
+
|
|
57
|
+
**Strong Indicators**:
|
|
58
|
+
|
|
59
|
+
- Large migration scope (>50 files, >5,000 lines affected)
|
|
60
|
+
- Multiple independent subsystems to migrate
|
|
61
|
+
- Complex breaking changes requiring staged adaptation
|
|
62
|
+
- Team needs to learn new technology during migration
|
|
63
|
+
|
|
64
|
+
**Avoid If**:
|
|
65
|
+
|
|
66
|
+
- Small, isolated change (<10 files)
|
|
67
|
+
- Tight deadline requiring fast completion
|
|
68
|
+
- No logical breakpoints in migration
|
|
69
|
+
|
|
70
|
+
### Implementation Pattern
|
|
71
|
+
|
|
72
|
+
**Phase Definition**:
|
|
73
|
+
|
|
74
|
+
1. **Identify Natural Boundaries**: Modules, layers, features that can migrate independently
|
|
75
|
+
2. **Define Dependencies**: Which phases must complete before others
|
|
76
|
+
3. **Set Verification Criteria**: How to validate each phase succeeded
|
|
77
|
+
4. **Plan Checkpoints**: Git tags, deployment points, rollback triggers
|
|
78
|
+
|
|
79
|
+
**Example - Framework Migration (Vue 2 → Vue 3)**:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
Phase 1: Core dependencies (package.json, build config)
|
|
83
|
+
↓ Verify: App still builds and runs
|
|
84
|
+
Phase 2: Shared components (buttons, forms, layouts)
|
|
85
|
+
↓ Verify: Component tests pass
|
|
86
|
+
Phase 3: Feature modules (user management, dashboard)
|
|
87
|
+
↓ Verify: Feature tests pass
|
|
88
|
+
Phase 4: Router and state management
|
|
89
|
+
↓ Verify: Navigation and data flow work
|
|
90
|
+
Phase 5: Cleanup (remove compatibility shims)
|
|
91
|
+
↓ Verify: Full test suite passes
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Task Group Structure**:
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
### Task Group 1: Phase 1 - Core Dependencies
|
|
98
|
+
|
|
99
|
+
- [ ] 1.1 Write tests for compatibility layer
|
|
100
|
+
- [ ] 1.2 Upgrade core packages
|
|
101
|
+
- [ ] 1.3 Update build configuration
|
|
102
|
+
- [ ] 1.4 Verify app builds and runs
|
|
103
|
+
- [ ] 1.5 Run Phase 1 checkpoint tests
|
|
104
|
+
|
|
105
|
+
### Task Group 2: Phase 2 - Shared Components
|
|
106
|
+
|
|
107
|
+
[continues with next phase after Phase 1 verified]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Benefits
|
|
111
|
+
|
|
112
|
+
- **Lower Risk**: Problems isolated to current phase
|
|
113
|
+
- **Easy Rollback**: Revert to previous phase checkpoint
|
|
114
|
+
- **Learning Curve**: Team learns as they progress
|
|
115
|
+
- **Progress Visibility**: Clear milestones
|
|
116
|
+
|
|
117
|
+
### Challenges
|
|
118
|
+
|
|
119
|
+
- **Longer Duration**: More phases = more time
|
|
120
|
+
- **Compatibility Layers**: May need temporary bridges between old/new
|
|
121
|
+
- **Coordination**: Larger teams need phase synchronization
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Rollback Planning
|
|
126
|
+
|
|
127
|
+
### Concept
|
|
128
|
+
|
|
129
|
+
**Definition**: Document undo procedures for each migration phase before executing
|
|
130
|
+
|
|
131
|
+
**Pattern**:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
Before Phase 1: Define rollback procedure
|
|
135
|
+
Execute Phase 1
|
|
136
|
+
If failure: Execute rollback procedure → Back to known good state
|
|
137
|
+
If success: Continue to Phase 2
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### When to Use
|
|
141
|
+
|
|
142
|
+
**Strong Indicators**:
|
|
143
|
+
|
|
144
|
+
- Production systems (downtime is costly)
|
|
145
|
+
- Data migrations (data loss risk)
|
|
146
|
+
- Critical business functionality
|
|
147
|
+
- Compliance/regulatory requirements
|
|
148
|
+
- First-time migration (learning experience)
|
|
149
|
+
|
|
150
|
+
**Always Use For**:
|
|
151
|
+
|
|
152
|
+
- Data migrations (required)
|
|
153
|
+
- Production deployments (required)
|
|
154
|
+
- Architecture migrations affecting multiple systems
|
|
155
|
+
|
|
156
|
+
### Implementation Pattern
|
|
157
|
+
|
|
158
|
+
**Rollback Plan Structure** (`analysis/rollback-plan.md`):
|
|
159
|
+
|
|
160
|
+
```markdown
|
|
161
|
+
# Rollback Plan: [Migration Name]
|
|
162
|
+
|
|
163
|
+
## Rollback Overview
|
|
164
|
+
|
|
165
|
+
- **Rollback Complexity**: Simple | Moderate | Complex
|
|
166
|
+
- **Data Loss Risk**: None | Minimal | Moderate | High
|
|
167
|
+
- **Rollback Time Estimate**: [minutes/hours]
|
|
168
|
+
|
|
169
|
+
## Phase 1: [Phase Name] Rollback
|
|
170
|
+
|
|
171
|
+
**Trigger**: [What indicates rollback needed]
|
|
172
|
+
**Procedure**:
|
|
173
|
+
|
|
174
|
+
1. [Undo step 1]
|
|
175
|
+
2. [Undo step 2]
|
|
176
|
+
**Verification**: [How to verify rollback succeeded]
|
|
177
|
+
**Data Recovery**: [How to restore data if modified]
|
|
178
|
+
|
|
179
|
+
## Phase 2: [Phase Name] Rollback
|
|
180
|
+
|
|
181
|
+
[Same structure for each phase]
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Rollback Categories**:
|
|
185
|
+
|
|
186
|
+
| Category | Example | Procedure |
|
|
187
|
+
| --------------------------- | ------------------- | ------------------------------------------- |
|
|
188
|
+
| **Code Rollback** | Framework upgrade | `git revert [commit]`, redeploy |
|
|
189
|
+
| **Data Rollback** | Schema migration | Restore from backup, revert migrations |
|
|
190
|
+
| **Config Rollback** | Environment changes | Restore old config files, restart |
|
|
191
|
+
| **Infrastructure Rollback** | Platform migration | Switch DNS back, restore old infrastructure |
|
|
192
|
+
|
|
193
|
+
**Rollback Testing Strategy**:
|
|
194
|
+
|
|
195
|
+
- **Non-Destructive Test**: Test rollback in non-prod first
|
|
196
|
+
- **Documented Steps**: Exact commands/procedures
|
|
197
|
+
- **Validation Criteria**: How to verify rollback succeeded
|
|
198
|
+
- **Time Estimate**: How long rollback takes (critical for production)
|
|
199
|
+
|
|
200
|
+
### Benefits
|
|
201
|
+
|
|
202
|
+
- **Confidence**: Knowing you can undo increases willingness to proceed
|
|
203
|
+
- **Recovery Speed**: Pre-planned procedures faster than improvised
|
|
204
|
+
- **Risk Management**: Downside risk clearly understood
|
|
205
|
+
- **Audit Trail**: Documented for compliance/retrospectives
|
|
206
|
+
|
|
207
|
+
### Challenges
|
|
208
|
+
|
|
209
|
+
- **Planning Overhead**: Requires upfront effort
|
|
210
|
+
- **Testing Rollback**: Hard to test without actually migrating
|
|
211
|
+
- **Data Rollback Complexity**: Can't always undo data changes cleanly
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Dual-Run Strategy
|
|
216
|
+
|
|
217
|
+
### Concept
|
|
218
|
+
|
|
219
|
+
**Definition**: Run old and new systems in parallel, gradually shift traffic from old to new
|
|
220
|
+
|
|
221
|
+
**Pattern**:
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
Old System (100% traffic) → Dual-Run (Old + New in parallel) → New System (100% traffic)
|
|
225
|
+
↓
|
|
226
|
+
Synchronize data/state
|
|
227
|
+
Verify consistency
|
|
228
|
+
Gradual cutover (10% → 50% → 100%)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### When to Use
|
|
232
|
+
|
|
233
|
+
**Strong Indicators**:
|
|
234
|
+
|
|
235
|
+
- Zero-downtime requirement (24/7 systems)
|
|
236
|
+
- Data migration with live writes during migration
|
|
237
|
+
- Need to compare old vs new behavior in production
|
|
238
|
+
- Large user base (gradual rollout safer)
|
|
239
|
+
- Regulatory requirement for parallel validation
|
|
240
|
+
|
|
241
|
+
**Avoid If**:
|
|
242
|
+
|
|
243
|
+
- Systems can't coexist (e.g., Vue 2 and Vue 3 in same app)
|
|
244
|
+
- Data synchronization too complex
|
|
245
|
+
- Cost of running both systems prohibitive
|
|
246
|
+
- Migration scope too small to justify overhead
|
|
247
|
+
|
|
248
|
+
### Implementation Pattern
|
|
249
|
+
|
|
250
|
+
**Dual-Run Phases**:
|
|
251
|
+
|
|
252
|
+
**Phase 1: Setup Dual Environment**
|
|
253
|
+
|
|
254
|
+
- Deploy new system alongside old
|
|
255
|
+
- Configure routing/load balancer for split traffic
|
|
256
|
+
- Set up data synchronization mechanism
|
|
257
|
+
|
|
258
|
+
**Phase 2: Shadow Mode** (new system receives traffic but doesn't affect users)
|
|
259
|
+
|
|
260
|
+
- 100% traffic to old system
|
|
261
|
+
- Duplicate writes to new system (shadow)
|
|
262
|
+
- Compare old vs new results
|
|
263
|
+
- Identify discrepancies, fix new system
|
|
264
|
+
|
|
265
|
+
**Phase 3: Gradual Cutover**
|
|
266
|
+
|
|
267
|
+
- 10% traffic → new system (monitor closely)
|
|
268
|
+
- 50% traffic → new system (A/B test)
|
|
269
|
+
- 100% traffic → new system (full cutover)
|
|
270
|
+
|
|
271
|
+
**Phase 4: Old System Decommission**
|
|
272
|
+
|
|
273
|
+
- Keep old system running for 7-30 days (rollback safety net)
|
|
274
|
+
- After validation period, decommission old system
|
|
275
|
+
|
|
276
|
+
**Dual-Run Plan Structure** (`analysis/dual-run-plan.md`):
|
|
277
|
+
|
|
278
|
+
```markdown
|
|
279
|
+
# Dual-Run Plan: [Migration Name]
|
|
280
|
+
|
|
281
|
+
## Synchronization Strategy
|
|
282
|
+
|
|
283
|
+
**Sync Direction**: Old → New | Bidirectional | New → Old
|
|
284
|
+
**Sync Mechanism**: [Database replication | Message queue | API calls]
|
|
285
|
+
**Sync Frequency**: [Real-time | Batch every X minutes]
|
|
286
|
+
**Conflict Resolution**: [Last-write-wins | Manual resolution | Application logic]
|
|
287
|
+
|
|
288
|
+
## Cutover Plan
|
|
289
|
+
|
|
290
|
+
| Phase | Old Traffic % | New Traffic % | Duration | Success Criteria |
|
|
291
|
+
| ------ | ------------- | ------------- | -------- | ------------------------------ |
|
|
292
|
+
| Shadow | 100% | 0% (shadow) | 3-7 days | No errors in new system |
|
|
293
|
+
| Pilot | 90% | 10% | 3-7 days | Error rate <0.1% in new |
|
|
294
|
+
| Ramp | 50% | 50% | 3-7 days | Performance metrics equivalent |
|
|
295
|
+
| Full | 0% | 100% | - | All users migrated |
|
|
296
|
+
|
|
297
|
+
## Monitoring
|
|
298
|
+
|
|
299
|
+
- **Key Metrics**: [Response time, error rate, data consistency]
|
|
300
|
+
- **Alerting**: [Thresholds that trigger rollback]
|
|
301
|
+
- **Comparison Dashboards**: [Old vs new side-by-side]
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Data Synchronization Patterns**:
|
|
305
|
+
|
|
306
|
+
| Pattern | Description | Use When |
|
|
307
|
+
| ------------------------------- | ---------------------------------------------- | ----------------------------------------------- |
|
|
308
|
+
| **Write-Through** | Writes go to both old and new | Gradual migration, data validation |
|
|
309
|
+
| **Replication** | Database-level replication (one-way) | Read-heavy systems, database migrations |
|
|
310
|
+
| **Event Streaming** | Publish changes to message queue, both consume | Event-driven architectures |
|
|
311
|
+
| **Dual-Write + Reconciliation** | Write to both, periodic reconciliation job | Complex data models, conflict resolution needed |
|
|
312
|
+
|
|
313
|
+
### Benefits
|
|
314
|
+
|
|
315
|
+
- **Zero Downtime**: Users never experience outage
|
|
316
|
+
- **Gradual Validation**: Catch issues with small % of traffic first
|
|
317
|
+
- **Easy Rollback**: Just shift traffic back to old system
|
|
318
|
+
- **Real-World Testing**: Test new system with actual production load
|
|
319
|
+
|
|
320
|
+
### Challenges
|
|
321
|
+
|
|
322
|
+
- **Complexity**: Running two systems is operationally complex
|
|
323
|
+
- **Cost**: Double infrastructure during migration period
|
|
324
|
+
- **Data Consistency**: Synchronization bugs can cause data issues
|
|
325
|
+
- **Monitoring Overhead**: Need to watch both systems simultaneously
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Strategy Selection Decision Tree
|
|
330
|
+
|
|
331
|
+
Use this decision tree to select appropriate strategies:
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
START: What's the migration scope?
|
|
335
|
+
│
|
|
336
|
+
├─ Small (<10 files, <1 day effort)
|
|
337
|
+
│ └─ Strategy: Big-Bang (single phase, direct migration)
|
|
338
|
+
│
|
|
339
|
+
├─ Medium (10-50 files, 2-5 days effort)
|
|
340
|
+
│ └─ Is system critical?
|
|
341
|
+
│ ├─ Yes → Incremental + Rollback
|
|
342
|
+
│ └─ No → Incremental only
|
|
343
|
+
│
|
|
344
|
+
└─ Large (>50 files, >5 days effort)
|
|
345
|
+
└─ Can system tolerate downtime?
|
|
346
|
+
├─ Yes → Incremental + Rollback
|
|
347
|
+
└─ No → Incremental + Rollback + Dual-Run
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**Special Cases**:
|
|
351
|
+
|
|
352
|
+
- **Data Migration**: Always use Rollback + Dual-Run (if possible)
|
|
353
|
+
- **First-Time Team Migration**: Use Incremental (learning curve)
|
|
354
|
+
- **Architecture Migration**: Consider Dual-Run (old/new systems coexist)
|
|
355
|
+
- **Breaking Changes**: Use Incremental (adapt gradually)
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## Combined Strategies
|
|
360
|
+
|
|
361
|
+
### Common Combinations
|
|
362
|
+
|
|
363
|
+
**Incremental + Rollback** (Most Common):
|
|
364
|
+
|
|
365
|
+
- Break into phases (Incremental)
|
|
366
|
+
- Document rollback for each phase (Rollback)
|
|
367
|
+
- Use for: Most medium-large migrations
|
|
368
|
+
|
|
369
|
+
**Incremental + Rollback + Dual-Run** (Maximum Safety):
|
|
370
|
+
|
|
371
|
+
- Break into phases (Incremental)
|
|
372
|
+
- Document rollback (Rollback)
|
|
373
|
+
- Run old/new in parallel (Dual-Run)
|
|
374
|
+
- Use for: Critical systems, data migrations, zero-downtime requirements
|
|
375
|
+
|
|
376
|
+
**Example - Database Migration (MySQL → PostgreSQL)**:
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
Strategy: Incremental + Rollback + Dual-Run
|
|
380
|
+
|
|
381
|
+
Phase 1: Setup PostgreSQL + Replication
|
|
382
|
+
Rollback: Drop PostgreSQL instance, stop replication
|
|
383
|
+
Dual-Run: MySQL (primary), PostgreSQL (replica)
|
|
384
|
+
|
|
385
|
+
Phase 2: Dual-Write Mode
|
|
386
|
+
Rollback: Stop writes to PostgreSQL, keep MySQL only
|
|
387
|
+
Dual-Run: Write to both, read from MySQL
|
|
388
|
+
|
|
389
|
+
Phase 3: Shadow Read Mode
|
|
390
|
+
Rollback: Revert read queries to MySQL only
|
|
391
|
+
Dual-Run: Write to both, read from PostgreSQL (shadow)
|
|
392
|
+
|
|
393
|
+
Phase 4: Cutover
|
|
394
|
+
Rollback: Switch connection strings back to MySQL
|
|
395
|
+
Dual-Run: Write to both, read from PostgreSQL (primary)
|
|
396
|
+
|
|
397
|
+
Phase 5: Decommission MySQL
|
|
398
|
+
Rollback: Re-activate MySQL, switch back
|
|
399
|
+
Dual-Run: PostgreSQL only (MySQL kept for 30 days)
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Strategy Complexity Matrix
|
|
403
|
+
|
|
404
|
+
| Combination | Complexity | Duration Overhead | Risk Reduction |
|
|
405
|
+
| --------------------------------- | ---------- | ----------------- | -------------- |
|
|
406
|
+
| Incremental only | Low | +20-40% | Medium |
|
|
407
|
+
| Incremental + Rollback | Medium | +30-50% | High |
|
|
408
|
+
| Incremental + Dual-Run | High | +50-80% | High |
|
|
409
|
+
| Incremental + Rollback + Dual-Run | Very High | +80-120% | Very High |
|
|
410
|
+
|
|
411
|
+
**Guidance**: Choose simplest strategy that adequately mitigates your risks. Over-engineering increases complexity without proportional benefit.
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## Summary
|
|
416
|
+
|
|
417
|
+
**Key Takeaways**:
|
|
418
|
+
|
|
419
|
+
1. **Incremental** = Lower risk through phased execution
|
|
420
|
+
2. **Rollback** = Safety net for critical systems
|
|
421
|
+
3. **Dual-Run** = Zero downtime for live systems
|
|
422
|
+
4. **Combine strategies** based on risk, scope, and requirements
|
|
423
|
+
5. **Document procedures** before executing migration
|
|
424
|
+
|
|
425
|
+
**Read by**:
|
|
426
|
+
|
|
427
|
+
- `migration-spec`: select the migration strategy and produce the rollback/dual-run plans
|
|
428
|
+
- `migration-plan`: structure the implementation plan by strategy (per-task-group rollback steps)
|
|
429
|
+
- `migration-implement`: execute according to the selected strategy
|
|
430
|
+
- `migration-verify`: test rollback procedures non-destructively and run the compatibility checks
|