gstack-openclaw-investigate
- 信任分
- 88/100
- 兼容 Agent
- 1
- 领域
- 工程开发
- 兼容 Agent
- Claude Code
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @garrytan · 未声明 license
- 安装命令数
- 1 条
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
想读作者英文原文? ↓ 滚到正文区切换 · 在 GitHub 查看 ↗
设计思路
gstack-openclaw-investigate 是 gstack 的「root cause 调查 SOP」——五个阶段,从根因追查到回归测试到结构化报告,每一步都有硬规则。Iron Law:3 次失败的修复尝试 → 停下来质疑架构(错的是结构,不是单点假设)。
五阶段
Phase 1:Root Cause Investigation 追到根因,不停在症状层。
Phase 2:Pattern Analysis 看是不是已知模式 / 既往同类 bug。
Phase 3:Hypothesis Testing 列假设、按可能性排序、逐个验证。3 个假设跑完都不中就停下:
"3 hypotheses tested, none match. This may be an architectural issue rather than a simple bug."
给用户三个选项:继续投新假设(描述清楚)/ escalate 给懂系统的人 / 加 logging 等下次复现。
Red flags(看到放慢节奏):
- "Quick fix for now"——没有「for now」,要么修对要么 escalate
- 没追数据流就开始提 fix——你在猜
- 每修一处就在别处冒新问题——错层不是错码
Phase 4:Implementation
- Fix root cause, not symptom——最小改动消除真问题
- Minimal diff——动文件最少、行最少;忍住别顺手重构
- 写回归测试:fix 之前 fail(证明测试有意义)、fix 之后 pass(证明 fix 有效)
- 跑全套测试——零回归
- fix 改 > 5 文件:先报 blast radius 给用户再继续——bug fix 改这么多算大动作
Phase 5:Verification & Report
- Fresh verification:复现原 bug 场景验证已修——非可选
- 跑全套测试
- 输出结构化 DEBUG REPORT:
- Symptom / Root cause / Fix(含文件引用) / Evidence(测试输出 + 复现) / Regression test 位置 / Related(同区域往例 / 架构注记) / Status
- 存到
memory/加日期戳
Status 取值
- DONE:根因找到、fix 应用、回归测试写完、全套通过
- DONE_WITH_CONCERNS:修了但无法完整验证(间歇 bug、需要 staging)
- BLOCKED:调查后根因仍不清,已 escalate
重要规则
- 3+ failed fix attempts: STOP and question the architecture.
- Never apply a fix you cannot verify.
- Never say "this should fix it"——验证给我看,跑测试。
- Fix 改 > 5 文件:先报 blast radius。
适合谁
- 调查复杂 / 跨模块 bug 的工程师
- 想把调试经验产品化、给团队留报告的 Tech Lead
- 反复出现的疑难 bug 想做根因调查
何时不该用
- 一眼看穿的低级错误——直接改
- 不在 gstack 生态——
diagnose是更轻量的等价物
配套
diagnose(superpowers 等价物)、improve-codebase-architecture(3+ fail 后的下一站)、systematic-debugging(更基础的调试方法论)。
Systematic Debugging
Iron Law
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.
Fixing symptoms creates whack-a-mole debugging. Every fix that doesn't address root cause makes the next bug harder to find. Find the root cause, then fix it.
Phase 1: Root Cause Investigation
Gather context before forming any hypothesis.
Collect symptoms: Read the error messages, stack traces, and reproduction steps. If the user hasn't provided enough context, ask ONE question at a time. Don't ask five questions at once.
Read the code: Trace the code path from the symptom back to potential causes. Search for all references, read the logic around the failure point.
Check recent changes:
git log --oneline -20 -- <affected-files>Was this working before? What changed? A regression means the root cause is in the diff.
Reproduce: Can you trigger the bug deterministically? If not, gather more evidence before proceeding.
Check memory for prior debugging sessions on the same area. Recurring bugs in the same files are an architectural smell.
Output: "Root cause hypothesis: ..." ... a specific, testable claim about what is wrong and why.
Phase 2: Pattern Analysis
Check if this bug matches a known pattern:
Race condition ... Intermittent, timing-dependent. Look at concurrent access to shared state.
Nil/null propagation ... NoMethodError, TypeError. Missing guards on optional values.
State corruption ... Inconsistent data, partial updates. Check transactions, callbacks, hooks.
Integration failure ... Timeout, unexpected response. External API calls, service boundaries.
Configuration drift ... Works locally, fails in staging/prod. Env vars, feature flags, DB state.
Stale cache ... Shows old data, fixes on cache clear. Redis, CDN, browser cache.
Also check:
- Known issues in the project for related problems
- Git log for prior fixes in the same area. Recurring bugs in the same files are an architectural smell, not a coincidence.
External search: If the bug doesn't match a known pattern, search for the error type online. Sanitize first: strip hostnames, IPs, file paths, SQL, customer data. Search the error category, not the raw message.
Phase 3: Hypothesis Testing
Before writing ANY fix, verify your hypothesis.
Confirm the hypothesis: Add a temporary log statement, assertion, or debug output at the suspected root cause. Run the reproduction. Does the evidence match?
If the hypothesis is wrong: Search for the error (sanitize sensitive data first). Return to Phase 1. Gather more evidence. Do not guess.
3-strike rule: If 3 hypotheses fail, STOP. Tell the user:
"3 hypotheses tested, none match. This may be an architectural issue rather than a simple bug."
Options:
- Continue investigating with a new hypothesis (describe it)
- Escalate for human review (needs someone who knows the system)
- Add logging and wait (instrument the area and catch it next time)
Red flags ... if you see any of these, slow down:
- "Quick fix for now" ... there is no "for now." Fix it right or escalate.
- Proposing a fix before tracing data flow ... you're guessing.
- Each fix reveals a new problem elsewhere ... wrong layer, not wrong code.
Phase 4: Implementation
Once root cause is confirmed:
Fix the root cause, not the symptom. The smallest change that eliminates the actual problem.
Minimal diff: Fewest files touched, fewest lines changed. Resist the urge to refactor adjacent code.
Write a regression test that:
- Fails without the fix (proves the test is meaningful)
- Passes with the fix (proves the fix works)
Run the full test suite. No regressions allowed.
If the fix touches >5 files: Flag the blast radius to the user before proceeding. That's large for a bug fix.
Phase 5: Verification & Report
Fresh verification: Reproduce the original bug scenario and confirm it's fixed. This is not optional.
Run the test suite.
Output a structured debug report:
DEBUG REPORT
- Symptom: what the user observed
- Root cause: what was actually wrong
- Fix: what was changed, with file references
- Evidence: test output, reproduction showing fix works
- Regression test: location of the new test
- Related: prior bugs in same area, architectural notes
- Status: DONE | DONE_WITH_CONCERNS | BLOCKED
Save the report to memory/ with today's date so future sessions can reference it.
Important Rules
- 3+ failed fix attempts: STOP and question the architecture. Wrong architecture, not failed hypothesis.
- Never apply a fix you cannot verify. If you can't reproduce and confirm, don't ship it.
- Never say "this should fix it." Verify and prove it. Run the tests.
- If fix touches >5 files: Flag to user before proceeding.
- Completion status:
- DONE ... root cause found, fix applied, regression test written, all tests pass
- DONE_WITH_CONCERNS ... fixed but cannot fully verify (e.g., intermittent bug, requires staging)
- BLOCKED ... root cause unclear after investigation, escalated