Skip to content

Commit f7cb0fa

Browse files
committed
DELTA: add random shared helpers
1 parent 6c1f77e commit f7cb0fa

14 files changed

Lines changed: 901 additions & 528 deletions

docs_build/dev/BUILD_PR.md

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
1-
# PR_26177_DELTA_052-random-seed-utility
1+
# PR_26177_DELTA_053-random-shared-helpers
22

33
## Purpose
44

5-
Add a reusable shared JavaScript `RandomSeed` utility for deterministic seeded random sequences.
5+
Create shared internal helper logic for random utility operations.
66

77
## Source Of Truth
88

9-
This `BUILD_PR.md`, `PLAN_PR.md`, the user request, and `docs_build/dev/ProjectInstructions.zip` are the source of truth for `PR_26177_DELTA_052-random-seed-utility`.
9+
This `BUILD_PR.md`, `PLAN_PR.md`, the user request, and `docs_build/dev/ProjectInstructions.zip` are the source of truth for `PR_26177_DELTA_053-random-shared-helpers`.
1010

1111
## OWNER Override And Team Assignment
1212

13-
OWNER override approved: Assign Team Delta `PR_26177_DELTA_052-random-seed-utility`.
13+
OWNER override approved: Continue Team Delta random utility stack with `PR_26177_DELTA_053-random-shared-helpers`.
1414

1515
Team Delta owns Shared JS, runtime utilities, technical debt remediation, and runtime test coverage.
1616

1717
## Exact Scope
1818

19-
- Add reusable shared JavaScript utility class named `RandomSeed`.
20-
- Constructor accepts an initial seed.
21-
- Include:
22-
- `seed(value)`
23-
- `next()`
24-
- `nextInt(min, max)`
25-
- `nextFloat(min, max)`
26-
- `pick(array)`
27-
- Same seed must reproduce the same sequence after reseeding.
28-
- Different seeds should produce different sequences.
29-
- Add JSDoc.
19+
- Add internal/shared helper functions for:
20+
- `nextInt(randomNext, min, max)`
21+
- `nextFloat(randomNext, min, max)`
22+
- `pick(randomNext, array)`
23+
- `shuffle(randomNext, array)`
24+
- `chance(randomNext, percent)`
25+
- `weightedPick(randomNext, weightedItems)`
26+
- Helper must consume a `randomNext` function returning float `>= 0` and `< 1`.
27+
- Do not expose this as Creator-facing API.
28+
- Do not change existing `RandomSeed` behavior.
3029
- Add targeted unit tests.
31-
- Do not replace existing `Math.random()` usage.
32-
- No UI changes.
33-
- No browser storage.
34-
- No API/database changes.
35-
- No unrelated cleanup.
3630
- Create required Codex reports under `docs_build/dev/reports/`.
3731
- Create repo-structured delta ZIP under `tmp/`.
3832

@@ -42,25 +36,26 @@ Team Delta owns Shared JS, runtime utilities, technical debt remediation, and ru
4236
- `docs_build/dev/BUILD_PR.md`
4337
- `docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md`
4438
- `docs_build/dev/ProjectInstructions/team_assignments/ACTIVE_TEAM_REGISTRY.md`
45-
- `src/shared/math/RandomSeed.js`
46-
- `tests/shared/RandomSeed.test.mjs`
47-
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility.md`
48-
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_branch-validation.md`
49-
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_requirement-checklist.md`
50-
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_validation-lane.md`
51-
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_manual-validation-notes.md`
52-
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_instruction-compliance-checklist.md`
39+
- `src/shared/math/randomHelpers.js`
40+
- `tests/shared/RandomHelpers.test.mjs`
41+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers.md`
42+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_branch-validation.md`
43+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_requirement-checklist.md`
44+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_validation-lane.md`
45+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_manual-validation-notes.md`
46+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_instruction-compliance-checklist.md`
5347
- `docs_build/dev/reports/codex_review.diff`
5448
- `docs_build/dev/reports/codex_changed_files.txt`
5549

5650
## Out Of Scope
5751

52+
- No Creator-facing API exposure.
53+
- No existing `RandomSeed` behavior changes.
5854
- No existing `Math.random()` call-site replacements.
5955
- No UI changes.
6056
- No browser storage changes.
6157
- No API changes.
6258
- No database changes.
63-
- No engine core changes outside the new shared utility.
6459
- No `start_of_day` folder changes.
6560
- No unrelated cleanup.
6661

@@ -69,18 +64,18 @@ Team Delta owns Shared JS, runtime utilities, technical debt remediation, and ru
6964
Run exactly:
7065

7166
```powershell
72-
node ./scripts/run-node-test-files.mjs tests/shared/RandomSeed.test.mjs
73-
node --check src/shared/math/RandomSeed.js
74-
node --check tests/shared/RandomSeed.test.mjs
67+
node ./scripts/run-node-test-files.mjs tests/shared/RandomHelpers.test.mjs tests/shared/RandomSeed.test.mjs
68+
node --check src/shared/math/randomHelpers.js
69+
node --check tests/shared/RandomHelpers.test.mjs
7570
git diff --check
7671
```
7772

78-
Playwright is not required because this PR does not change UI or browser runtime behavior.
73+
Playwright is not required because this PR does not change UI or browser runtime flows.
7974

8075
## Artifact
8176

8277
Create repo-structured delta ZIP:
8378

8479
```text
85-
tmp/PR_26177_DELTA_052-random-seed-utility_delta.zip
80+
tmp/PR_26177_DELTA_053-random-shared-helpers_delta.zip
8681
```

docs_build/dev/PLAN_PR.md

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,40 @@
1-
# PLAN_PR: PR_26177_DELTA_052-random-seed-utility
1+
# PLAN_PR: PR_26177_DELTA_053-random-shared-helpers
22

33
## Purpose
44

5-
Add a reusable shared JavaScript `RandomSeed` utility for deterministic seeded random sequences.
5+
Create shared internal helper logic for random utility operations.
66

77
## Owner And Assignment
88

99
- Team: Delta
10-
- OWNER override approved: Assign Team Delta `PR_26177_DELTA_052-random-seed-utility`.
10+
- OWNER override approved: Continue Team Delta random utility stack with `PR_26177_DELTA_053-random-shared-helpers`.
1111
- Ownership fit: Team Delta owns Shared JS, runtime utilities, technical debt remediation, and runtime test coverage.
1212

1313
## Scope
1414

15-
- Add a shared JavaScript utility class named `RandomSeed`.
16-
- Constructor accepts an initial seed.
17-
- Include:
18-
- `seed(value)`
19-
- `next()`
20-
- `nextInt(min, max)`
21-
- `nextFloat(min, max)`
22-
- `pick(array)`
23-
- Add JSDoc for the utility and public methods.
15+
- Add internal/shared helper functions for:
16+
- `nextInt(randomNext, min, max)`
17+
- `nextFloat(randomNext, min, max)`
18+
- `pick(randomNext, array)`
19+
- `shuffle(randomNext, array)`
20+
- `chance(randomNext, percent)`
21+
- `weightedPick(randomNext, weightedItems)`
22+
- Helper functions must consume a `randomNext` function returning a float `>= 0` and `< 1`.
23+
- Do not expose these helpers as Creator-facing API.
24+
- Do not change existing `RandomSeed` behavior.
2425
- Add targeted unit tests.
25-
- Do not replace existing `Math.random()` usage.
26-
- No UI changes.
27-
- No browser storage.
28-
- No API/database changes.
29-
- No unrelated cleanup.
3026

3127
## Implementation Plan
3228

33-
1. Add `src/shared/math/RandomSeed.js`.
34-
2. Add `tests/shared/RandomSeed.test.mjs`.
35-
3. Validate deterministic reseeding, different-seed divergence, numeric ranges, and array picking.
36-
4. Run targeted unit tests for `RandomSeed`.
37-
5. Run changed-file syntax checks for the new JS and test files.
38-
6. Produce required reports and repo-structured ZIP.
29+
1. Add `src/shared/math/randomHelpers.js`.
30+
2. Add `tests/shared/RandomHelpers.test.mjs`.
31+
3. Validate helper behavior and input guards with targeted unit tests.
32+
4. Preserve current `RandomSeed` implementation and tests unchanged.
33+
5. Produce required PR reports and repo-structured ZIP.
3934

4035
## Acceptance Criteria
4136

42-
- Same seed reproduces the same sequence after reseeding.
43-
- Different seeds produce different sequences.
44-
- `next()` returns deterministic normalized values.
45-
- `nextInt(min, max)` returns deterministic inclusive integers inside range.
46-
- `nextFloat(min, max)` returns deterministic floats inside range.
47-
- `pick(array)` returns deterministic values from the provided array.
48-
- Existing `Math.random()` usage remains unchanged.
37+
- Helpers use only the supplied `randomNext` source.
38+
- Integer, float, pick, shuffle, chance, and weighted pick operations are covered.
39+
- Invalid `randomNext`, ranges, arrays, percentages, and weighted item inputs reject predictably.
40+
- Existing `RandomSeed` behavior remains unchanged.

docs_build/dev/ProjectInstructions/team_assignments/ACTIVE_TEAM_REGISTRY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ If a team has no assignment, no active branch, and no active PR, it is inactive
3131
| Team Alfa | none | none | none | Available | Active ownership lane |
3232
| Team Bravo | none | none | none | Available | Active ownership lane |
3333
| Team Charlie | none | none | none | Available | Active ownership lane |
34-
| Team Delta | PR_26177_DELTA_052-random-seed-utility | PR_26177_DELTA_052-random-seed-utility | PR_26177_DELTA_052-random-seed-utility | Active | OWNER override approved: Assign Team Delta PR_26177_DELTA_052-random-seed-utility |
34+
| Team Delta | PR_26177_DELTA_053-random-shared-helpers | PR_26177_DELTA_053-random-shared-helpers | PR_26177_DELTA_053-random-shared-helpers | Active | OWNER override approved: Continue Team Delta random utility stack with PR_26177_DELTA_053-random-shared-helpers |
3535
| Team Golf | none | none | none | Available | Replacement active ownership lane for retired Team Gamma |
3636
| Team OWNER | none | none | none | Available | Governance Phase 1 complete |
3737

docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
| Team Alfa | none | none | none | Available |
88
| Team Bravo | none | none | none | Available |
99
| Team Charlie | none | none | none | Available |
10-
| Team Delta | PR_26177_DELTA_052-random-seed-utility | PR_26177_DELTA_052-random-seed-utility | PR_26177_DELTA_052-random-seed-utility | Active |
10+
| Team Delta | PR_26177_DELTA_053-random-shared-helpers | PR_26177_DELTA_053-random-shared-helpers | PR_26177_DELTA_053-random-shared-helpers | Active |
1111
| Team Golf | none | none | none | Available |
1212
| Team OWNER | none | none | none | Available |
1313

@@ -50,13 +50,13 @@ Current OWNER clarification:
5050

5151
Status: Active
5252

53-
Active assignment: PR_26177_DELTA_052-random-seed-utility.
53+
Active assignment: PR_26177_DELTA_053-random-shared-helpers.
5454

55-
Active branch: PR_26177_DELTA_052-random-seed-utility.
55+
Active branch: PR_26177_DELTA_053-random-shared-helpers.
5656

57-
Active PR: PR_26177_DELTA_052-random-seed-utility.
57+
Active PR: PR_26177_DELTA_053-random-shared-helpers.
5858

59-
OWNER override approved: Assign Team Delta PR_26177_DELTA_052-random-seed-utility.
59+
OWNER override approved: Continue Team Delta random utility stack with PR_26177_DELTA_053-random-shared-helpers.
6060

6161
## Team Bravo
6262

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# PR_26177_DELTA_053-random-shared-helpers
2+
3+
Date: 2026-06-26
4+
Team: Delta
5+
Scope: Shared internal random helper logic and targeted unit tests
6+
Status: PASS
7+
8+
## Summary
9+
10+
- Added internal shared random helper functions in `src/shared/math/randomHelpers.js`.
11+
- Added helpers for `nextInt`, `nextFloat`, `pick`, `shuffle`, `chance`, and `weightedPick`.
12+
- Helpers consume caller-provided `randomNext` functions returning floats `>= 0` and `< 1`.
13+
- Kept helpers as shared internal code only; no Creator-facing API was added.
14+
- Preserved existing `RandomSeed` behavior and did not change its implementation in this PR.
15+
- Added targeted unit tests in `tests/shared/RandomHelpers.test.mjs`.
16+
- Updated Team Delta active assignment metadata for the stacked random utility workstream.
17+
18+
## Branch Validation
19+
20+
PASS. Branch `PR_26177_DELTA_053-random-shared-helpers` was created from clean synchronized `main` after PR_052 merged.
21+
22+
## Changed Files
23+
24+
- `docs_build/dev/PLAN_PR.md`
25+
- `docs_build/dev/BUILD_PR.md`
26+
- `docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md`
27+
- `docs_build/dev/ProjectInstructions/team_assignments/ACTIVE_TEAM_REGISTRY.md`
28+
- `src/shared/math/randomHelpers.js`
29+
- `tests/shared/RandomHelpers.test.mjs`
30+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers.md`
31+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_branch-validation.md`
32+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_requirement-checklist.md`
33+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_validation-lane.md`
34+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_manual-validation-notes.md`
35+
- `docs_build/dev/reports/PR_26177_DELTA_053-random-shared-helpers_instruction-compliance-checklist.md`
36+
- `docs_build/dev/reports/codex_changed_files.txt`
37+
- `docs_build/dev/reports/codex_review.diff`
38+
39+
## Validation
40+
41+
- PASS: `node ./scripts/run-node-test-files.mjs tests/shared/RandomHelpers.test.mjs tests/shared/RandomSeed.test.mjs`
42+
- PASS: `node --check src/shared/math/randomHelpers.js`
43+
- PASS: `node --check tests/shared/RandomHelpers.test.mjs`
44+
- PASS: `git diff --check`
45+
- SKIP: Playwright was not run because this PR does not change UI or browser runtime flows.
46+
47+
## Artifact
48+
49+
- `tmp/PR_26177_DELTA_053-random-shared-helpers_delta.zip`
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# PR_26177_DELTA_053-random-shared-helpers Branch Validation
2+
3+
Status: PASS
4+
5+
## Start Gates
6+
7+
- PASS: PR_052 was merged before starting PR_053.
8+
- PASS: Current branch was `main` before creating PR_053.
9+
- PASS: `main` worktree was clean and synchronized with `origin/main`.
10+
- PASS: Branch `PR_26177_DELTA_053-random-shared-helpers` was created from `main`.
11+
12+
## Scope Confirmation
13+
14+
- PASS: Work is assigned to Team Delta.
15+
- PASS: Work is limited to shared internal random helper logic, targeted tests, PR docs, reports, and ZIP packaging.
16+
- PASS: No Creator-facing API, UI, browser storage, API, database, or unrelated cleanup changes were made.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# PR_26177_DELTA_053-random-shared-helpers Instruction Compliance Checklist
2+
3+
| Instruction | Status | Notes |
4+
|---|---:|---|
5+
| Read `ProjectInstructions.zip` and `README.txt` first | PASS | Read `ProjectInstructions/README.txt` before work. |
6+
| Merge PR_052 before starting stacked PRs | PASS | PR #204 was merged and `main` synced first. |
7+
| Keep one PR purpose only | PASS | Scope is shared internal random helper logic. |
8+
| Use Team Delta ownership | PASS | Team Delta owns Shared JS and runtime test coverage. |
9+
| Do not expose Creator-facing API | PASS | No Creator-facing surface was added. |
10+
| Produce required reports | PASS | Reports were added under `docs_build/dev/reports/`. |
11+
| Produce repo-structured ZIP under `tmp/` | PASS | ZIP path is `tmp/PR_26177_DELTA_053-random-shared-helpers_delta.zip`. |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# PR_26177_DELTA_053-random-shared-helpers Manual Validation Notes
2+
3+
Status: PASS
4+
5+
Manual review confirmed:
6+
7+
- Helper functions are shared internal JavaScript utilities under `src/shared/math/`.
8+
- The helpers are not wired into existing game logic or Creator-facing surfaces.
9+
- Existing `RandomSeed` behavior was preserved by leaving `RandomSeed.js` unchanged in this PR.
10+
- Unit tests cover deterministic helper behavior and input validation.
11+
- No browser storage, UI, API, database, or `start_of_day` files changed.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# PR_26177_DELTA_053-random-shared-helpers Requirement Checklist
2+
3+
| Requirement | Status | Notes |
4+
|---|---:|---|
5+
| Add `nextInt(randomNext, min, max)` helper | PASS | Added in `src/shared/math/randomHelpers.js`. |
6+
| Add `nextFloat(randomNext, min, max)` helper | PASS | Added in `src/shared/math/randomHelpers.js`. |
7+
| Add `pick(randomNext, array)` helper | PASS | Added in `src/shared/math/randomHelpers.js`. |
8+
| Add `shuffle(randomNext, array)` helper | PASS | Added in `src/shared/math/randomHelpers.js`. |
9+
| Add `chance(randomNext, percent)` helper | PASS | Added in `src/shared/math/randomHelpers.js`. |
10+
| Add `weightedPick(randomNext, weightedItems)` helper | PASS | Added in `src/shared/math/randomHelpers.js`. |
11+
| Helpers consume `randomNext` returning float `>= 0` and `< 1` | PASS | Helpers validate `randomNext` output before use. |
12+
| Do not expose as Creator-facing API | PASS | No UI, tool, or barrel export exposure was added. |
13+
| Do not change existing `RandomSeed` behavior | PASS | `RandomSeed.js` was not changed in this PR; existing test passed. |
14+
| Add targeted unit tests | PASS | Added `tests/shared/RandomHelpers.test.mjs`. |
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# PR_26177_DELTA_053-random-shared-helpers Validation Lane
2+
3+
Status: PASS
4+
5+
## Commands
6+
7+
```powershell
8+
node ./scripts/run-node-test-files.mjs tests/shared/RandomHelpers.test.mjs tests/shared/RandomSeed.test.mjs
9+
node --check src/shared/math/randomHelpers.js
10+
node --check tests/shared/RandomHelpers.test.mjs
11+
git diff --check
12+
```
13+
14+
## Results
15+
16+
- PASS: `tests/shared/RandomHelpers.test.mjs`
17+
- PASS: `tests/shared/RandomSeed.test.mjs`
18+
- PASS: `src/shared/math/randomHelpers.js` syntax check
19+
- PASS: `tests/shared/RandomHelpers.test.mjs` syntax check
20+
- PASS: `git diff --check`
21+
22+
## Playwright
23+
24+
SKIP. Playwright was not run because this PR does not change UI or browser runtime flows.

0 commit comments

Comments
 (0)