test(semver): measure the ReDoS guard as best-of-N, not one sample - #3345
Conversation
The guard timed a single parse against a 50ms budget. On a loaded macOS runner that sample came back at 53.77ms and failed the v2.41.0 promotion, for a parse whose subject regression is 522ms — three orders of magnitude away. A first call also carries regex compilation and JIT warm-up that the parse itself does not. A gate that fires on runner weather teaches everyone to re-run it, which is exactly how a real ReDoS regression would get waved through. Best-of-N is the right statistic here, and that is measured rather than assumed. Running the semver.org prerelease pattern this module replaced, three runs each: 17.4-17.6ms at 20 repetitions, then 491-545ms at 30, 39 and 45. The blowup is on every run with under 10% spread, because superlinear backtracking is a property of the pattern; the 4ms of jitter that broke the single-sample form is not. If the exponential path returns, no run is fast. The measurements are in the test file, so the next person to touch the budget can see what it is actually separating. Verification: bun test tests/strict-semver.test.ts 7 pass 0 fail; bun run typecheck exit 0.
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe strict semver ReDoS tests now measure the fastest result across five parses. The tests retain input-length and null-result checks while replacing single-run timing helpers with ChangesStrict semver timing tests
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Semver ReDoS timing tests now use the fastest of five parse measurements to reduce one-time runtime noise while retaining the existing performance guard. The updated tests and typecheck pass, with no current merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
리뷰 · 우선순위 62 / 80이 PR은 제품 코드를 바꾸지 않습니다. 바꾸는 파일은 지금 그래서 이 PR은 라인 40-48 - 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
Summary
Best-of-N is the right statistic here, and that is measured rather than asserted. Running the semver.org prerelease pattern this module replaced against the same inputs, three runs each:
The blowup lands on every run with under 10% spread, because superlinear backtracking is a property of the pattern. The ~4ms of scheduler jitter that broke the single-sample form is not. If the exponential path returns, no run is fast, so the guard still fails loudly. Those numbers are in the test file so the next person to touch the budget can see what it separates.
Verification
bun test tests/strict-semver.test.ts— 7 pass, 0 fail.bun run typecheck— exit 0.Checklist
Summary by CodeRabbit