Skip to content

tests: wall-clock bounds become load-independent assertions (Fixes #4477) - #4838

Merged
squid-protocol merged 2 commits into
mainfrom
tests/4477-timing-tests
Oct 10, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
tests/4477-timing-tests

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #4477 (also the Windows-leg test_no_new_offenders flake from #4836).

Design

Wall-clock bounds measured the runner, not the code. New tests/_timing.py: CPU time of the calling thread (time.thread_time, descheduled time not counted), minimum of N repeats, and assert_scales_linearly (ratio of a 4x input vs the small one, limit = 8x, linear ~4x / quadratic ~16x) or assert_cpu_below (fixed pathological payload, bound far above honest cost and far below the regressed cost).

  • Ratio tests: test_prism_suppression_regex_bomb, test_an_unterminated_declare_is_linear, test_many_move_statements_stay_linear, test_an_unterminated_exec_is_capped_and_linear.
  • CPU best-of-3 bound (about 40 more tests): prism poison cases, cpp shield, mainframe_boundary / jcl_symbol / commarea / cics_tasks / job_submits / job_flow / mq_calls / uow_handlers / csd / file_control shapes, cobol dag/graveyard/jcl_forge, go/abap/dead_code/ruby/scheme/yaml/matlab/calls_out, dart/kotlin/security_lens/pii.
  • ReDoS harness (assert_redos_immune in _strict_harness.py / _extraction_harness.py, _measure_scaling_point; hundreds of callers): the child now reports its own CPU time, which is bounded by timeout_sec; wall time is only the hang kill (max(10, 10*timeout_sec)).
  • tests/tools/tool_regex_redos.py (sweep behind test_no_new_offenders): CPU clock, slow verdict confirmed on best-of-5, quadratic confirmation best-of-5; where the thread clock is coarse (Windows, ~15 ms) it uses perf_counter + min-of-5.
  • ci_digest.FLAKY is now empty (tests listed there are deterministic; test_regex_redos was a stale name); the mechanism is still tested via monkeypatch.
  • Left alone (generous or not wall-clock): test_redos_poison.py (10 s hang kill + 120 s stall, a kill switch), test_chronometer_timeout (feature test of a timeout), test_a_class_miss_is_several_times_cheaper... (ratio of two regexes, 3x margin vs 25x+; only switched to thread_time), test_ada_strict (already a documented plain ceiling).

cobol_graveyard_finder lines 112/115

Not genuinely quadratic: measured min-of-3 at 40k/80k/160k chars grows 4.0x for 4x input (_TERMINAL_TAIL/_ALTER shapes); the Windows 10-12x came from 15 ms thread/wall-clock noise on 2-30 ms samples.

Proof

  • Under load (12 busy-loop processes on 12 cores, other agents' load average 15-70 on top): all changed test files run 20 times in a row, 20/20 green (1,300+ tests each).
  • Still fail when the property breaks (scratch plugin, not committed, inflates the work quadratically / burns CPU): prism bomb 12.6x cost for 4x input (limit 8x); unterminated DECLARE 10.4x; unterminated EXEC 11.2x; MOVE statements 8.1x (limit 8x, the weakest sabotage); fixed-payload bounds with 3 s CPU burn: mainframe_boundary and cpp shield fail (3.01 s > 2.0 s). Existing test_redos_detonator_timeout_catch, test_catches_the_3205_pattern, test_catches_a_mild_quadratic_by_growth and test_the_kill_switch_still_catches... still pass, so the harness and sweep still catch real ReDoS.
  • pr_gates --fast 5/5, --ratchets 7/7 (with equivalence_env JDK 17).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TBJdDBRtJis5hzE244NQKV

)

CPU-time (thread_time) best-of-N measurements and size-scaling ratios replace
absolute wall-clock bounds; the ReDoS harness bounds child CPU time and keeps
wall time only as a generous hang kill; tool_regex_redos uses CPU time, confirms
slow samples, and avoids Windows' 15 ms thread clock. ci_digest FLAKY emptied.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TBJdDBRtJis5hzE244NQKV
@squid-protocol squid-protocol added bug Unintended behavior or logic failure in the engine testing Unit, integration, and E2E pipeline verification labels Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol marked this pull request as ready for review October 10, 2026 12:54
@squid-protocol
squid-protocol merged commit d9ad2eb into main Oct 10, 2026
24 checks passed
@squid-protocol
squid-protocol deleted the tests/4477-timing-tests branch October 10, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unintended behavior or logic failure in the engine testing Unit, integration, and E2E pipeline verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: wall-clock-bound tests fail under CI load (regex_redos, many_move_statements_stay_linear)

1 participant