Skip to content

Audit sleep-polling-loop detector misses the most common form, sleep 30s #522

Description

@chhhee10

Description

The sleep-polling-loop audit detector flags long sleep calls (busy-waiting), but its regex
silently drops the explicit-seconds form sleep 30s. The unit alternation omits s, and the
trailing \b then fails on the trailing s (both 0 and s are word characters), so the
entire match fails rather than falling back to the bare number.

src/audit/detectors/sleep-polling-loop.ts:23:

const match = /\bsleep\s+(\d+(?:\.\d+)?)(m|h|d)?\b/.exec(cmd);

Steps to Reproduce

Run an audit over a transcript containing sleep 30s (or sleep 45s). The detector does not
fire, even though the duration is at/above the 30s threshold.

/\bsleep\s+(\d+(?:\.\d+)?)(m|h|d)?\b/.exec("sleep 30s"); // => null
/\bsleep\s+(\d+(?:\.\d+)?)(m|h|d)?\b/.exec("sleep 30");  // => matches
/\bsleep\s+(\d+(?:\.\d+)?)(m|h|d)?\b/.exec("sleep 1m");  // => matches

Ironically the docstring boasts that sleep 0.5m (= 30s) "isn't dropped", while the far more
common sleep 30s is.

Expected Behavior

sleep 30s / sleep 45s should be detected exactly like sleep 30 and sleep 0.5m.

Failproof AI Version

0.0.14-beta.1

Node.js / Bun Version

Bun 1.3+

Operating System

macOS

Additional Context

One-character fix: add s to the unit group — (s|m|h|d)?. Add a test for sleep 30s next to
the existing cases in the detector's test file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions