|
| 1 | +# BUILD_PR_SHARED_EXTRACTION_12_NETWORK_SAMPLE_C_NUMBER_HELPERS |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Remove remaining local number-helper duplication in the network_sample_c game slice and switch those files to the shared number helper module. |
| 5 | + |
| 6 | +## Single PR Purpose |
| 7 | +Normalize only these helper usages inside network_sample_c: |
| 8 | +- `asFiniteNumber` |
| 9 | +- `asPositiveInteger` |
| 10 | + |
| 11 | +Target files: |
| 12 | +- `games/network_sample_c/game/ReconciliationLayerAdapter.js` |
| 13 | +- `games/network_sample_c/game/StateTimelineBuffer.js` |
| 14 | + |
| 15 | +This BUILD does **not** change any other helper or file. |
| 16 | + |
| 17 | +## Exact Files Allowed |
| 18 | +Edit only these 3 files: |
| 19 | + |
| 20 | +1. `games/network_sample_c/game/ReconciliationLayerAdapter.js` |
| 21 | +2. `games/network_sample_c/game/StateTimelineBuffer.js` |
| 22 | +3. `src/shared/utils/numberUtils.js` **only if minimum export fix is required** |
| 23 | + |
| 24 | +Do not edit any other file. |
| 25 | + |
| 26 | +## Shared Dependency Assumption |
| 27 | +Use the shared helper path: |
| 28 | + |
| 29 | +- `src/shared/utils/numberUtils.js` |
| 30 | + |
| 31 | +Consumer import path from both network_sample_c files must be: |
| 32 | + |
| 33 | +```js |
| 34 | +../../../src/shared/utils/numberUtils.js |
| 35 | +``` |
| 36 | + |
| 37 | +## Fail-Fast Gate |
| 38 | +Before making consumer edits, confirm: |
| 39 | + |
| 40 | +1. `src/shared/utils/numberUtils.js` exists |
| 41 | +2. it exports `asFiniteNumber` |
| 42 | +3. it exports `asPositiveInteger` |
| 43 | + |
| 44 | +If any condition is false: |
| 45 | +- stop |
| 46 | +- report blocker |
| 47 | +- make no changes |
| 48 | +- do not create a delta ZIP |
| 49 | + |
| 50 | +Do **not** create a new shared number helper in this PR. |
| 51 | + |
| 52 | +## Exact Source Changes |
| 53 | + |
| 54 | +### 1) `games/network_sample_c/game/ReconciliationLayerAdapter.js` |
| 55 | +- remove the local `asPositiveInteger` function definition |
| 56 | +- remove the local `asFiniteNumber` function definition |
| 57 | +- add exactly one shared import, or minimally update the existing import block, to provide: |
| 58 | + |
| 59 | +```js |
| 60 | +import { asFiniteNumber, asPositiveInteger } from "../../../src/shared/utils/numberUtils.js"; |
| 61 | +``` |
| 62 | + |
| 63 | +Rules: |
| 64 | +- if separate imports from the same shared file already exist, collapse only if minimal and safe |
| 65 | +- do not duplicate imports |
| 66 | +- do not touch `sanitizeText` |
| 67 | +- do not touch snapshot cloning helpers |
| 68 | +- do not change logic |
| 69 | + |
| 70 | +### 2) `games/network_sample_c/game/StateTimelineBuffer.js` |
| 71 | +- remove the local `asPositiveInteger` function definition |
| 72 | +- add exactly one shared import, or minimally update the existing import block, to provide: |
| 73 | + |
| 74 | +```js |
| 75 | +import { asPositiveInteger } from "../../../src/shared/utils/numberUtils.js"; |
| 76 | +``` |
| 77 | + |
| 78 | +Rules: |
| 79 | +- do not add `asFiniteNumber` here |
| 80 | +- do not touch `normalizeFrameId` |
| 81 | +- do not touch snapshot cloning helpers |
| 82 | +- do not change logic |
| 83 | + |
| 84 | +### 3) `src/shared/utils/numberUtils.js` |
| 85 | +Do not modify implementation logic. |
| 86 | + |
| 87 | +Allowed edit only: |
| 88 | +- if `asFiniteNumber` or `asPositiveInteger` already exists in this file but is not exported correctly, make the minimum export change required |
| 89 | + |
| 90 | +If both helpers are already exported, leave this file unchanged. |
| 91 | + |
| 92 | +## Hard Constraints |
| 93 | +- do not edit any file other than the 3 listed above |
| 94 | +- do not change helper behavior |
| 95 | +- do not modify `network_sample_a` |
| 96 | +- do not modify engine debug inspector files |
| 97 | +- do not change `isPlainObject` |
| 98 | +- do not change promotion snapshot logic |
| 99 | +- do not perform repo-wide helper cleanup |
| 100 | +- keep one PR purpose only |
| 101 | + |
| 102 | +## Validation Checklist |
| 103 | +1. Confirm no more than the 3 listed files changed |
| 104 | +2. Confirm `src/shared/utils/numberUtils.js` exists |
| 105 | +3. Confirm `src/shared/utils/numberUtils.js` exports: |
| 106 | + - `asFiniteNumber` |
| 107 | + - `asPositiveInteger` |
| 108 | +4. Confirm local helper definitions no longer exist in: |
| 109 | + - `games/network_sample_c/game/ReconciliationLayerAdapter.js` for: |
| 110 | + - `asFiniteNumber` |
| 111 | + - `asPositiveInteger` |
| 112 | + - `games/network_sample_c/game/StateTimelineBuffer.js` for: |
| 113 | + - `asPositiveInteger` |
| 114 | +5. Confirm consumer imports now point exactly to: |
| 115 | + - `../../../src/shared/utils/numberUtils.js` |
| 116 | +6. Confirm no other logic changed |
| 117 | + |
| 118 | +## Non-Goals |
| 119 | +- no work in `games/network_sample_a/server/networkSampleADashboardServer.mjs` |
| 120 | +- no work in `src/engine/debug/inspectors/shared/inspectorUtils.js` |
| 121 | +- no broader number helper normalization |
| 122 | +- no new shared helper creation |
| 123 | +- no refactor beyond this exact duplicate-removal step |
0 commit comments