|
| 1 | +# Runtime Crash Recovery Implementation Plan |
| 2 | + |
| 3 | +> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. |
| 4 | +
|
| 5 | +**Goal:** Improve runtime/proxy recovery by adding explicit operator guidance in `hack doctor` and richer, self-explanatory artifacts in `hack crash-capture`. |
| 6 | + |
| 7 | +**Architecture:** Keep the existing diagnostics commands, but add shared recovery diagnosis helpers that classify failures into restart, repair, and follow-up buckets. Use those helpers to render a recovery panel in `hack doctor` and to write `summary.json` and `README.txt` inside crash bundles. |
| 8 | + |
| 9 | +**Tech Stack:** Bun, TypeScript, Bun test, existing CLI display helpers |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +### Task 1: Add failing tests for doctor recovery guidance |
| 14 | + |
| 15 | +**Files:** |
| 16 | +- Create: `tests/doctor-command.test.ts` |
| 17 | +- Modify: `src/commands/doctor.ts` |
| 18 | + |
| 19 | +**Step 1: Write the failing test** |
| 20 | + |
| 21 | +Add focused tests for recovery diagnosis such as: |
| 22 | +- proxy/global runtime down suggests `hack global up` |
| 23 | +- stale host mapping suggests `hack restart` |
| 24 | +- DNS/network drift suggests `hack doctor --fix` |
| 25 | +- stale daemon state suggests the daemon restart path |
| 26 | + |
| 27 | +**Step 2: Run test to verify it fails** |
| 28 | + |
| 29 | +Run: |
| 30 | +```bash |
| 31 | +bun test tests/doctor-command.test.ts |
| 32 | +``` |
| 33 | + |
| 34 | +Expected: FAIL because the exported diagnosis helpers do not exist yet. |
| 35 | + |
| 36 | +**Step 3: Write minimal implementation** |
| 37 | + |
| 38 | +Export the smallest helper surface needed to classify check results and render ordered recovery actions. |
| 39 | + |
| 40 | +**Step 4: Run test to verify it passes** |
| 41 | + |
| 42 | +Run: |
| 43 | +```bash |
| 44 | +bun test tests/doctor-command.test.ts |
| 45 | +``` |
| 46 | + |
| 47 | +Expected: PASS |
| 48 | + |
| 49 | +**Step 5: Commit** |
| 50 | + |
| 51 | +```bash |
| 52 | +git add src/commands/doctor.ts tests/doctor-command.test.ts |
| 53 | +git commit -m "test: cover doctor recovery guidance" |
| 54 | +``` |
| 55 | + |
| 56 | +### Task 2: Add failing tests for crash bundle summaries |
| 57 | + |
| 58 | +**Files:** |
| 59 | +- Create: `tests/crash-capture.test.ts` |
| 60 | +- Modify: `src/commands/crash-capture.ts` |
| 61 | + |
| 62 | +**Step 1: Write the failing test** |
| 63 | + |
| 64 | +Add tests for: |
| 65 | +- summary generation from command results |
| 66 | +- readable README content |
| 67 | +- recovery recommendations matching doctor heuristics |
| 68 | +- process snapshot command not depending on `rg` |
| 69 | + |
| 70 | +**Step 2: Run test to verify it fails** |
| 71 | + |
| 72 | +Run: |
| 73 | +```bash |
| 74 | +bun test tests/crash-capture.test.ts |
| 75 | +``` |
| 76 | + |
| 77 | +Expected: FAIL because the new helpers and artifacts do not exist yet. |
| 78 | + |
| 79 | +**Step 3: Write minimal implementation** |
| 80 | + |
| 81 | +Export bundle-summary helpers and update the capture command list/artifact writers. |
| 82 | + |
| 83 | +**Step 4: Run test to verify it passes** |
| 84 | + |
| 85 | +Run: |
| 86 | +```bash |
| 87 | +bun test tests/crash-capture.test.ts |
| 88 | +``` |
| 89 | + |
| 90 | +Expected: PASS |
| 91 | + |
| 92 | +**Step 5: Commit** |
| 93 | + |
| 94 | +```bash |
| 95 | +git add src/commands/crash-capture.ts tests/crash-capture.test.ts |
| 96 | +git commit -m "test: cover crash bundle summaries" |
| 97 | +``` |
| 98 | + |
| 99 | +### Task 3: Implement the doctor recovery panel |
| 100 | + |
| 101 | +**Files:** |
| 102 | +- Modify: `src/commands/doctor.ts` |
| 103 | +- Test: `tests/doctor-command.test.ts` |
| 104 | + |
| 105 | +**Step 1: Write the failing test** |
| 106 | + |
| 107 | +Extend the tests to assert grouped recovery actions and the temporary-vs-configuration distinction. |
| 108 | + |
| 109 | +**Step 2: Run test to verify it fails** |
| 110 | + |
| 111 | +Run: |
| 112 | +```bash |
| 113 | +bun test tests/doctor-command.test.ts |
| 114 | +``` |
| 115 | + |
| 116 | +Expected: FAIL |
| 117 | + |
| 118 | +**Step 3: Write minimal implementation** |
| 119 | + |
| 120 | +- classify checks into recovery buckets |
| 121 | +- render a single panel with ordered commands |
| 122 | +- keep unknown issues explicit rather than guessing |
| 123 | + |
| 124 | +**Step 4: Run test to verify it passes** |
| 125 | + |
| 126 | +Run: |
| 127 | +```bash |
| 128 | +bun test tests/doctor-command.test.ts |
| 129 | +``` |
| 130 | + |
| 131 | +Expected: PASS |
| 132 | + |
| 133 | +**Step 5: Commit** |
| 134 | + |
| 135 | +```bash |
| 136 | +git add src/commands/doctor.ts tests/doctor-command.test.ts |
| 137 | +git commit -m "feat: add explicit doctor recovery guidance" |
| 138 | +``` |
| 139 | + |
| 140 | +### Task 4: Implement richer crash bundle artifacts |
| 141 | + |
| 142 | +**Files:** |
| 143 | +- Modify: `src/commands/crash-capture.ts` |
| 144 | +- Test: `tests/crash-capture.test.ts` |
| 145 | + |
| 146 | +**Step 1: Write the failing test** |
| 147 | + |
| 148 | +Extend the tests to assert: |
| 149 | +- `summary.json` structure |
| 150 | +- `README.txt` guidance text |
| 151 | +- additional capture commands included |
| 152 | + |
| 153 | +**Step 2: Run test to verify it fails** |
| 154 | + |
| 155 | +Run: |
| 156 | +```bash |
| 157 | +bun test tests/crash-capture.test.ts |
| 158 | +``` |
| 159 | + |
| 160 | +Expected: FAIL |
| 161 | + |
| 162 | +**Step 3: Write minimal implementation** |
| 163 | + |
| 164 | +- capture additional doctor/global/runtime diagnostics |
| 165 | +- write bundle summary/readme artifacts |
| 166 | +- switch the process snapshot command to a portable filter |
| 167 | + |
| 168 | +**Step 4: Run test to verify it passes** |
| 169 | + |
| 170 | +Run: |
| 171 | +```bash |
| 172 | +bun test tests/crash-capture.test.ts |
| 173 | +``` |
| 174 | + |
| 175 | +Expected: PASS |
| 176 | + |
| 177 | +**Step 5: Commit** |
| 178 | + |
| 179 | +```bash |
| 180 | +git add src/commands/crash-capture.ts tests/crash-capture.test.ts |
| 181 | +git commit -m "feat: improve crash capture triage artifacts" |
| 182 | +``` |
| 183 | + |
| 184 | +### Task 5: Update docs and verify quality gates |
| 185 | + |
| 186 | +**Files:** |
| 187 | +- Modify: `README.md` |
| 188 | +- Modify: `docs/cli.md` |
| 189 | + |
| 190 | +**Step 1: Write the failing test** |
| 191 | + |
| 192 | +No automated test. Use doc consistency review against the implementation. |
| 193 | + |
| 194 | +**Step 2: Run verification** |
| 195 | + |
| 196 | +Run: |
| 197 | +```bash |
| 198 | +bun test tests/doctor-command.test.ts tests/crash-capture.test.ts |
| 199 | +bun test |
| 200 | +bun x ultracite fix |
| 201 | +bun x ultracite check |
| 202 | +``` |
| 203 | + |
| 204 | +Expected: targeted tests pass; full suite and checks pass or expose any unrelated failures that must be reported. |
| 205 | + |
| 206 | +**Step 3: Write minimal implementation** |
| 207 | + |
| 208 | +Update docs to mirror the same recovery sequence shown by `hack doctor`. |
| 209 | + |
| 210 | +**Step 4: Commit** |
| 211 | + |
| 212 | +```bash |
| 213 | +git add README.md docs/cli.md |
| 214 | +git commit -m "docs: document runtime and proxy recovery workflow" |
| 215 | +``` |
0 commit comments