Skip to content

test: per-host throttle sequential spacing assertion is load-sensitive (27 ms against a 30 ms bound) #1516

Closed

Description

@nc9

Found while reviewing #1319 (CI run of that PR). Not caused by that PR: it touches no apps/cli files.

apps/cli/tests/crawler/per-host-throttle.test.ts (around line 466), the test "per-host throttle (#265) > sequential mode (perHostConcurrency=1) still spaces starts by the delay", asserts that the spacing between starts is at least 0.6 times the delay (30 ms). Under CI load it measured 27 ms ("Expected: >= 30, Received: 27") and failed the CLI tests job. Run by path twice at low load on the parent tree it passes 6 of 6.

Acceptance Criteria

  • The sequential-mode spacing assertion no longer depends on wall-clock timing under load: it uses a fake clock, or a tolerance that a loaded runner cannot miss (for example the median spacing, or a lower bound with a documented margin)
  • The test still fails if the per-host delay is removed (checked by mutating the delay to 0)
  • The file passes 10 of 10 consecutive runs with 12 busy processes running alongside
  • No other timing assertion in the same file asserts a bound within 2x of the measured spacing

nik

Activity

  1. added
    bug
    size: XS
    on Nov 1, 2026
  2. added theissue type on Nov 1, 2026
  3. WilliamK112 commented on Nov 1, 2026

    @WilliamK112
    Contributor

    I would like to take this. I will first reproduce the sequential-spacing test under load and verify that setting the delay to zero makes the current assertion fail, then replace the wall-clock-sensitive bound with the smallest documented assertion that preserves that mutation check. I will also audit the other timing bounds in this file and run the requested 10 loaded repetitions.

  4. nc9 commented on Nov 1, 2026

    @nc9
    ContributorAuthor

    Fixed in v0.0.158 by William's #1519 (commits d2007730, f4a8e937): the sequential spacing checks now use lower bounds at 0.4 of the delay, the median gap and the total span first to last, and the test passed 6 of 6 and 5 of 5 under 3 busy processes in review; removing the per-host spacing in the crawler source turns it red. Thank you William. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.158

    nik

  5. nc9 commented on Nov 1, 2026

    @nc9
    ContributorAuthor

    Checked against v0.0.158. All four criteria are met: the sequential spacing assertion uses the median gap and the total span with lower bounds at 0.4 of the delay (no wall-clock bound a loaded runner can miss); the tests still fail when the per-host spacing is removed from the crawler source (mutated in review: four of the six tests go red), and when the Crawl-delay cap is removed; the file passed 10 of 10 consecutive runs with 12 busy processes running alongside (6 of 6 tests each); and the other lower bounds also moved to 0.4 with the capped-delay upper bound at 5,000 against the declared 10,000. One tolerance note: the bounds accept a spacing down to about 0.4 of the configured delay, so halving the delay is not caught. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.158

    nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsize: XS

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions