Skip to content

Commit 8cdd87b

Browse files
authored
Merge pull request #208 from ToolboxAid/PR_26177_DELTA_056-shared-validation-assertions
PR_26177_DELTA_056-shared-validation-assertions
2 parents 988b835 + bf01a96 commit 8cdd87b

14 files changed

Lines changed: 483 additions & 496 deletions

docs_build/dev/BUILD_PR.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
1-
# PR_26177_DELTA_055-random-seed-enhancements
1+
# PR_26177_DELTA_056-shared-validation-assertions
22

33
## Purpose
44

5-
Enhance `RandomSeed` with matching procedural convenience methods.
5+
Move generic validation/assertion helpers out of random helper code into a shared validation module.
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_055-random-seed-enhancements`.
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_056-shared-validation-assertions`.
1010

1111
## OWNER Override And Team Assignment
1212

13-
OWNER override approved: Continue Team Delta random utility stack with `PR_26177_DELTA_055-random-seed-enhancements`.
13+
OWNER override approved: Continue Team Delta random utility stack with `PR_26177_DELTA_056-shared-validation-assertions`.
1414

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

1717
## Stack
1818

19-
- Base branch: `PR_26177_DELTA_054-random-utility`
20-
- This PR depends on the shared helper module from PR_053 and the stack context from PR_054.
19+
- Base branch: `PR_26177_DELTA_055-random-seed-enhancements`
20+
- This PR depends on the random helper module from PR_053, `Random` from PR_054, and `RandomSeed` enhancements from PR_055.
2121

2222
## Exact Scope
2323

24-
- Update `RandomSeed` to use shared helper logic where appropriate.
25-
- Add:
26-
- `shuffle(array)`
27-
- `chance(percent)`
28-
- `weightedPick(weightedItems)`
29-
- `saveState()`
30-
- `restoreState(state)`
31-
- Preserve existing `RandomSeed` sequence compatibility.
32-
- Same seed must still reproduce same sequence.
33-
- Reseeding must still reproduce same sequence.
34-
- Add targeted unit tests for new methods.
35-
- No adoption changes in existing game logic.
24+
- Create `src/shared/validation/assert.js`.
25+
- Move generic assertion helpers from random helper code into `assert.js`.
26+
- Include only generic reusable validation functions needed by current random helpers:
27+
- `assertArray`
28+
- `assertFiniteNumber`
29+
- `assertOrderedRange`
30+
- Update random helper code to import from `src/shared/validation/assert.js`.
31+
- Preserve existing `Random` and `RandomSeed` behavior.
32+
- Do not change public API.
33+
- Do not expand into unrelated validation functions yet.
34+
- Add/update targeted unit tests if needed.
3635
- No UI changes.
36+
- No API/database changes.
37+
- No unrelated cleanup.
3738
- Create required Codex reports under `docs_build/dev/reports/`.
3839
- Create repo-structured delta ZIP under `tmp/`.
3940

@@ -43,20 +44,21 @@ Team Delta owns Shared JS, runtime utilities, technical debt remediation, and ru
4344
- `docs_build/dev/BUILD_PR.md`
4445
- `docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md`
4546
- `docs_build/dev/ProjectInstructions/team_assignments/ACTIVE_TEAM_REGISTRY.md`
46-
- `src/shared/math/RandomSeed.js`
47-
- `tests/shared/RandomSeed.test.mjs`
48-
- `docs_build/dev/reports/PR_26177_DELTA_055-random-seed-enhancements.md`
49-
- `docs_build/dev/reports/PR_26177_DELTA_055-random-seed-enhancements_branch-validation.md`
50-
- `docs_build/dev/reports/PR_26177_DELTA_055-random-seed-enhancements_requirement-checklist.md`
51-
- `docs_build/dev/reports/PR_26177_DELTA_055-random-seed-enhancements_validation-lane.md`
52-
- `docs_build/dev/reports/PR_26177_DELTA_055-random-seed-enhancements_manual-validation-notes.md`
53-
- `docs_build/dev/reports/PR_26177_DELTA_055-random-seed-enhancements_instruction-compliance-checklist.md`
47+
- `src/shared/validation/assert.js`
48+
- `src/shared/math/randomHelpers.js`
49+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions.md`
50+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_branch-validation.md`
51+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_requirement-checklist.md`
52+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_validation-lane.md`
53+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_manual-validation-notes.md`
54+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_instruction-compliance-checklist.md`
5455
- `docs_build/dev/reports/codex_review.diff`
5556
- `docs_build/dev/reports/codex_changed_files.txt`
5657

5758
## Out Of Scope
5859

59-
- No seeded `next()` algorithm changes.
60+
- No public API changes.
61+
- No new unrelated validation helpers.
6062
- No existing game logic adoption changes.
6163
- No UI changes.
6264
- No browser storage changes.
@@ -70,9 +72,9 @@ Team Delta owns Shared JS, runtime utilities, technical debt remediation, and ru
7072
Run exactly:
7173

7274
```powershell
73-
node ./scripts/run-node-test-files.mjs tests/shared/RandomSeed.test.mjs tests/shared/RandomHelpers.test.mjs
74-
node --check src/shared/math/RandomSeed.js
75-
node --check tests/shared/RandomSeed.test.mjs
75+
node ./scripts/run-node-test-files.mjs tests/shared/RandomHelpers.test.mjs tests/shared/Random.test.mjs tests/shared/RandomSeed.test.mjs
76+
node --check src/shared/validation/assert.js
77+
node --check src/shared/math/randomHelpers.js
7678
git diff --check
7779
```
7880

@@ -83,5 +85,5 @@ Playwright is not required because this PR does not change UI or browser runtime
8385
Create repo-structured delta ZIP:
8486

8587
```text
86-
tmp/PR_26177_DELTA_055-random-seed-enhancements_delta.zip
88+
tmp/PR_26177_DELTA_056-shared-validation-assertions_delta.zip
8789
```

docs_build/dev/PLAN_PR.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
1-
# PLAN_PR: PR_26177_DELTA_055-random-seed-enhancements
1+
# PLAN_PR: PR_26177_DELTA_056-shared-validation-assertions
22

33
## Purpose
44

5-
Enhance `RandomSeed` with matching procedural convenience methods.
5+
Move generic validation/assertion helpers out of random helper code into a shared validation module.
66

77
## Owner And Assignment
88

99
- Team: Delta
10-
- OWNER override approved: Continue Team Delta random utility stack with `PR_26177_DELTA_055-random-seed-enhancements`.
11-
- Stack base: `PR_26177_DELTA_054-random-utility`.
10+
- OWNER override approved: Continue Team Delta random utility stack with `PR_26177_DELTA_056-shared-validation-assertions`.
11+
- Stack base: `PR_26177_DELTA_055-random-seed-enhancements`.
1212

1313
## Scope
1414

15-
- Update `RandomSeed` to use shared helper logic where appropriate.
16-
- Add:
17-
- `shuffle(array)`
18-
- `chance(percent)`
19-
- `weightedPick(weightedItems)`
20-
- `saveState()`
21-
- `restoreState(state)`
22-
- Preserve existing `RandomSeed` sequence compatibility.
23-
- Same seed must still reproduce same sequence.
24-
- Reseeding must still reproduce same sequence.
25-
- Add targeted unit tests for new methods.
26-
- No adoption changes in existing game logic.
15+
- Create `src/shared/validation/assert.js`.
16+
- Move generic assertion helpers from random helper code into `assert.js`.
17+
- Include only generic reusable validation functions needed by current random helpers:
18+
- `assertArray`
19+
- `assertFiniteNumber`
20+
- `assertOrderedRange`
21+
- Update random helper code to import from `src/shared/validation/assert.js`.
22+
- Preserve existing `Random` and `RandomSeed` behavior.
23+
- Do not change public API.
24+
- Do not expand into unrelated validation functions yet.
25+
- Add/update targeted unit tests if needed.
2726
- No UI changes.
27+
- No API/database changes.
28+
- No unrelated cleanup.
2829

2930
## Implementation Plan
3031

31-
1. Update `src/shared/math/RandomSeed.js` to reuse `randomHelpers.js` for procedural helper methods.
32-
2. Keep the existing seeded `next()` algorithm unchanged.
33-
3. Add state save/restore methods.
34-
4. Extend `tests/shared/RandomSeed.test.mjs` with sequence compatibility, new method, and state tests.
32+
1. Add `src/shared/validation/assert.js` with only the required generic assertion helpers.
33+
2. Remove duplicated generic assertions from `src/shared/math/randomHelpers.js`.
34+
3. Import the shared assertions from `randomHelpers.js`.
35+
4. Run targeted random helper, `Random`, and `RandomSeed` tests.
3536
5. Produce required PR reports and repo-structured ZIP.
3637

3738
## Acceptance Criteria
3839

39-
- Existing seeded sequence values remain compatible.
40-
- Same seed and reseeding behavior remain deterministic.
41-
- New procedural methods use the same seeded random stream.
42-
- State save/restore resumes the sequence from the saved point.
40+
- Existing random helper behavior is preserved.
41+
- Existing `Random` and `RandomSeed` behavior is preserved.
42+
- Public random APIs are unchanged.
43+
- Shared assertion module stays limited to the current reusable validation helpers.

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_055-random-seed-enhancements | PR_26177_DELTA_055-random-seed-enhancements | PR_26177_DELTA_055-random-seed-enhancements | Active | OWNER override approved: Continue Team Delta random utility stack with PR_26177_DELTA_055-random-seed-enhancements |
34+
| Team Delta | PR_26177_DELTA_056-shared-validation-assertions | PR_26177_DELTA_056-shared-validation-assertions | PR_26177_DELTA_056-shared-validation-assertions | Active | OWNER override approved: Continue Team Delta random utility stack with PR_26177_DELTA_056-shared-validation-assertions |
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_055-random-seed-enhancements | PR_26177_DELTA_055-random-seed-enhancements | PR_26177_DELTA_055-random-seed-enhancements | Active |
10+
| Team Delta | PR_26177_DELTA_056-shared-validation-assertions | PR_26177_DELTA_056-shared-validation-assertions | PR_26177_DELTA_056-shared-validation-assertions | 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_055-random-seed-enhancements.
53+
Active assignment: PR_26177_DELTA_056-shared-validation-assertions.
5454

55-
Active branch: PR_26177_DELTA_055-random-seed-enhancements.
55+
Active branch: PR_26177_DELTA_056-shared-validation-assertions.
5656

57-
Active PR: PR_26177_DELTA_055-random-seed-enhancements.
57+
Active PR: PR_26177_DELTA_056-shared-validation-assertions.
5858

59-
OWNER override approved: Continue Team Delta random utility stack with PR_26177_DELTA_055-random-seed-enhancements.
59+
OWNER override approved: Continue Team Delta random utility stack with PR_26177_DELTA_056-shared-validation-assertions.
6060

6161
## Team Bravo
6262

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# PR_26177_DELTA_056-shared-validation-assertions
2+
3+
Date: 2026-06-26
4+
Team: Delta
5+
Scope: Shared validation assertions extracted from random helper code
6+
Status: PASS
7+
8+
## Summary
9+
10+
- Added `src/shared/validation/assert.js`.
11+
- Moved generic reusable assertion helpers out of `src/shared/math/randomHelpers.js`.
12+
- Included only the current generic assertion helpers needed by random helpers: `assertArray`, `assertFiniteNumber`, and `assertOrderedRange`.
13+
- Updated `randomHelpers.js` to import those assertions from the shared validation module.
14+
- Preserved existing `Random`, `RandomSeed`, and random helper behavior.
15+
- Did not change public API.
16+
- Did not add unrelated validation helpers.
17+
- No UI, API, database, or unrelated cleanup changes were made.
18+
19+
## Branch Validation
20+
21+
PASS. Branch `PR_26177_DELTA_056-shared-validation-assertions` was created from clean `PR_26177_DELTA_055-random-seed-enhancements`.
22+
23+
## Changed Files
24+
25+
- `docs_build/dev/PLAN_PR.md`
26+
- `docs_build/dev/BUILD_PR.md`
27+
- `docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md`
28+
- `docs_build/dev/ProjectInstructions/team_assignments/ACTIVE_TEAM_REGISTRY.md`
29+
- `src/shared/validation/assert.js`
30+
- `src/shared/math/randomHelpers.js`
31+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions.md`
32+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_branch-validation.md`
33+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_requirement-checklist.md`
34+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_validation-lane.md`
35+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_manual-validation-notes.md`
36+
- `docs_build/dev/reports/PR_26177_DELTA_056-shared-validation-assertions_instruction-compliance-checklist.md`
37+
- `docs_build/dev/reports/codex_changed_files.txt`
38+
- `docs_build/dev/reports/codex_review.diff`
39+
40+
## Validation
41+
42+
- PASS: `node ./scripts/run-node-test-files.mjs tests/shared/RandomHelpers.test.mjs tests/shared/Random.test.mjs tests/shared/RandomSeed.test.mjs`
43+
- PASS: `node --check src/shared/validation/assert.js`
44+
- PASS: `node --check src/shared/math/randomHelpers.js`
45+
- PASS: `git diff --check`
46+
- SKIP: Playwright was not run because this PR does not change UI or browser runtime flows.
47+
48+
## Artifact
49+
50+
- `tmp/PR_26177_DELTA_056-shared-validation-assertions_delta.zip`
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# PR_26177_DELTA_056-shared-validation-assertions Branch Validation
2+
3+
Status: PASS
4+
5+
## Start Gates
6+
7+
- PASS: Current branch was `PR_26177_DELTA_055-random-seed-enhancements`.
8+
- PASS: Worktree was clean before creating PR_056.
9+
- PASS: Branch `PR_26177_DELTA_056-shared-validation-assertions` was created from PR_055.
10+
11+
## Scope Confirmation
12+
13+
- PASS: Work is assigned to Team Delta.
14+
- PASS: Work is limited to extracting generic assertions used by random helpers.
15+
- PASS: No public 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_056-shared-validation-assertions 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+
| Create PR_056 as stacked PR on current branch | PASS | Branch was created from `PR_26177_DELTA_055-random-seed-enhancements`. |
7+
| Hard stop if branch/worktree gates fail | PASS | Branch and clean worktree gates passed. |
8+
| Keep one PR purpose only | PASS | Scope is shared validation assertion extraction. |
9+
| Do not change public API | PASS | No public API changes were made. |
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_056-shared-validation-assertions_delta.zip`. |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# PR_26177_DELTA_056-shared-validation-assertions Manual Validation Notes
2+
3+
Status: PASS
4+
5+
Manual review confirmed:
6+
7+
- The extracted assertions are generic and reusable.
8+
- `assert.js` intentionally contains only `assertArray`, `assertFiniteNumber`, and `assertOrderedRange`.
9+
- Random helper behavior is preserved through imports from the shared validation module.
10+
- `Random` and `RandomSeed` public APIs are unchanged.
11+
- No UI, browser storage, API, database, or unrelated files changed.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# PR_26177_DELTA_056-shared-validation-assertions Requirement Checklist
2+
3+
| Requirement | Status | Notes |
4+
|---|---:|---|
5+
| Create `src/shared/validation/assert.js` | PASS | New shared validation module added. |
6+
| Move generic assertion helpers from random helper code into `assert.js` | PASS | `assertArray`, `assertFiniteNumber`, and `assertOrderedRange` were extracted. |
7+
| Include only generic reusable validation functions needed by current random helpers | PASS | No unrelated validation helpers were added. |
8+
| Update random helper code to import from `src/shared/validation/assert.js` | PASS | `randomHelpers.js` now imports from shared validation. |
9+
| Preserve existing `Random` behavior | PASS | Targeted `Random` tests pass. |
10+
| Preserve existing `RandomSeed` behavior | PASS | Targeted `RandomSeed` tests pass. |
11+
| Do not change public API | PASS | No public API methods or call sites changed. |
12+
| Do not expand into unrelated validation functions yet | PASS | Module includes only the requested assertions. |
13+
| Add/update targeted unit tests if needed | PASS | Existing targeted random tests cover behavior after extraction. |
14+
| No UI changes | PASS | No UI files changed. |
15+
| No API/database changes | PASS | No API or database files changed. |
16+
| No unrelated cleanup | PASS | Changes stayed scoped to assertion extraction and reports. |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# PR_26177_DELTA_056-shared-validation-assertions 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/Random.test.mjs tests/shared/RandomSeed.test.mjs
9+
node --check src/shared/validation/assert.js
10+
node --check src/shared/math/randomHelpers.js
11+
git diff --check
12+
```
13+
14+
## Results
15+
16+
- PASS: `tests/shared/RandomHelpers.test.mjs`
17+
- PASS: `tests/shared/Random.test.mjs`
18+
- PASS: `tests/shared/RandomSeed.test.mjs`
19+
- PASS: `src/shared/validation/assert.js` syntax check
20+
- PASS: `src/shared/math/randomHelpers.js` syntax check
21+
- PASS: `git diff --check`
22+
23+
## Playwright
24+
25+
SKIP. Playwright was not run because this PR does not change UI or browser runtime flows.

0 commit comments

Comments
 (0)