Skip to content

tests: one CPU-clock helper for ReDoS harnesses and linearity check (Part of #8423) - #8523

Merged
squid-shepherd[bot] merged 2 commits into
mainfrom
churn/8423-cpu-clock-helper
Nov 16, 2026
Merged

squid-shepherd[bot] merged 2 commits into
mainfrom
churn/8423-cpu-clock-helper

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

What

tests/_timing.py already held the CPU-clock helpers; this slice makes the ReDoS harnesses and the linearity helper use them, with the limit stated once.

  • REDOS_LIMIT_S = 1.0 and CPU_REPEATS = 3 live in tests/_timing.py; both harnesses' default timeout_sec comes from it.
  • New cpu_best_of(work, limit_s): fastest CPU time of up to three runs, returning after the first run that is under the limit (a passing regex costs one run; only a slow first run pays for retries). The child timers in _strict_harness.py and _extraction_harness.py use it.
  • best_cpu_seconds takes an injectable clock; linear_assert.py now defaults to time.thread_time (was perf_counter) and delegates to it. The fake-clock meta-test (main is red: GitGalaxy Smoke Tests #8132) still passes.
  • tests/core_engine/test_timing_helper_8423.py pins best-of semantics, retry-only-after-slow, and that both harnesses take their default from the helper.

Class

A test that judges elapsed time with a raw or single-sample clock, with its own copy of the limit.

Remaining slices

  • Gate refusing raw time.time() / perf_counter() / monotonic() difference asserts in tests, plus the shrink-only offender list (checklist items 2-3).
  • Sibling gaps (no burned-estate program needs them): test_hlasm_macro_uses.py (_best_of_three, test_macro_use_scans_are_redos_immune), test_hlasm_strict.py:934, and about 36 test_*.py files using perf_counter/time.time/monotonic (e.g. test_dense_source_7501/7504, test_cics_macro_level, test_uef_length_invariance, test_prefetch).

Gates

ruff check/format on changed files, audit_check.py all clear, pr_gates --ratchets --only-ratchets time PASS, 643 timing/ReDoS/linearity tests pass.

Checklist: partial [c:e628cc47] -- the gate and offender list (items 2-3) and the other offenders remain

🤖 Generated with Claude Code

squid-protocol and others added 2 commits November 16, 2026 10:59
…and linearity helper use it (Part of #8423)

REDOS_LIMIT_S stated once in tests/_timing.py; cpu_best_of (thread_time, fastest of three, retry only
after an over-limit run) drives the ReDoS child timers; linear_assert defaults to thread_time.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Nov 16, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

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

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant