root-cause-finder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRoot-Cause Finder
根因定位工具
Core Instruction
核心指令
Before fixing the error, prove whether the code path that produced it was intended.
Do not stop at the first contract, parsing, type, null, or schema error. Treat it as a possible symptom.
在修复错误之前,先确认产生该错误的代码路径是否是预期的。
不要在遇到第一个契约、解析、类型、空值或模式错误时就停止排查,要将其视为可能的症状。
Default Workflow
默认工作流程
- State the expected behavior in plain language.
- State the invariant in one sentence.
- State what definitely did not happen.
- Trace the causal chain from the intended action or system event to the observed system effect.
- Ask whether the request or mutation should have happened at all.
- Identify the canonical source of truth and every competing source.
- Find the first unintended side effect or write.
- Only then decide whether a downstream contract fix is still necessary.
- 用平实语言描述预期行为。
- 用一句话说明不变量。
- 明确说明绝对未发生的情况。
- 从预期操作或系统事件追溯到观测到的系统影响的因果链。
- 确认该请求或变更是否本就应该发生。
- 确定权威数据源以及所有竞争数据源。
- 找到第一个非预期副作用或写入操作。
- 只有在这之后,再决定是否仍需要修复下游契约。
Questions To Answer In Order
需按顺序回答的问题
- What user action or system event was supposed to happen?
- What exact call path caused this request or response?
- Should this request, mutation, or side effect have happened at all under the expected behavior and invariants?
- Who owns the state at each layer?
- Is there observer-driven syncing, lifecycle startup code, persistence restore, retry logic, background work, or multiple sources of truth causing an unintended side effect?
- If a contract is violated, is the contract wrong, or did unintended logic reach the contract?
- 应该发生的用户操作或系统事件是什么?
- 导致该请求或响应的具体调用路径是什么?
- 根据预期行为和不变量,该请求、变更或副作用本就应该发生吗?
- 每一层的状态归谁所有?
- 是否存在观察者驱动的同步、生命周期启动代码、持久化恢复、重试逻辑、后台任务或多数据源导致了非预期副作用?
- 如果契约被违反,是契约本身有误,还是非预期逻辑触发了契约?
Rules
规则
- Do not make the contract more permissive unless you can prove the observed payload is intended in the final design.
- Prefer fixing the upstream logic bug over accepting bad downstream data.
- Separate symptom, trigger, root cause, minimal safe fix, and architectural follow-up.
- If a low-level fix is still needed, explain why the upstream fix is not sufficient or why both are required.
- Identify the correct layer to fix first.
- Name the first visible wrong behavior, not only the final error.
- 除非能证明观测到的负载符合最终设计意图,否则不要放宽契约限制。
- 优先修复上游逻辑bug,而非接受下游的不良数据。
- 区分症状、触发因素、根因、最小安全修复方案和架构后续改进措施。
- 如果仍需要底层修复,请说明为什么上游修复不足,或者为什么两者都需要。
- 确定首先需要修复的正确层级。
- 指出第一个可见的错误行为,而不仅仅是最终的错误。
Hidden Write Checks
隐式写入检查
Treat non-explicit writes as suspicious by default.
- Audit lifecycle hooks, callbacks, subscribers, watchers, interceptors, middleware, retries, background jobs, cache refreshers, persistence restore, scheduled tasks, and startup code.
- Check whether derived data is being mirrored into another store, cache, file, queue, session, or database through an observer or helper layer.
- Prefer explicit command handlers, request handlers, job runners, or user actions as writers; treat startup-time and background writes as suspects until proven intentional.
- If a framework has automatic reactivity or lifecycle execution, map this rule onto its equivalent constructs without assuming the framework behavior is correct.
默认将非显式写入视为可疑操作。
- 审计生命周期钩子、回调函数、订阅者、监听器、拦截器、中间件、重试机制、后台任务、缓存刷新器、持久化恢复、定时任务和启动代码。
- 检查派生数据是否通过观察者或辅助层被镜像到另一个存储、缓存、文件、队列、会话或数据库中。
- 优先将显式命令处理器、请求处理器、任务运行器或用户操作作为写入来源;在被证明是有意为之之前,将启动时和后台写入视为可疑操作。
- 如果框架具有自动响应性或生命周期执行机制,请将此规则映射到其等效结构中,不要假设框架行为是正确的。
Output Format
输出格式
Use this structure:
- Expected behavior
- Invariant
- What definitely did not happen
- Bug class
- Causal chain from intended action to system effect
- First unintended side effect
- Canonical source of truth
- Competing sources of truth
- Symptom
- Trigger
- Root cause
- Correct layer to fix first
- Minimal safe fix
- Architectural follow-up
- Proposed patch
使用以下结构:
- 预期行为
- 不变量
- 绝对未发生的情况
- Bug类别
- 从预期操作到系统影响的因果链
- 第一个非预期副作用
- 权威数据源
- 竞争数据源
- 症状
- 触发因素
- 根因
- 首先需要修复的正确层级
- 最小安全修复方案
- 架构后续改进措施
- 建议补丁