0
Root-cause a flaky test using a structured hypothesis funnel
This test fails intermittently, not on every run. Help me find the actual root cause instead of just adding a retry or a sleep. Work through this funnel and show your reasoning at each step:
1. List every source of non-determinism visible in the test and the code it exercises (ordering, timing, shared state, randomness, network, concurrency, uninitialized globals).
2. Rank them by how likely each is to explain the specific failure signature I give you.
3. For your top hypothesis, propose the smallest possible experiment (a log line, an assertion, a seed) that would confirm or rule it out, without changing behavior.
4. Only after that, propose a fix. Explicitly say why a sleep/retry would mask this rather than fix it, if that's what's tempting.
5. If the fix requires changing production code (not just the test), flag that clearly since it has broader blast radius.
Test code: test_code
Code under test: code_under_test
Failure signature (error, stack trace, how often it fails): failure_signature