Skip to content

Commit 6c1f77e

Browse files
authored
Merge pull request #204 from ToolboxAid/PR_26177_DELTA_052-random-seed-utility
PR_26177_DELTA_052-random-seed-utility
2 parents 0e9aa23 + 9640434 commit 6c1f77e

14 files changed

Lines changed: 991 additions & 681 deletions

docs_build/dev/BUILD_PR.md

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,86 @@
1-
# PR_26177_OWNER_051-environment-configuration-standards
1+
# PR_26177_DELTA_052-random-seed-utility
22

33
## Purpose
44

5-
Define the official Game Foundry Studio environment configuration standards that build on the OWNER_050 environment model.
5+
Add a reusable shared JavaScript `RandomSeed` utility for deterministic seeded random sequences.
66

77
## Source Of Truth
88

9-
This `BUILD_PR.md` and the user request are the source of truth for `PR_26177_OWNER_051-environment-configuration-standards`.
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`.
10+
11+
## OWNER Override And Team Assignment
12+
13+
OWNER override approved: Assign Team Delta `PR_26177_DELTA_052-random-seed-utility`.
14+
15+
Team Delta owns Shared JS, runtime utilities, technical debt remediation, and runtime test coverage.
1016

1117
## Exact Scope
1218

13-
- Governance/documentation only.
14-
- Build on OWNER_050 environment model.
15-
- Standardize environment file names:
16-
- `.env.local`
17-
- `.env.dev`
18-
- `.env.ist`
19-
- `.env.uat`
20-
- `.env.prod`
21-
- Treat `.env.prd` as legacy technical debt only.
22-
- Add `GAMEFOUNDRY_ENVIRONMENT` allowed values:
23-
- `local`
24-
- `dev`
25-
- `ist`
26-
- `uat`
27-
- `prod`
28-
- Keep `GAMEFOUNDRY_ENVIRONMENT_LABEL` display-only.
29-
- Document that only `.env` values and environment-managed secrets differ.
30-
- Document that the deployable artifact must remain identical.
31-
- Document one shared API/service contract.
32-
- Document feature flags cannot create permanent environment-specific behavior.
33-
- Review `.env.example` comments/placeholders only.
34-
- Clarify that only `.env.example` is committed to the repository.
35-
- Clarify that real `.env` files are user/environment-owned and must live outside the repo clone or be injected by deployment.
36-
- Document the external `/env/<target>/.env` layout next to the `/GFS/` repo clone.
37-
- Do not change runtime behavior.
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.
30+
- 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.
3836
- Create required Codex reports under `docs_build/dev/reports/`.
3937
- Create repo-structured delta ZIP under `tmp/`.
4038

4139
## Exact Targets
4240

41+
- `docs_build/dev/PLAN_PR.md`
4342
- `docs_build/dev/BUILD_PR.md`
44-
- `docs_build/dev/PROJECT_INSTRUCTIONS.md`
45-
- `docs_build/dev/ProjectInstructions/PROJECT_INSTRUCTIONS.md`
46-
- `docs_build/dev/ProjectInstructions/README.txt`
47-
- `docs_build/dev/ProjectInstructions/addendums/environment_configuration_standards.md`
48-
- `docs_build/dev/ProjectInstructions/addendums/environment_governance_model.md`
49-
- `docs_build/dev/ProjectInstructions/addendums/release_gate.md`
50-
- `.env.example`
51-
- `docs_build/dev/reports/PR_26177_OWNER_051-environment-configuration-standards.md`
52-
- `docs_build/dev/reports/PR_26177_OWNER_051-environment-configuration-standards_branch-validation.md`
53-
- `docs_build/dev/reports/PR_26177_OWNER_051-environment-configuration-standards_requirement-checklist.md`
54-
- `docs_build/dev/reports/PR_26177_OWNER_051-environment-configuration-standards_validation-lane.md`
55-
- `docs_build/dev/reports/PR_26177_OWNER_051-environment-configuration-standards_manual-validation-notes.md`
56-
- `docs_build/dev/reports/PR_26177_OWNER_051-environment-configuration-standards_instruction-compliance-checklist.md`
43+
- `docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md`
44+
- `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`
5753
- `docs_build/dev/reports/codex_review.diff`
5854
- `docs_build/dev/reports/codex_changed_files.txt`
5955

6056
## Out Of Scope
6157

62-
- No runtime code changes.
58+
- No existing `Math.random()` call-site replacements.
6359
- No UI changes.
64-
- No engine core changes.
60+
- No browser storage changes.
61+
- No API changes.
62+
- No database changes.
63+
- No engine core changes outside the new shared utility.
6564
- No `start_of_day` folder changes.
66-
- No actual `.env`, `.env.local`, `.env.dev`, `.env.ist`, `.env.uat`, `.env.prod`, or `.env.prd` secret/value file edits.
67-
- No committed real `.env.*` copy-source files.
68-
- No API implementation changes.
69-
- No storage implementation changes.
70-
- No database migration or DDL changes.
71-
- No feature flag implementation changes.
65+
- No unrelated cleanup.
7266

7367
## Validation
7468

7569
Run exactly:
7670

7771
```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
7875
git diff --check
7976
```
8077

81-
Playwright is not required unless runtime files change.
78+
Playwright is not required because this PR does not change UI or browser runtime behavior.
8279

8380
## Artifact
8481

8582
Create repo-structured delta ZIP:
8683

8784
```text
88-
tmp/PR_26177_OWNER_051-environment-configuration-standards_delta.zip
85+
tmp/PR_26177_DELTA_052-random-seed-utility_delta.zip
8986
```

docs_build/dev/PLAN_PR.md

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,48 @@
1-
# PLAN_PR: Move JSON schemas under tools ownership
1+
# PLAN_PR: PR_26177_DELTA_052-random-seed-utility
22

33
## Purpose
4-
Move schema contracts out of the repository root and into the tools area so schema ownership matches the systems that load, edit, validate, and export tool/sample data.
4+
5+
Add a reusable shared JavaScript `RandomSeed` utility for deterministic seeded random sequences.
6+
7+
## Owner And Assignment
8+
9+
- Team: Delta
10+
- OWNER override approved: Assign Team Delta `PR_26177_DELTA_052-random-seed-utility`.
11+
- Ownership fit: Team Delta owns Shared JS, runtime utilities, technical debt remediation, and runtime test coverage.
512

613
## Scope
7-
- Do not change runtime behavior directly.
8-
- Do not edit locked samples.
9-
- Do not modify start_of_day folders.
10-
- Establish schema placement rules for Codex to implement in the next pass.
11-
12-
## Schema placement rule
13-
Use this structure:
14-
15-
```text
16-
toolbox/
17-
schemas/
18-
tool.manifest.schema.json
19-
palette.schema.json
20-
samples/
21-
sample.tool-payload.schema.json
22-
toolbox/
23-
vector-map-editor.schema.json
24-
vector-asset-studio.schema.json
25-
sprite-editor.schema.json
26-
```
27-
28-
## Rationale
29-
Schemas belong near tool contracts, not at repository root. The root should stay clean and should not accumulate validation artifacts.
30-
31-
Shared schemas live at `src/shared/schemas/`.
32-
Tool-specific schemas live at `src/shared/schemas/tools/<tool>.schema.json`.
33-
34-
## Acceptance criteria
35-
- No new schema files are added at repository root.
36-
- All JSON schema files are under `src/shared/schemas/`.
37-
- Tool manifest validation uses `src/shared/schemas/tool.manifest.schema.json`.
38-
- Tool-specific payload validation uses `src/shared/schemas/tools/<tool>.schema.json`.
39-
- Samples reference the same tool schema contracts used by tool manifests.
14+
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.
24+
- 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.
30+
31+
## Implementation Plan
32+
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.
39+
40+
## Acceptance Criteria
41+
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.

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 | 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 |
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: 8 additions & 4 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 | 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 |
1111
| Team Golf | none | none | none | Available |
1212
| Team OWNER | none | none | none | Available |
1313

@@ -48,11 +48,15 @@ Current OWNER clarification:
4848

4949
## Team Alfa
5050

51-
Status: Available
51+
Status: Active
5252

53-
Active assignment: none.
53+
Active assignment: PR_26177_DELTA_052-random-seed-utility.
5454

55-
Active branch: none.
55+
Active branch: PR_26177_DELTA_052-random-seed-utility.
56+
57+
Active PR: PR_26177_DELTA_052-random-seed-utility.
58+
59+
OWNER override approved: Assign Team Delta PR_26177_DELTA_052-random-seed-utility.
5660

5761
## Team Bravo
5862

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# PR_26177_DELTA_052-random-seed-utility
2+
3+
Date: 2026-06-26
4+
Team: Delta
5+
Scope: Shared JavaScript utility and targeted unit tests
6+
Status: PASS
7+
8+
## Summary
9+
10+
- Added reusable shared JavaScript utility class `RandomSeed`.
11+
- Implemented constructor seed initialization plus `seed(value)`, `next()`, `nextInt(min, max)`, `nextFloat(min, max)`, and `pick(array)`.
12+
- Added JSDoc for the utility and public methods.
13+
- Verified same-seed reproducibility after reseeding.
14+
- Verified different seeds produce different sequences.
15+
- Added targeted unit tests in `tests/shared/RandomSeed.test.mjs`.
16+
- Preserved existing `Math.random()` usage; no call sites were replaced.
17+
- Updated active Team Delta assignment metadata required by the attached Project Instructions.
18+
- No UI, browser storage, API, database, or unrelated cleanup changes were made.
19+
20+
## Branch Validation
21+
22+
PASS. Work started from clean `main` synchronized with `origin/main` at `0e9aa23eee267edcc6aac0eb660185c4552128c8`.
23+
24+
Current PR branch:
25+
26+
`PR_26177_DELTA_052-random-seed-utility`
27+
28+
## Changed Files
29+
30+
- `docs_build/dev/PLAN_PR.md`
31+
- `docs_build/dev/BUILD_PR.md`
32+
- `docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md`
33+
- `docs_build/dev/ProjectInstructions/team_assignments/ACTIVE_TEAM_REGISTRY.md`
34+
- `src/shared/math/RandomSeed.js`
35+
- `tests/shared/RandomSeed.test.mjs`
36+
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility.md`
37+
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_branch-validation.md`
38+
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_requirement-checklist.md`
39+
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_validation-lane.md`
40+
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_manual-validation-notes.md`
41+
- `docs_build/dev/reports/PR_26177_DELTA_052-random-seed-utility_instruction-compliance-checklist.md`
42+
- `docs_build/dev/reports/codex_changed_files.txt`
43+
- `docs_build/dev/reports/codex_review.diff`
44+
45+
## Validation
46+
47+
- PASS: `node ./scripts/run-node-test-files.mjs tests/shared/RandomSeed.test.mjs`
48+
- PASS: `node --check src/shared/math/RandomSeed.js`
49+
- PASS: `node --check tests/shared/RandomSeed.test.mjs`
50+
- PASS: `git diff --check`
51+
- SKIP: Playwright was not run because no UI or browser runtime files changed.
52+
53+
## Artifact
54+
55+
- `tmp/PR_26177_DELTA_052-random-seed-utility_delta.zip`
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# PR_26177_DELTA_052-random-seed-utility Branch Validation
2+
3+
Status: PASS
4+
5+
## Start Gates
6+
7+
- PASS: Initial branch was `main`.
8+
- PASS: Initial worktree was clean.
9+
- PASS: `main` was synchronized with `origin/main`.
10+
- PASS: PR branch was created from `main`.
11+
12+
## Active Branch
13+
14+
`PR_26177_DELTA_052-random-seed-utility`
15+
16+
## Base Commit
17+
18+
`0e9aa23eee267edcc6aac0eb660185c4552128c8`
19+
20+
## Scope Confirmation
21+
22+
- PASS: Team Delta assignment was OWNER-approved.
23+
- PASS: Work is limited to shared JS utility, targeted test coverage, PR governance docs, reports, and ZIP packaging.
24+
- PASS: No UI, browser storage, API, database, or unrelated cleanup changes were made.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# PR_26177_DELTA_052-random-seed-utility Instruction Compliance Checklist
2+
3+
| Instruction | Status | Notes |
4+
|---|---:|---|
5+
| Read `ProjectInstructions.zip` and `README.txt` first | PASS | Read `ProjectInstructions/README.txt` before applying relevant instructions. |
6+
| Use `main` branch only as start/base | PASS | Start gate confirmed current branch `main` before work. |
7+
| Hard stop if current branch is not `main` | PASS | Branch was `main`. |
8+
| Hard stop if worktree is not clean | PASS | Worktree was clean. |
9+
| Use PR workflow rather than direct commit to `main` | PASS | Created `PR_26177_DELTA_052-random-seed-utility` from `main`. |
10+
| Apply OWNER override assignment to Team Delta | PASS | Assignment documented in active Team Delta metadata. |
11+
| Keep one PR purpose only | PASS | Scope is RandomSeed shared utility and targeted tests. |
12+
| Produce required reports | PASS | Required report files were created under `docs_build/dev/reports/`. |
13+
| Produce repo-structured ZIP under `tmp/` | PASS | ZIP path is `tmp/PR_26177_DELTA_052-random-seed-utility_delta.zip`. |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# PR_26177_DELTA_052-random-seed-utility Manual Validation Notes
2+
3+
Status: PASS
4+
5+
Manual review confirmed:
6+
7+
- `RandomSeed` is opt-in and does not replace existing `Math.random()` usage.
8+
- The utility is in the existing shared math area: `src/shared/math/RandomSeed.js`.
9+
- The class exposes the required public methods.
10+
- The implementation stores generator state in memory only.
11+
- No browser storage, API, database, UI, or start-of-day files were changed.
12+
- Team Delta assignment metadata reflects the OWNER override and active PR branch.
13+
- Playwright is not impacted by this shared utility/test-only change set.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# PR_26177_DELTA_052-random-seed-utility Requirement Checklist
2+
3+
| Requirement | Status | Notes |
4+
|---|---:|---|
5+
| Add reusable shared JavaScript utility class named `RandomSeed` | PASS | Added `src/shared/math/RandomSeed.js`. |
6+
| Constructor accepts an initial seed | PASS | `constructor(initialSeed = 1)` seeds the instance. |
7+
| Include `seed(value)` | PASS | Reseeds and returns the instance. |
8+
| Include `next()` | PASS | Returns deterministic values in `[0, 1)`. |
9+
| Include `nextInt(min, max)` | PASS | Returns inclusive deterministic integers. |
10+
| Include `nextFloat(min, max)` | PASS | Returns deterministic floats in `[min, max)`. |
11+
| Include `pick(array)` | PASS | Deterministically selects from a non-empty array. |
12+
| Same seed reproduces same sequence after reseeding | PASS | Covered by targeted unit test. |
13+
| Different seeds should produce different sequences | PASS | Covered by targeted unit test. |
14+
| Add JSDoc | PASS | Added class and public method JSDoc. |
15+
| Add targeted unit tests | PASS | Added `tests/shared/RandomSeed.test.mjs`. |
16+
| Do not replace existing `Math.random()` usage | PASS | No existing call sites were changed. |
17+
| No UI changes | PASS | No UI files changed. |
18+
| No browser storage | PASS | No storage usage was added. |
19+
| No API/database changes | PASS | No API or database files changed. |
20+
| No unrelated cleanup | PASS | Changes stayed scoped to utility, tests, PR docs, assignment metadata, and reports. |

0 commit comments

Comments
 (0)