Skip to content

Commit 6a8af39

Browse files
author
DavidQ
committed
BUILD PR: remove remaining advanced-local asPositiveInteger duplicates and use shared number utils.
1 parent 1d63875 commit 6a8af39

9 files changed

Lines changed: 108 additions & 27 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_06_PROMOTION_SNAPSHOT_IMPORT_NORMALIZATION.md exactly.
5-
6-
Edit ONLY:
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_07_AS_POSITIVE_INTEGER_ADVANCED_ONLY.md exactly.
5+
Edit only these files:
76
- src/advanced/promotion/createPromotionGate.js
87
- src/advanced/state/createWorldGameStateSystem.js
9-
108
Do not expand scope.
11-
12-
Package output to:
13-
<project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_06_PROMOTION_SNAPSHOT_IMPORT_NORMALIZATION_delta.zip
9+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_07_AS_POSITIVE_INTEGER_ADVANCED_ONLY_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD PR: normalize createPromotionStateSnapshot imports in promotion/state modules only.
1+
BUILD PR: remove remaining advanced-local asPositiveInteger duplicates and use shared number utils.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: continue with next executable BUILD (no APPLY).
1+
Next: if clean, continue with the next executable BUILD. If blocked, capture the exact blocker and narrow further without changing PR purpose.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Normalized import paths for shared promotion snapshot helper to prevent path drift.
1+
Built the next executable shared-extraction step by narrowing to the two remaining advanced modules that still carried local asPositiveInteger definitions in the repo snapshot used for this workflow.

docs/dev/reports/file_tree.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
docs/pr + docs/dev
1+
docs/
2+
pr/
3+
BUILD_PR_SHARED_EXTRACTION_07_AS_POSITIVE_INTEGER_ADVANCED_ONLY.md
4+
dev/
5+
codex_commands.md
6+
commit_comment.txt
7+
next_command.txt
8+
reports/
9+
change_summary.txt
10+
validation_checklist.txt
11+
file_tree.txt
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
SESSION VALIDATION GATE
2-
- BUILD executable: yes
3-
- Exact files listed: yes
4-
- No guessing: yes
5-
- Scope minimal: yes
2+
- Bundle type: BUILD
3+
- One PR purpose only: yes
4+
- Exact target files listed: yes
5+
- Exact import target listed: yes
6+
- No guessing beyond established shared helper path: yes
7+
- Repo-wide scan/refactor language avoided: yes
8+
- Scope minimized: yes
9+
- ZIP repo-structured and execution-ready: yes
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# BUILD_PR_SHARED_EXTRACTION_07_AS_POSITIVE_INTEGER_ADVANCED_ONLY
2+
3+
## Purpose
4+
Remove the remaining duplicated local `asPositiveInteger` helpers from the two advanced promotion/state modules and switch them to the existing shared number helper.
5+
6+
## Single PR Purpose
7+
Centralize `asPositiveInteger` usage in:
8+
9+
- `src/advanced/promotion/createPromotionGate.js`
10+
- `src/advanced/state/createWorldGameStateSystem.js`
11+
12+
This BUILD does **not** change any other helper or file.
13+
14+
## Exact Files Allowed
15+
Edit only these 2 files:
16+
17+
1. `src/advanced/promotion/createPromotionGate.js`
18+
2. `src/advanced/state/createWorldGameStateSystem.js`
19+
20+
Do not edit any other file.
21+
22+
## Shared Dependency Assumption
23+
Use the existing shared helper already established earlier in this workflow:
24+
25+
- `src/shared/utils/numberUtils.js`
26+
27+
This BUILD assumes `numberUtils.js` already exports `asPositiveInteger`.
28+
29+
Do **not** modify `src/shared/utils/numberUtils.js` in this PR.
30+
31+
## Exact Source Changes
32+
33+
### 1) `src/advanced/promotion/createPromotionGate.js`
34+
- remove the local `asPositiveInteger` function definition
35+
- keep all other local helpers exactly as they are
36+
- add exactly one import for `asPositiveInteger` from:
37+
38+
```js
39+
import { asPositiveInteger } from '../../shared/utils/numberUtils.js';
40+
```
41+
42+
If an import for `asPositiveInteger` already exists, do not duplicate it.
43+
44+
### 2) `src/advanced/state/createWorldGameStateSystem.js`
45+
- remove the local `asPositiveInteger` function definition
46+
- keep all other local helpers exactly as they are
47+
- add exactly one import for `asPositiveInteger` from:
48+
49+
```js
50+
import { asPositiveInteger } from '../../shared/utils/numberUtils.js';
51+
```
52+
53+
If an import for `asPositiveInteger` already exists, do not duplicate it.
54+
55+
## Hard Constraints
56+
- do not edit any file other than the 2 listed above
57+
- do not change `asFiniteNumber`
58+
- do not change `isPlainObject`
59+
- do not change `getState`
60+
- do not change promotion snapshot imports
61+
- do not modify logic or behavior
62+
- do not perform repo-wide helper cleanup
63+
- do not create any new file
64+
- do not modify `src/shared/utils/numberUtils.js`
65+
66+
## Validation Checklist
67+
1. Confirm only the 2 listed files changed
68+
2. Confirm local `asPositiveInteger` function definitions no longer exist in:
69+
- `src/advanced/promotion/createPromotionGate.js`
70+
- `src/advanced/state/createWorldGameStateSystem.js`
71+
3. Confirm both files import `asPositiveInteger` from exactly:
72+
- `../../shared/utils/numberUtils.js`
73+
4. Confirm there is only one `asPositiveInteger` import per file
74+
5. Confirm no other helper definitions or logic changed
75+
76+
## Non-Goals
77+
- no changes to any debug inspector files
78+
- no changes to `src/shared/utils/numberUtils.js`
79+
- no broader number helper normalization
80+
- no repo-wide import cleanup
81+
- no refactor beyond this exact duplicate-removal step

src/advanced/promotion/createPromotionGate.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@ David Quesenberry
55
createPromotionGate.js
66
*/
77

8-
import { asFiniteNumber } from '../../shared/utils/numberUtils.js';
8+
import { asFiniteNumber, asPositiveInteger } from '../../shared/utils/numberUtils.js';
99
import { isPlainObject } from '../../shared/utils/objectUtils.js';
1010
import { createPromotionStateSnapshot } from '../shared/state/createPromotionStateSnapshot.js';
1111

12-
function asPositiveInteger(value, fallback = 1) {
13-
const numeric = Math.floor(asFiniteNumber(value, fallback));
14-
return numeric >= 1 ? numeric : fallback;
15-
}
16-
1712
function normalizeCriteriaMap(input, requiredCriteria = []) {
1813
const normalized = {};
1914
if (isPlainObject(input)) {

src/advanced/state/createWorldGameStateSystem.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
createTransitionRejectedEvent
2020
} from './events.js';
2121
import { createPromotionStateSnapshot } from '../../shared/state/createPromotionStateSnapshot.js';
22-
import { asFiniteNumber } from '../../shared/utils/numberUtils.js';
22+
import { asFiniteNumber, asPositiveInteger } from '../../shared/utils/numberUtils.js';
2323
import {
2424
cloneDeep,
2525
createReadonlyClone,
@@ -78,11 +78,6 @@ function resolveFrameFromMeta(meta, payload) {
7878
return null;
7979
}
8080

81-
function asPositiveInteger(value, fallback = 1) {
82-
const numeric = Math.floor(asFiniteNumber(value, fallback));
83-
return numeric >= 1 ? numeric : fallback;
84-
}
85-
8681
function normalizeRequiredCriteria(requiredCriteria) {
8782
if (!Array.isArray(requiredCriteria)) return [];
8883
const seen = new Set();

0 commit comments

Comments
 (0)