Skip to content

Keep seeded PRNG output strictly below 1 in checkout-pricing test - #1738

Merged
stefan-burke merged 2 commits into
mainfrom
claude/biome-ts-scripts-exclusion-jp4auc
Jul 11, 2026
Merged

Keep seeded PRNG output strictly below 1 in checkout-pricing test#1738
stefan-burke merged 2 commits into
mainfrom
claude/biome-ts-scripts-exclusion-jp4auc

Conversation

@stefan-burke

@stefan-burke stefan-burke commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up from the PR #1729 review (item #5 in TODO.md). The seeded PRNG in test/lib/checkout-pricing-consistency.test.ts divided by 0x7fffffff (2³¹−1), so rand() returned exactly 1 when seed === 0x7fffffff. That would let pick index one past the array (undefined) and randInt return hi + 1, producing invalid generated test data.

Changes

  • makeRng's rand() now divides by 0x80000000 (2³¹), so the output is always in [0, 1).
  • Removed the corresponding follow-up entry from TODO.md.

Note this shifts the seeded sequence (i.e. which random cases the property test explores); the test asserts an invariant (public ↔ webhook re-price identically) rather than hardcoded outputs, so it still passes.

Verification

  • deno task lint:ci on the file — clean.
  • deno check — passes.
  • test/lib/checkout-pricing-consistency.test.ts — passes (14 steps).

🤖 Generated with Claude Code


Generated by Claude Code

Summary by CodeRabbit

  • Tests

    • Improved deterministic pricing consistency tests to ensure generated random values remain within the expected range, preventing boundary-related calculation issues.
  • Documentation

    • Updated development follow-up notes to clarify expected command-line error handling for incomplete value flags.
    • Removed a completed random-number edge-case item from the follow-up list.

makeRng's rand() divided by 0x7fffffff (2^31-1), returning exactly 1 when
seed === 0x7fffffff, which would let pick index past the array and randInt
return hi + 1. Divide by 0x80000000 (2^31) so the result is always in
[0, 1). Removes the corresponding follow-up from TODO.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RJV4Bsf2owkANcSfn5sZgm
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@stefan-burke, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 23 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cd16d7c2-0cbe-4e99-bae3-cf723634fe7a

📥 Commits

Reviewing files that changed from the base of the PR and between 595f9e0 and 7b45d35.

📒 Files selected for processing (1)
  • test/shared/payment-signature.test.ts
📝 Walkthrough

Walkthrough

The deterministic test PRNG now normalizes values to the half-open range [0, 1). The TODO list documents a missing-value CLI error and removes the resolved seeded PRNG follow-up.

Changes

PRNG and code-quality follow-ups

Layer / File(s) Summary
Normalize deterministic PRNG output
test/lib/checkout-pricing-consistency.test.ts
Changes the RNG divisor to 0x80000000 and documents the [0, 1) boundary behavior.
Update code-quality follow-ups
TODO.md
Specifies fail-fast handling for missing recognized flag values and removes the seeded PRNG follow-up.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing the seeded PRNG in the checkout-pricing test to stay below 1.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/biome-ts-scripts-exclusion-jp4auc

Comment @coderabbitai help to get the list of available commands.

@stefan-burke
stefan-burke enabled auto-merge July 11, 2026 08:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/lib/checkout-pricing-consistency.test.ts`:
- Around line 121-124: Update the identical LCG rand() implementation in
payment-signature.test.ts to divide by 0x80000000 instead of 0x7fffffff,
ensuring rand() remains in [0, 1) and pick() cannot index past the array.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 64436e5b-4dfb-4827-8ed4-d141ea27e62e

📥 Commits

Reviewing files that changed from the base of the PR and between 41a9982 and 595f9e0.

📒 Files selected for processing (2)
  • TODO.md
  • test/lib/checkout-pricing-consistency.test.ts
💤 Files with no reviewable changes (1)
  • TODO.md

Comment thread test/lib/checkout-pricing-consistency.test.ts
The identical LCG in payment-signature.test.ts also divided by 0x7fffffff,
so its rand() could return exactly 1. Divide by 0x80000000 for consistency.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RJV4Bsf2owkANcSfn5sZgm
@stefan-burke
stefan-burke added this pull request to the merge queue Jul 11, 2026
Merged via the queue into main with commit d64cf18 Jul 11, 2026
3 checks passed
@stefan-burke
stefan-burke deleted the claude/biome-ts-scripts-exclusion-jp4auc branch July 11, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants