Skip to content

PR_26177_DELTA_053-random-shared-helpers#205

Merged
ToolboxAid merged 1 commit into
mainfrom
PR_26177_DELTA_053-random-shared-helpers
Jun 26, 2026
Merged

PR_26177_DELTA_053-random-shared-helpers#205
ToolboxAid merged 1 commit into
mainfrom
PR_26177_DELTA_053-random-shared-helpers

Conversation

@ToolboxAid

Copy link
Copy Markdown
Owner

PR_26177_DELTA_053-random-shared-helpers

Date: 2026-06-26
Team: Delta
Scope: Shared internal random helper logic and targeted unit tests
Status: PASS

Summary

  • Added internal shared random helper functions in src/shared/math/randomHelpers.js.
  • Added helpers for nextInt, nextFloat, pick, shuffle, chance, and weightedPick.
  • Helpers consume caller-provided randomNext functions returning floats >= 0 and < 1.
  • Kept helpers as shared internal code only; no Creator-facing API was added.
  • Preserved existing RandomSeed behavior and did not change its implementation in this PR.
  • Added targeted unit tests in tests/shared/RandomHelpers.test.mjs.
  • Updated Team Delta active assignment metadata for the stacked random utility workstream.

Branch Validation

PASS. Branch PR_26177_DELTA_053-random-shared-helpers was created from clean synchronized main after PR_052 merged.

Changed Files

  • docs_build/dev/PLAN_PR.md
  • docs_build/dev/BUILD_PR.md
  • docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md
  • docs_build/dev/ProjectInstructions/team_assignments/ACTIVE_TEAM_REGISTRY.md
  • src/shared/math/randomHelpers.js
  • tests/shared/RandomHelpers.test.mjs
  • docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers.md
  • docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_branch-validation.md
  • docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_requirement-checklist.md
  • docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_validation-lane.md
  • docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_manual-validation-notes.md
  • docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_instruction-compliance-checklist.md
  • docs_build/dev/reports/codex_changed_files.txt
  • docs_build/dev/reports/codex_review.diff

Validation

  • PASS: node ./scripts/run-node-test-files.mjs tests/shared/RandomHelpers.test.mjs tests/shared/RandomSeed.test.mjs
  • PASS: node --check src/shared/math/randomHelpers.js
  • PASS: node --check tests/shared/RandomHelpers.test.mjs
  • PASS: git diff --check
  • SKIP: Playwright was not run because this PR does not change UI or browser runtime flows.

Artifact

  • tmp/PR_26177_DELTA_053-random-shared-helpers_delta.zip

@ToolboxAid ToolboxAid marked this pull request as ready for review June 26, 2026 03:43
@ToolboxAid ToolboxAid merged commit 145aacf into main Jun 26, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7cb0fa085

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +88 to +89
assertOrderedRange(min, max);
return min + readRandomValue(randomNext) * (max - min);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject degenerate float ranges

When callers pass an equal min and max, assertOrderedRange permits the range and this returns min, but that value is equal to the exclusive upper bound and is therefore outside the documented [min, max) contract. For example, nextFloat(() => 0, 5, 5) returns 5 instead of rejecting an empty float interval, so callers can receive an out-of-range value for degenerate ranges.

Useful? React with 👍 / 👎.


function readRandomValue(randomNext) {
assertRandomNext(randomNext);
const value = Number(randomNext());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject non-number random results

Because the helper coerces the random source result with Number(...), invalid implementations that return values like null, "", or numeric strings are accepted as valid rolls instead of failing the documented randomNext contract. For example, nextInt(() => null, 1, 3) currently returns 1, which can silently bias every caller toward the lower bound when a broken random source returns a non-number.

Useful? React with 👍 / 👎.

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