|
| 1 | +# BUILD_PR_SHARED_EXTRACTION_40_CLONE_SNAPSHOT_NETWORK_SAMPLE_C_BATCH |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Centralize duplicated `cloneSnapshot(snapshot)` implementations across the exact network_sample_c batch identified in the duplicate report. |
| 5 | + |
| 6 | +## Single PR Purpose |
| 7 | +Normalize ONLY this helper: |
| 8 | + |
| 9 | +- `cloneSnapshot(snapshot)` |
| 10 | + |
| 11 | +## Exact Files Allowed |
| 12 | + |
| 13 | +### New shared file |
| 14 | +1. `src/shared/utils/snapshotCloneUtils.js` |
| 15 | + |
| 16 | +### Consumer files |
| 17 | +2. `games/network_sample_c/game/ReconciliationLayerAdapter.js` |
| 18 | +3. `games/network_sample_c/game/StateTimelineBuffer.js` |
| 19 | + |
| 20 | +Do not edit any other file. |
| 21 | + |
| 22 | +## Source of Truth |
| 23 | +This exact scope comes from the provided duplicate report entry for: |
| 24 | + |
| 25 | +`function cloneSnapshot(snapshot)` |
| 26 | + |
| 27 | +Only the 2 listed consumer files are in scope. |
| 28 | + |
| 29 | +## Exact Shared Helper Creation |
| 30 | +Create: |
| 31 | + |
| 32 | +`src/shared/utils/snapshotCloneUtils.js` |
| 33 | + |
| 34 | +Export exactly: |
| 35 | + |
| 36 | +```js |
| 37 | +export function cloneSnapshot(snapshot) { |
| 38 | + // copy one existing implementation exactly |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +Implementation rules: |
| 43 | +- use ONE existing local implementation as source-of-truth |
| 44 | +- do NOT merge logic |
| 45 | +- do NOT generalize behavior |
| 46 | +- preserve the function signature exactly: |
| 47 | + - `cloneSnapshot(snapshot)` |
| 48 | + |
| 49 | +## Exact Consumer Changes |
| 50 | +For each of the 2 listed consumer files: |
| 51 | + |
| 52 | +If the file contains a local function definition matching: |
| 53 | +```js |
| 54 | +function cloneSnapshot(snapshot) |
| 55 | +``` |
| 56 | +then: |
| 57 | +- remove the local `cloneSnapshot(snapshot)` function definition |
| 58 | +- import `cloneSnapshot` from the correct relative path to: |
| 59 | + - `src/shared/utils/snapshotCloneUtils.js` |
| 60 | +- if the file already imports from that module, add `cloneSnapshot` with the minimum safe edit |
| 61 | +- do not duplicate imports |
| 62 | +- do not touch unrelated helpers |
| 63 | +- do not change logic |
| 64 | + |
| 65 | +If a listed file already imports and uses shared `cloneSnapshot`, leave it unchanged. |
| 66 | + |
| 67 | +## Relative Import Rule |
| 68 | +Use the correct relative path from each consumer file to: |
| 69 | + |
| 70 | +`src/shared/utils/snapshotCloneUtils.js` |
| 71 | + |
| 72 | +Do not use aliases. |
| 73 | +Do not change `.js` extension usage. |
| 74 | + |
| 75 | +## Hard Constraints |
| 76 | +- no engine changes |
| 77 | +- no game files outside the 2 listed consumers |
| 78 | +- no sample files |
| 79 | +- no repo-wide snapshot/deep-clone cleanup |
| 80 | +- no behavior changes |
| 81 | +- keep one PR purpose only |
| 82 | + |
| 83 | +## Validation Checklist |
| 84 | +1. Confirm no more than the 3 listed files changed |
| 85 | +2. Confirm `src/shared/utils/snapshotCloneUtils.js` exists and exports `cloneSnapshot` |
| 86 | +3. Confirm local `function cloneSnapshot(snapshot)` definitions no longer exist in changed listed consumer files |
| 87 | +4. Confirm changed consumer files import `cloneSnapshot` from the correct relative path to `src/shared/utils/snapshotCloneUtils.js` |
| 88 | +5. Confirm no unrelated engine, game, or sample files changed |
| 89 | +6. Confirm no behavior changes were made |
| 90 | + |
| 91 | +## Non-Goals |
| 92 | +- no cleanup of `clone(value)` |
| 93 | +- no cleanup of `cloneJson(value)` |
| 94 | +- no cleanup outside the 2 listed consumer files |
| 95 | +- no refactor beyond this exact duplicate-removal batch |
0 commit comments