Repository navigation
test: make the linear-scan timing tests hold on loaded CI runners - #8185
Conversation
Three linearity checks failed on busy Linux runners under xdist and blocked PRs that never touched shell code. They now compare how time grows between two input sizes, measured interleaved and best-of-N, so load slows both sides alike while a quadratic regression still trips the ratio by a wide margin. Closes #8184
# Conflicts: # tests/unit/test_shell_guardrails.py
CPython's parse of the f-string storm is itself super-linear, so on a loaded Windows runner the 4x size step crossed the 9x bound with no detector change. The growth check now excludes the parse, uses an 8x step (500 to 4000 launches) with best-of-5, and allows 24x: linear runs measure 6-16x, while a per-launch re-read of earlier statements measures 40-68x and still fails.
Skill audit
✅ All audited skills cleared the tier they claim. Per-finding detail is withheld here on purpose. Read it in the Security > Code scanning tab, or download the |
|
Verdict: Request changes 🔴 The merge from To fix it, take 🔍 Technical details
|
…owth test The last merge from main kept this branch's older copy of the file, dropping the multi-line command suite and the gh_on_path fixture calls.
|
Verdict: Approve with suggestions This makes the two flaky "stays linear" timing tests stable on busy CI runners. They now compare how the time grows when the input gets 8x bigger, instead of timing one call against a fixed limit. The change is tests-only and makes both tests sturdier and no weaker than before. Two small things are worth fixing:
Real-world evidenceN/A: this PR only changes tests, so this verdict comes from reading the code. 🔍 Technical detailsIssues found 🟢 The 5 ms floor hides quadratic growth in the cheap heredoc shapes (
Exponential backtracking is still caught, and the old 0.5 s wall-clock bound couldn't catch a quadratic either, so nothing is lost compared with (or lower the floor to 🟢 The PR body's 🔍 section describes superseded parameters. It still says "1000 vs 4000 launches, interleaved best of 3 … Checked, no action needed
Strengths
|
|
Verdict: Approve This PR fixes three flaky "stays linear" timing tests. They now check how the scan time grows when the input is 8x bigger, rather than comparing one run against a fixed time limit. Both sizes are timed back to back and the best of 5 is kept, so a busy runner slows both sizes alike, while a quadratic slowdown (~64x) still fails the 24x bound. It only touches tests, the original correctness checks still run at full size, and I found nothing blocking. Real-world evidenceN/A: this PR changes tests only. There is no evidence bundle, and nothing user-facing changed that could be run. The verdict rests on reading the code alone. I could not run the tests here because pytest isn't installed in this review sandbox, so the PR's own CI run is what shows them passing. 🔍 Technical detailsIssues found 🟢 Parsing is patched out of the timing, so a re-parse regression wouldn't show ( 🟢 The 🟢 The heredoc test leaves GC running. The detection test pauses GC during timing; the heredoc test doesn't. The heredoc strings are small, so the risk is low, but pausing GC there too would make the two tests consistent. Strengths
|
Three "stays linear" tests timed a single call against a fixed or lopsided bound, so a busy Linux CI runner could push them over and block PRs that never touched shell code (seen twice on #8025). They now check how the time grows when the input gets 8x bigger: both sizes are timed back to back, best of several runs, so runner load slows both alike. A quadratic regression still fails.
Closes #8184
Test plan
python -m pytest tests/unit/test_shell_guardrails.py tests/unit/agents/test_unsupported_test_claim.py -k linearpassespython -m pytest tests/unit/ -xpassespython util/lint.py --allpassesUnit Tests (Linux, py3.12)is green on this PR🔍 Technical details
TestHeredocCannotHideARefusedCommand::test_the_scan_stays_linear): it used to assert one call under 0.5 s. Now each shape is built at n=400 and n=3200 and timed interleaved, best of 5. The assert isbig < 24*small + 5ms: linear gives ~8-9x, quadratic ~64x. At these sizes a quadratic clears the 5 ms floor on every shape that does real work; the$((…))shape returns almost immediately at any size.test_a_command_grown_and_launched_each_time_stays_linear): it timed detection once, against best-of-3ast.parse. Now it compares 500 vs 4000 launches, interleaved best of 5 with GC paused, timing only the detector's walk (parse excluded). The assert isbig < 24*small + 20ms: linear gives ~6-16x, the unbounded n²/2 ~64x. Thefound/ no-warning / storm-only-is-False checks still run at the original 5000 launches._linear_boundusers are unchanged; the issue named only these two tests.