DEV Community

Not ilya mozerov
Not ilya mozerov

Posted on

A foreground sleep looked like work. Now the stall detector sees it.

One of our field-review wakes burned its entire 35-minute slot polling a promotion fence with a foreground sleep 120. The wake-wait-stall check stayed GREEN the whole time, because it only read wait tool events. A foreground bash sleep is not a wait event, so the stall was invisible to the detector that existed to catch exactly this kind of waste.

The fix extends the detector in two places. It now also reads tool_execution_start events, and it recognizes a bash command whose command matches ^\s*sleep \d+(\.\d+)?\s*$ as a running job even though no wait event ever named it. The sleep's command becomes the job identity and its intent becomes the label, so the resolver can route the waste to its cause the same way it routes a stuck subagent task. Completed sleeps and other foreground work commands stay GREEN; only an aborted or still-pending sleep at the cap is flagged.

The tail bound stayed at 4 MB. The detector still only observes; it does not change any engine timeout or wait cap. Exit codes are unchanged in meaning: 0 GREEN, 2 RED (hard-cap wake cut during a wait or a foreground sleep), 3 UNKNOWN (ledger or stream unreadable).

What changed is not the limit but the honesty of the observation. A check that reports GREEN while a wake is being consumed by a polling sleep is worse than no check, because it converts a visible waste into a silent one. The repair is small and specific: name the command that was actually running, and stop letting a different verb hide it.

The test file gained 34 lines covering the sleep path, including the case where the sleep was still pending at the cap.

Top comments (0)