|
| 1 | +--- |
| 2 | +status: planned |
| 3 | +created: '2025-11-28' |
| 4 | +tags: |
| 5 | + - cli |
| 6 | + - migration |
| 7 | + - dx |
| 8 | + - performance |
| 9 | +priority: high |
| 10 | +created_at: '2025-11-28T01:21:44.679Z' |
| 11 | +updated_at: '2025-11-28T01:24:56.701Z' |
| 12 | +related: |
| 13 | + - 047-git-backfill-timestamps |
| 14 | +--- |
| 15 | + |
| 16 | +# Constant-Time Migration (O(1) UX) |
| 17 | + |
| 18 | +> **Status**: 🗓️ Planned · **Priority**: High · **Created**: 2025-11-28 · **Tags**: cli, migration, dx, performance |
| 19 | +
|
| 20 | +**Project**: lean-spec |
| 21 | +**Team**: Core Development |
| 22 | + |
| 23 | +## Overview |
| 24 | + |
| 25 | +Migration time should NOT scale with the number of existing specs. Whether you have 10 or 1000 specs, the migration experience should feel instant. |
| 26 | + |
| 27 | +**Problem**: Current migration process is O(n) where n = number of specs. The time estimates table shows linear scaling (100 specs = 3x time of 20 specs). This is unacceptable for larger projects. |
| 28 | + |
| 29 | +**Goal**: Achieve O(1) *perceived* migration time regardless of spec count. |
| 30 | + |
| 31 | +## Problem Analysis |
| 32 | + |
| 33 | +### Current Pain Points |
| 34 | + |
| 35 | +1. **Manual folder restructuring** - Each spec requires individual attention |
| 36 | +2. **Sequential renaming** - `spec.md → README.md` one by one |
| 37 | +3. **Backfill is already fast** - This scales well via git operations |
| 38 | +4. **Validation per-spec** - Must check each spec individually |
| 39 | + |
| 40 | +### Why O(n) Is Bad for AI Era |
| 41 | + |
| 42 | +- AI agents work in parallel, shouldn't wait for migrations |
| 43 | +- Large projects shouldn't be punished |
| 44 | +- Migration should be "invisible" - just works |
| 45 | + |
| 46 | +## Design |
| 47 | + |
| 48 | +### Strategy: Batch Everything, Parallelize, Cache |
| 49 | + |
| 50 | +**Phase 1: One-Shot Folder Transform** |
| 51 | +```bash |
| 52 | +lean-spec migrate ./source --auto |
| 53 | +``` |
| 54 | + |
| 55 | +This single command should: |
| 56 | +1. Auto-detect source format (spec-kit, OpenSpec, generic markdown) |
| 57 | +2. Bulk rename/restructure in one pass (using filesystem batch ops) |
| 58 | +3. Run backfill in parallel across all specs |
| 59 | +4. Validate all at once (not per-spec) |
| 60 | + |
| 61 | +**Phase 2: AI-Assisted Instant Migration** |
| 62 | + |
| 63 | +For any source format, generate a single AI prompt that handles ALL specs at once: |
| 64 | +```bash |
| 65 | +lean-spec migrate ./source --ai |
| 66 | +``` |
| 67 | + |
| 68 | +Outputs a comprehensive migration script that the AI executes in one shot. |
| 69 | + |
| 70 | +**Phase 3: Zero-Touch Migration** |
| 71 | + |
| 72 | +Ideal future state: |
| 73 | +```bash |
| 74 | +lean-spec init # Detects existing specs anywhere, migrates automatically |
| 75 | +``` |
| 76 | + |
| 77 | +### Key Insight |
| 78 | + |
| 79 | +**Don't process specs one-by-one. Process the entire specs directory as a single unit.** |
| 80 | + |
| 81 | +- Batch `mv` operations via shell |
| 82 | +- Parallel `git log` queries (already supported) |
| 83 | +- Single-pass validation with aggregated results |
| 84 | + |
| 85 | +## Plan |
| 86 | + |
| 87 | +- [ ] Audit current migration bottlenecks (profile with 100+ specs) |
| 88 | +- [ ] Implement batch folder restructure (`migrate --auto`) |
| 89 | +- [ ] Add auto-detection for source formats |
| 90 | +- [ ] Parallelize backfill across specs |
| 91 | +- [ ] Update `validate` to batch mode |
| 92 | +- [ ] Update docs to show single-command migration |
| 93 | +- [ ] Remove per-spec time estimates (irrelevant if instant) |
| 94 | + |
| 95 | +## Test |
| 96 | + |
| 97 | +- [ ] Migration of 100 specs completes in < 30 seconds |
| 98 | +- [ ] Migration of 500 specs completes in < 60 seconds |
| 99 | +- [ ] Time increase from 100 → 500 specs is < 2x (not 5x) |
| 100 | +- [ ] Single command handles entire migration |
| 101 | + |
| 102 | +## Success Metrics |
| 103 | + |
| 104 | +| Spec Count | Current Time | Target Time | |
| 105 | +|------------|--------------|-------------| |
| 106 | +| 20 | 5-30 min | < 30 sec | |
| 107 | +| 100 | 15-60 min | < 30 sec | |
| 108 | +| 500 | hours | < 60 sec | |
| 109 | + |
| 110 | +## Notes |
| 111 | + |
| 112 | +Related: [063-migration-from-existing-tools](../063-migration-from-existing-tools) - original migration design |
| 113 | +Related: [047-git-backfill-timestamps](../047-git-backfill-timestamps) - backfill command (already performant) |
0 commit comments