|
| 1 | +# BUILD PR — STATE + SAMPLE `toFiniteNumber` MIGRATION |
| 2 | + |
| 3 | +## PR Purpose |
| 4 | +Migrate the remaining state/sample-local `toFiniteNumber(value, fallback = 0)` implementations to the canonical shared math helper in `src/shared/math/numberNormalization.js`. |
| 5 | + |
| 6 | +This PR has one purpose only: |
| 7 | +- replace exact local duplicate implementations in the two known remaining consumer files |
| 8 | +- preserve behavior with fallback default `0` |
| 9 | +- do not widen scope beyond these files |
| 10 | + |
| 11 | +## Exact Target Files |
| 12 | +### Code files to modify |
| 13 | +- `src/advanced/state/transitions.js` |
| 14 | +- `samples/shared/worldGameStateSystem.js` |
| 15 | + |
| 16 | +### Existing shared dependency to use |
| 17 | +- `src/shared/math/numberNormalization.js` |
| 18 | + |
| 19 | +### Delivery docs to include/update in this bundle |
| 20 | +- `docs/pr/BUILD_PR_SHARED_EXTRACTION_51_STATE_SAMPLE_TOFINITENUMBER_MIGRATION.md` |
| 21 | +- `docs/dev/codex_commands.md` |
| 22 | +- `docs/dev/commit_comment.txt` |
| 23 | +- `docs/dev/next_command.txt` |
| 24 | +- `docs/dev/reports/file_tree.txt` |
| 25 | +- `docs/dev/reports/change_summary.txt` |
| 26 | +- `docs/dev/reports/validation_checklist.txt` |
| 27 | + |
| 28 | +## Preconditions |
| 29 | +Assume BUILD 50 has already landed and the canonical helper exists in: |
| 30 | +- `src/shared/math/numberNormalization.js` |
| 31 | + |
| 32 | +Assume that file exports: |
| 33 | +- `toFiniteNumber(value, fallback = 0)` |
| 34 | +- `roundNumber(value)` may also exist there, but it is out of scope for this PR |
| 35 | + |
| 36 | +If the canonical `toFiniteNumber` export does not exist in `src/shared/math/numberNormalization.js`, fail fast and stop. |
| 37 | + |
| 38 | +## Required Code Changes |
| 39 | +### 1) `src/advanced/state/transitions.js` |
| 40 | +- remove the local `function toFiniteNumber(value, fallback = 0)` implementation |
| 41 | +- import `toFiniteNumber` from `src/shared/math/numberNormalization.js` using the correct relative path |
| 42 | +- preserve all existing call-site behavior |
| 43 | +- do not change other helpers in this file |
| 44 | + |
| 45 | +### 2) `samples/shared/worldGameStateSystem.js` |
| 46 | +- remove the local `function toFiniteNumber(value, fallback = 0)` implementation |
| 47 | +- import `toFiniteNumber` from `src/shared/math/numberNormalization.js` using the correct relative path |
| 48 | +- preserve all existing call-site behavior |
| 49 | +- do not change unrelated helpers in this file |
| 50 | + |
| 51 | +## Explicit Non-Goals |
| 52 | +Do NOT: |
| 53 | +- modify `src/shared/math/numberNormalization.js` |
| 54 | +- touch any vector files |
| 55 | +- touch any other number helpers (`asFiniteNumber`, `asPositiveNumber`, `normalizeNumber`, `sanitizeFiniteNumber`, etc.) |
| 56 | +- touch any files other than the two exact code files listed above |
| 57 | +- rename exports |
| 58 | +- perform repo-wide cleanup |
| 59 | +- change logic beyond replacing the duplicate local helper with the shared import |
| 60 | + |
| 61 | +## Acceptance Criteria |
| 62 | +- both target files import `toFiniteNumber` from `src/shared/math/numberNormalization.js` |
| 63 | +- both target files no longer define a local `toFiniteNumber` |
| 64 | +- behavior remains fallback-compatible with default `0` |
| 65 | +- no unused imports remain |
| 66 | +- no call sites are changed beyond the import-based migration |
| 67 | +- bundle output is written to `<project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_51_STATE_SAMPLE_TOFINITENUMBER_MIGRATION_delta.zip` |
| 68 | + |
| 69 | +## Validation Steps |
| 70 | +1. Confirm `src/shared/math/numberNormalization.js` exports `toFiniteNumber` |
| 71 | +2. Open `src/advanced/state/transitions.js` |
| 72 | + - verify local `toFiniteNumber` removed |
| 73 | + - verify shared import added |
| 74 | +3. Open `samples/shared/worldGameStateSystem.js` |
| 75 | + - verify local `toFiniteNumber` removed |
| 76 | + - verify shared import added |
| 77 | +4. Search only within the two target files for `function toFiniteNumber` |
| 78 | + - expect zero matches |
| 79 | +5. Ensure there are no unused imports in the two target files |
| 80 | +6. Package only the changed files plus required docs into: |
| 81 | + - `<project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_51_STATE_SAMPLE_TOFINITENUMBER_MIGRATION_delta.zip` |
| 82 | + |
| 83 | +## Fail-Fast Conditions |
| 84 | +Stop immediately if any of the following occurs: |
| 85 | +- `src/shared/math/numberNormalization.js` does not export `toFiniteNumber` |
| 86 | +- migration would require touching files beyond the two exact code files |
| 87 | +- behavior-preserving replacement cannot be completed directly |
| 88 | +- any ambiguity appears about which helper version should be used |
| 89 | + |
| 90 | +## Output Expectation |
| 91 | +Return one repo-structured delta zip at: |
| 92 | +- `<project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_51_STATE_SAMPLE_TOFINITENUMBER_MIGRATION_delta.zip` |
| 93 | + |
| 94 | +Include only: |
| 95 | +- changed code files |
| 96 | +- docs for this PR |
| 97 | +- report files for this PR |
| 98 | + |
| 99 | +Do not include unrelated files, full-repo copies, dependencies, or build artifacts. |
0 commit comments