Investigate a failure
Find why something fails before you change it. A fix chosen before the cause is known can hide the failure without removing it. Swapping a version, image, or provider until the symptom stops teaches nothing. The next failure stays as mysterious as this one.ΒΆ
Read AGENTS.md first. Then read these leaves:ΒΆ
skills/rat-stack-mode/principles/find-the-cause-first.mdΒΆskills/rat-stack-mode/principles/rebuild-what-you-run.mdΒΆskills/rat-stack-mode/principles/measure-real-limits.mdΒΆskills/rat-stack-mode/principles/keep-execution-receipts.mdΒΆ
Terms used here
- Repro: a script that makes the failure happen on demand, at a known rate.ΒΆ
- Hypothesis: one testable claim about the cause. It stays a hypothesis until an experiment proves it.ΒΆ
- Probe: temporary instrumentation that checks a hypothesis. It stops the run cleanly, with the values it saw, before the failure happens.ΒΆ
- Asynchronous error: an error reported after the work that caused it. Its stack trace names where it surfaced, which may be far from where it started.ΒΆ
- Notebook: the running record of the investigation, written as it happens.ΒΆ
1. Bound the symptom
Write down what fails, how often, and under which conditions. Keep receipts: logs, error codes, timestamps, and inputs. Separate the failure from events near it. Output that looks corrupted may be a side effect of a crash.ΒΆ
2. Make it happen on demand
Write the smallest repro that triggers the failure. Report its rate as counts, for example β17 in 1,000 runsβ. A rare failure needs enough runs per attempt to show up. Then make it deterministic where you can, so the same input fails every time. The repro proves the fix later.ΒΆ
3. Rebuild what runs
Investigate code you can read and rebuild. If the running artifact holds changes that exist nowhere else, extract them as readable patches and pin every commit. Confirm the rebuild reproduces the failure before you trust an experiment on it.ΒΆ
4. Test one hypothesis at a time
Record each hypothesis, then run one experiment that can prove or falsify it.ΒΆ
- Make asynchronous errors synchronous before you trust a stack trace.ΒΆ
- Prefer probes that check the suspected values and stop cleanly over runs that wait for the crash.ΒΆ
- Change one setting per experiment. Repeat each experiment enough times to see the rate change.ΒΆ
A falsified hypothesis is a result. Write it down with its evidence and move to the next layer.ΒΆ
5. Fix at the cause
Fix the cause where it lives, not where it surfaced. A setting that avoids the failure, such as a longer timeout or a disabled feature, is a workaround. Measure its cost and label it as one.ΒΆ
Prove the fix with the repro. Then repeat the original workload enough times to show the rate is zero.ΒΆ
Example: two web tests read the same build output while the build rewrote it. Two repro runs found 17 and 28 torn reads. The fix wrote each file to a temporary path and renamed it into place. After the fix, 8.5 million reads showed no torn read. The fix lives in apps/web/scripts/reader-build.ts.ΒΆ
6. Leave a notebook and a recipe
Write the notebook as you go, not at the end. Each entry records:ΒΆ
End the notebook with:ΒΆ
- the cause and its proof;ΒΆ
- each setting touched, what it trades, and what was measured;ΒΆ
- the rebuild recipe with pinned sources, so someone else can reproduce the failure and the fix.ΒΆ
If the cause is upstream, send the maintainer the repro and the proof. Sending it is an outward action and follows the projectβs approval rules.ΒΆ
Report
Report these items:ΒΆ
- the cause and the experiment that proved it;ΒΆ
- the falsified hypotheses;ΒΆ
- the fix and its proof, as a rate before and after;ΒΆ
- any workaround and its cost;ΒΆ
- the notebook path.ΒΆ
Last changed 2026-10-10 in 0d43dfc. Source on GitHub. Change log.