|
| 1 | +# Hypothesis-Driven Debugging Workflow Plan |
| 2 | + |
| 3 | +Implemented a sophisticated, scientific debugging workflow for the `.gemini/` framework. |
| 4 | + |
| 5 | +## Objective |
| 6 | +Refactor the `/debug` command and `debugger` agent to use a hypothesis-driven approach involving isolated diagnostic branches and automated testing. |
| 7 | + |
| 8 | +## Architectural Impact |
| 9 | +- **Structured Logic:** Moves debugging from "search and trace" to "hypothesize and experiment". |
| 10 | +- **Isolation:** Uses temporary git branches (`debug/hyp-*`) for all diagnostic changes, ensuring the `main` branch remains stable. |
| 11 | +- **Tooling:** Grants the `debugger` agent `write_file` access for diagnostic purposes only. |
| 12 | + |
| 13 | +## File Operations |
| 14 | + |
| 15 | +### 1. `.gemini/agents/debugger.md` |
| 16 | +- **Change:** Add `write_file` to `tools`. |
| 17 | +- **Change:** Update instructions to allow code modification for diagnostic purposes (e.g., adding logs, reproduction scripts). |
| 18 | +- **Change:** Implement a structured reporting format (Hypothesis, Actions, Observations, Conclusion). |
| 19 | + |
| 20 | +### 2. `.gemini/commands/debug.toml` |
| 21 | +- **Change:** Implement Phase 1: Context & Status Analysis (including `makefile`/auto-detect test check). |
| 22 | +- **Change:** Implement Phase 2: Hypothesis Formulation & `ask_user` approval loop. |
| 23 | +- **Change:** Implement Phase 3: Hypothesis Testing Loop with mandatory `git branch` creation and cleanup. |
| 24 | +- **Change:** Implement Phase 4: Synthesis and RCA report generation. |
| 25 | + |
| 26 | +## Execution Steps |
| 27 | + |
| 28 | +### Step 1: Update Debugger Agent |
| 29 | +Modify `.gemini/agents/debugger.md` to enable the experimental mandate. The agent will now be instructed to prove or disprove hypotheses by adding diagnostic code and running tests. |
| 30 | + |
| 31 | +### Step 2: Refactor Debug Command Logic |
| 32 | +Update `.gemini/commands/debug.toml` with the new orchestration prompt. This includes the logic for: |
| 33 | +- Detecting test runners (Makefile vs Auto-detect). |
| 34 | +- Generating and switching between temporary branches. |
| 35 | +- Managing the user approval flow for hypotheses. |
| 36 | +- Synthesizing subagent reports into a final RCA. |
| 37 | + |
| 38 | +## Testing & Validation |
| 39 | +- **Dry Run:** Trigger `/debug` with a simulated issue to verify the hypothesis formulation stage. |
| 40 | +- **Branch Verification:** Confirm the command creates `debug/hyp-` branches and successfully deletes them after the subagent returns. |
| 41 | +- **Cleanup Check:** Verify that Phase 1 correctly identifies and offers to clean up "stale" debug branches from previous interrupted sessions. |
| 42 | +- **RCA Verification:** Ensure the final output follows the Root Cause Analysis format and suggests a `/plan` for the fix. |
0 commit comments