Loading...
Loading...
Compare original and translation side by side
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRSTNO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRSTDebugging Progress:
- [ ] Phase 1: Root Cause Investigation
- [ ] Read error messages carefully
- [ ] Reproduce consistently
- [ ] Check recent changes
- [ ] Gather evidence at component boundaries
- [ ] Trace data flow backward to source
- [ ] Phase 2: Pattern Analysis
- [ ] Find working examples
- [ ] Compare against references
- [ ] Identify differences
- [ ] Phase 3: Hypothesis and Testing
- [ ] Form single hypothesis
- [ ] Test minimally (one change)
- [ ] Verify before continuing
- [ ] Phase 4: Implementation
- [ ] Create failing test case
- [ ] Implement single fix at root cause
- [ ] Apply defense-in-depth
- [ ] Remove all // debug-shim markers
- [ ] Verify fix and tests pass调试进度:
- [ ] 阶段1:根本原因调查
- [ ] 仔细阅读错误信息
- [ ] 稳定复现问题
- [ ] 检查近期变更
- [ ] 在组件边界收集证据
- [ ] 反向追踪数据流至源头
- [ ] 阶段2:模式分析
- [ ] 寻找可正常运行的示例
- [ ] 与参考实现对比
- [ ] 识别差异点
- [ ] 阶段3:假设与测试
- [ ] 形成单一假设
- [ ] 最小化测试(仅变更一处)
- [ ] 验证后再推进
- [ ] 阶段4:落地实施
- [ ] 创建失败测试用例
- [ ] 针对根本原因实施单一修复
- [ ] 应用纵深防御机制
- [ ] 移除所有// debug-shim标记
- [ ] 验证修复方案与测试用例均通过reading-logsFor EACH component boundary:
- Log what data enters component
- Log what data exits component
- Verify environment/config propagation
- Check state at each layer
Run once to gather evidence showing WHERE it breaks
THEN analyze evidence to identify failing component
THEN investigate that specific componentundefinedreading-logs对于每个组件边界:
- 记录进入组件的数据
- 记录离开组件的数据
- 验证环境/配置的传递情况
- 检查每一层的状态
运行一次以收集问题发生位置的证据
然后分析证据确定故障组件
再针对该特定组件展开调查undefined
**This reveals:** Which layer fails (secrets → workflow ✓, workflow → build ✗)
**该示例可揭示:** 哪一层出现故障(密钥 → 工作流 ✓,工作流 → 构建 ✗)Symptom: git init creates .git in source code directory
Why? → cwd parameter is empty string, defaults to process.cwd()
Why? → projectDir variable passed to git init is ''
Why? → Session.create() received empty tempDir
Why? → Test accessed context.tempDir before beforeEach initialized it
Why? → setupCoreTest() returns object with tempDir: '' initially
Root Cause: Top-level variable initialization accessing uninitialized valueexecFileAsync('git', ['init'], { cwd: projectDir }) // Symptom
← WorktreeManager.createSessionWorktree(projectDir, sessionId)
← Session.initializeWorkspace()
← Session.create(tempDir)
← Test: Project.create('name', context.tempDir) // Root triggerasync function gitInit(directory: string) {
// debug-shim
const stack = new Error().stack;
console.error("DEBUG:", { directory, cwd: process.cwd(), stack });
// end debug-shim
await execFileAsync("git", ["init"], { cwd: directory });
}console.error()症状:git init在源代码目录中创建.git文件夹
为什么?→ cwd参数为空字符串,默认使用process.cwd()
为什么?→ 传递给git init的projectDir变量为''
为什么?→ Session.create()收到的tempDir为空
为什么?→ 测试在beforeEach初始化前访问了context.tempDir
为什么?→ setupCoreTest()返回的对象初始时tempDir为''
根本原因:顶层变量初始化时访问了未初始化的值execFileAsync('git', ['init'], { cwd: projectDir }) // 症状
← WorktreeManager.createSessionWorktree(projectDir, sessionId)
← Session.initializeWorkspace()
← Session.create(tempDir)
← 测试: Project.create('name', context.tempDir) // 初始触发点async function gitInit(directory: string) {
// debug-shim
const stack = new Error().stack;
console.error("DEBUG:", { directory, cwd: process.cwd(), stack });
// end debug-shim
await execFileAsync("git", ["init"], { cwd: directory });
}console.error()// debug-shimconsole.error("DEBUG:", { value, context }); // debug-shimgrep -r "debug-shim" .references/debugging-techniques.md#debug-shim-markers// debug-shimconsole.error("DEBUG:", { value, context }); // debug-shimgrep -r "debug-shim" .references/debugging-techniques.md#debug-shim-markers| Excuse | Reality |
|---|---|
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
| 借口 | 事实 |
|---|---|
| “问题很简单,不需要流程” | 简单问题也有根本原因。该流程处理简单bug的速度很快。 |
| “紧急情况,没时间走流程” | 系统化调试比盲目尝试更高效。 |
| “先试试这个,之后再调查” | 第一次修复会定下模式。从一开始就做对。 |
| “确认修复有效后再写测试” | 未测试的修复无法持久。先写测试才能证明修复有效。 |
| “同时做多处修复节省时间” | 无法确定哪部分起作用。会引入新bug。 |
| “参考内容太长,我会调整模式” | 一知半解必然导致bug。请完整阅读。 |
| “我看到问题了,我来修复” | 看到症状≠理解根本原因。 |
| “再试一次修复”(尝试2次以上后) | 3次以上失败=架构问题。质疑模式,不要继续修复。 |
| Phase | Key Activities | Success Criteria |
|---|---|---|
| 1. Root Cause | Read errors, reproduce, check changes, trace data flow | Understand WHAT and WHY |
| 2. Pattern | Find working examples, compare | Identify differences |
| 3. Hypothesis | Form theory, test minimally | Confirmed or new hypothesis |
| 4. Implementation | Create test, fix with defense-in-depth, verify | Bug resolved, tests pass |
| 阶段 | 核心活动 | 成功标准 |
|---|---|---|
| 1. 根本原因 | 阅读错误信息、复现问题、检查变更、反向追踪数据流 | 理解问题是什么以及为什么发生 |
| 2. 模式分析 | 寻找正常示例、对比参考实现 | 识别差异点 |
| 3. 假设与测试 | 形成理论、最小化测试 | 假设得到确认或形成新假设 |
| 4. 落地实施 | 创建测试用例、修复根本原因并应用纵深防御、验证 | Bug解决,测试通过 |
undefinedundefinedfile.ts:123file.ts:123file.ts:123-125test.ts:45file.ts:123-125test.ts:45undefinedundefinedwriting-testscondition-based-waitingverification-before-completionreading-logswriting-testscondition-based-waitingverification-before-completionreading-logs