|
| 1 | +--- |
| 2 | +name: delta-debugger |
| 3 | +description: "Tier 2: Delta Debugger - Binary search to minimize failure-inducing input. Inspired by Zeller's Delta Debugging & Git Bisect. Keywords: delta debug, binary search debugging, minimize input, git bisect, Delta调试, 二分查找调试" |
| 4 | +layer: workflow |
| 5 | +role: debugger-specialist |
| 6 | +tier: 2 |
| 7 | +version: 5.0.0 |
| 8 | +architecture: handoff-chain |
| 9 | +invokes: |
| 10 | + - error-analyzer |
| 11 | + - git-operations |
| 12 | + - test-generator |
| 13 | +invoked_by: |
| 14 | + - debugging-workflow |
| 15 | + - hierarchical-debugger |
| 16 | +capabilities: |
| 17 | + - binary_search_minimization |
| 18 | + - failure_inducing_input_isolation |
| 19 | + - git_bisect_integration |
| 20 | + - delta_debugging_algorithm |
| 21 | +triggers: |
| 22 | + keywords: |
| 23 | + - delta debug |
| 24 | + - binary search debugging |
| 25 | + - minimize input |
| 26 | + - git bisect |
| 27 | + - large failing input |
| 28 | + - Delta调试 |
| 29 | + - 二分查找调试 |
| 30 | + - 最小化输入 |
| 31 | + conditions: |
| 32 | + - "large input causes failure" |
| 33 | + - "need to find minimal failing case" |
| 34 | + - "git history has bug introduction" |
| 35 | +metrics: |
| 36 | + avg_execution_time: 15m |
| 37 | + success_rate: 0.88 |
| 38 | + reduction_factor: 10-100x |
| 39 | +--- |
| 40 | + |
| 41 | +# Delta Debugger - Tier 2 |
| 42 | + |
| 43 | +> **Tier 2 Skill**: Delta Debugging (inspired by Zeller 2002 & Git Bisect) |
| 44 | +
|
| 45 | +## What is Delta Debugging? |
| 46 | + |
| 47 | +Delta Debugging uses **binary search** to systematically minimize a failure-inducing input. |
| 48 | + |
| 49 | +``` |
| 50 | +LARGE FAILING INPUT (10,000 lines) |
| 51 | + │ |
| 52 | + │ Binary Search: Split in half |
| 53 | + ▼ |
| 54 | +┌───────────────┬───────────────┐ |
| 55 | +│ Half A │ Half B │ |
| 56 | +│ (5,000 lines)│ (5,000 lines)│ |
| 57 | +└───────┬───────┴───────┬───────┘ |
| 58 | + │ │ |
| 59 | + ▼ ▼ |
| 60 | + Test Half A Test Half B |
| 61 | + Fails? ✓ Fails? ✗ |
| 62 | + │ |
| 63 | + │ Keep searching Half A |
| 64 | + ▼ |
| 65 | + Split Half A again... |
| 66 | + │ |
| 67 | + ▼ |
| 68 | + ... repeat until ... |
| 69 | + │ |
| 70 | + ▼ |
| 71 | +MINIMAL FAILING INPUT (50 lines) ← 200x smaller! |
| 72 | +``` |
| 73 | + |
| 74 | +## Reduction Factor |
| 75 | + |
| 76 | +| Input Size | After Delta Debugging | Reduction | |
| 77 | +|------------|----------------------|-----------| |
| 78 | +| 10,000 lines | 50 lines | **200x** | |
| 79 | +| 1,000 config settings | 5 settings | **200x** | |
| 80 | +| 50 commits (Git Bisect) | 1 commit | **50x** | |
| 81 | + |
| 82 | +## Two Modes |
| 83 | + |
| 84 | +### Mode 1: Input Minimization (Zeller Style) |
| 85 | + |
| 86 | +```yaml |
| 87 | +purpose: "Minimize failure-inducing input" |
| 88 | +state: input_minimization |
| 89 | +algorithm: delta_debugging |
| 90 | +initial_input: "large_file.json" |
| 91 | +test_function: "does_input_fail(input)" |
| 92 | + |
| 93 | +phases: |
| 94 | + - name: "Split & Test" |
| 95 | + repeat: until minimal |
| 96 | + steps: |
| 97 | + - Split input into N chunks |
| 98 | + - Test each chunk |
| 99 | + - Identify which chunk(s) cause failure |
| 100 | + - Keep only failure-inducing chunks |
| 101 | + - Repeat with smaller chunks |
| 102 | + |
| 103 | + - name: "Verify Minimal" |
| 104 | + steps: |
| 105 | + - Verify minimal input still fails |
| 106 | + - Verify removing any element makes it pass |
| 107 | +``` |
| 108 | +
|
| 109 | +### Mode 2: Git Bisect (Commit History) |
| 110 | +
|
| 111 | +```yaml |
| 112 | +purpose: "Find commit that introduced bug" |
| 113 | +state: git_bisect |
| 114 | +algorithm: binary_search_on_commits |
| 115 | + |
| 116 | +phases: |
| 117 | + - name: "Setup Bisect" |
| 118 | + steps: |
| 119 | + - git bisect start |
| 120 | + - git bisect bad HEAD (current commit is bad) |
| 121 | + - git bisect good v1.0 (known good commit) |
| 122 | + |
| 123 | + - name: "Binary Search Commits" |
| 124 | + repeat: until found |
| 125 | + steps: |
| 126 | + - Git checks out midpoint commit |
| 127 | + - Run tests |
| 128 | + - If fails: git bisect bad |
| 129 | + - If passes: git bisect good |
| 130 | + |
| 131 | + - name: "Found It!" |
| 132 | + output: "Commit abc123 introduced the bug" |
| 133 | +``` |
| 134 | +
|
| 135 | +## Handoff Chain |
| 136 | +
|
| 137 | +``` |
| 138 | +Input Analyzer ━━(handoff)━━► Delta Debugger ━━(handoff)━━► Minimal Input Verifier |
| 139 | + │ │ │ |
| 140 | + ├─ Size estimate ├─ Binary search ├─ Confirm minimal |
| 141 | + └─ Failure pattern └─ Minimize input └─ Still fails |
| 142 | +``` |
| 143 | + |
| 144 | +## Example 1: Input Minimization |
| 145 | + |
| 146 | +``` |
| 147 | +PROBLEM: 10,000-line JSON file causes crash |
| 148 | +
|
| 149 | +BEFORE: Manual debugging (45min, gave up) |
| 150 | + - Too big to understand |
| 151 | + - Couldn't find what's wrong |
| 152 | +
|
| 153 | +AFTER: Delta Debugging (12min) |
| 154 | + Phase 1: Split into 10 chunks of 1,000 lines |
| 155 | + Phase 2: Test chunks → Chunk 7 fails |
| 156 | + Phase 3: Split Chunk 7 → Sub-chunk 7.3 fails |
| 157 | + Phase 4: Continue... |
| 158 | + Phase 5: Found minimal input: 50 lines! |
| 159 | + Phase 6: Verify: removing any line makes it pass |
| 160 | +
|
| 161 | +RESULT: Minimal input found, 12min, 200x reduction |
| 162 | +``` |
| 163 | + |
| 164 | +## Example 2: Git Bisect |
| 165 | + |
| 166 | +``` |
| 167 | +PROBLEM: Bug introduced somewhere in last 50 commits |
| 168 | +
|
| 169 | +BEFORE: Manual checking (30min, checked 10 commits) |
| 170 | + - Slow |
| 171 | + - Gave up |
| 172 | +
|
| 173 | +AFTER: Git Bisect (8min, checked 6 commits) |
| 174 | + git bisect start |
| 175 | + git bisect bad HEAD |
| 176 | + git bisect good v2.1.0 |
| 177 | + |
| 178 | + [binary search: 6 steps] |
| 179 | + |
| 180 | + git bisect found! |
| 181 | + → Commit abc1234: "Refactor authentication" |
| 182 | +
|
| 183 | +RESULT: Bug found in 8min! |
| 184 | +``` |
| 185 | + |
| 186 | +## Related Skills |
| 187 | + |
| 188 | +- **debugging-workflow** - Can use this for large inputs |
| 189 | +- **git-operations** - Git operations |
| 190 | +- **error-analyzer** - Error analysis |
0 commit comments