|
| 1 | +# BUILD_PR_SHARED_EXTRACTION_35_NETWORK_DEBUG_SERIALIZATION_BATCH |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Centralize duplicated network debug serialization helpers across the exact network debug batch identified in the duplicate report. |
| 5 | + |
| 6 | +## Single PR Purpose |
| 7 | +Normalize ONLY these helpers: |
| 8 | + |
| 9 | +- `asNumber(value, fallback = 0)` |
| 10 | +- `toNetworkSnapshot(snapshot)` |
| 11 | +- `getCommandSnapshot(context)` |
| 12 | +- `commandLinesForTrace(context, args = [])` |
| 13 | + |
| 14 | +## Exact Files Allowed |
| 15 | + |
| 16 | +### New shared source |
| 17 | +1. `src/shared/utils/networkDebugUtils.js` |
| 18 | + |
| 19 | +### Consumer files |
| 20 | +2. `games/network_sample_a/debug/networkSampleADebug.js` |
| 21 | +3. `games/network_sample_b/debug/networkSampleBDebug.js` |
| 22 | +4. `games/network_sample_c/debug/networkSampleCDebug.js` |
| 23 | + |
| 24 | +Do not edit any other file. |
| 25 | + |
| 26 | +## Source of Truth |
| 27 | +This exact scope comes from the provided duplicate report entries for: |
| 28 | +- `function asNumber(value, fallback = 0)` |
| 29 | +- `function toNetworkSnapshot(snapshot)` |
| 30 | +- `function getCommandSnapshot(context)` |
| 31 | +- `function commandLinesForTrace(context, args = [])` |
| 32 | + |
| 33 | +Only the listed network debug files are in scope. |
| 34 | + |
| 35 | +## Exact Shared Helper Creation |
| 36 | +Create: |
| 37 | + |
| 38 | +`src/shared/utils/networkDebugUtils.js` |
| 39 | + |
| 40 | +Export exactly these helpers: |
| 41 | +- `asNumber` |
| 42 | +- `toNetworkSnapshot` |
| 43 | +- `getCommandSnapshot` |
| 44 | +- `commandLinesForTrace` |
| 45 | + |
| 46 | +Implementation rules: |
| 47 | +- Use ONE existing implementation as source-of-truth for each helper |
| 48 | +- Do NOT merge logic |
| 49 | +- Do NOT generalize behavior |
| 50 | +- Preserve function signatures exactly as listed above |
| 51 | + |
| 52 | +Notes: |
| 53 | +- `getCommandSnapshot` is present only in `network_sample_a` and `network_sample_c` |
| 54 | +- `commandLinesForTrace` is present only in `network_sample_a` and `network_sample_c` |
| 55 | +That is expected. Export them from the shared file anyway; only import them in files that currently use them. |
| 56 | + |
| 57 | +## Exact Consumer Changes |
| 58 | + |
| 59 | +### `games/network_sample_a/debug/networkSampleADebug.js` |
| 60 | +- remove local definitions for any of the 4 listed helpers that exist in this file |
| 61 | +- import the helpers it uses from the correct relative path to: |
| 62 | + - `src/shared/utils/networkDebugUtils.js` |
| 63 | +- do not touch unrelated helpers |
| 64 | +- do not change logic |
| 65 | + |
| 66 | +### `games/network_sample_b/debug/networkSampleBDebug.js` |
| 67 | +- remove local definitions for: |
| 68 | + - `asNumber` |
| 69 | + - `toNetworkSnapshot` |
| 70 | +- import the helpers it uses from the correct relative path to: |
| 71 | + - `src/shared/utils/networkDebugUtils.js` |
| 72 | +- do not import helpers this file does not use |
| 73 | +- do not touch unrelated helpers |
| 74 | +- do not change logic |
| 75 | + |
| 76 | +### `games/network_sample_c/debug/networkSampleCDebug.js` |
| 77 | +- remove local definitions for any of the 4 listed helpers that exist in this file |
| 78 | +- import the helpers it uses from the correct relative path to: |
| 79 | + - `src/shared/utils/networkDebugUtils.js` |
| 80 | +- do not touch unrelated helpers |
| 81 | +- do not change logic |
| 82 | + |
| 83 | +Import rules: |
| 84 | +- if a file already imports from that module, add needed specifiers with the minimum safe edit |
| 85 | +- if multiple listed helpers are needed from the same module, a single combined import is allowed |
| 86 | +- do not duplicate imports |
| 87 | + |
| 88 | +## Relative Import Rule |
| 89 | +Use the correct relative path from each consumer file to: |
| 90 | + |
| 91 | +`src/shared/utils/networkDebugUtils.js` |
| 92 | + |
| 93 | +Do not use aliases. |
| 94 | +Do not change `.js` extension usage. |
| 95 | + |
| 96 | +## Hard Constraints |
| 97 | +- no engine changes |
| 98 | +- no game runtime changes outside the 3 listed debug consumers |
| 99 | +- no sample files |
| 100 | +- no repo-wide network helper cleanup |
| 101 | +- no behavior changes |
| 102 | +- keep one PR purpose only |
| 103 | + |
| 104 | +## Validation Checklist |
| 105 | +1. Confirm no more than the 4 listed files changed |
| 106 | +2. Confirm `src/shared/utils/networkDebugUtils.js` exists and exports the 4 listed helpers |
| 107 | +3. Confirm changed consumer files no longer contain local definitions for the listed helpers they used to own |
| 108 | +4. Confirm changed consumer files import only the needed helpers from the correct relative path to `src/shared/utils/networkDebugUtils.js` |
| 109 | +5. Confirm no unrelated engine, game runtime, or sample files changed |
| 110 | +6. Confirm no behavior changes were made |
| 111 | + |
| 112 | +## Non-Goals |
| 113 | +- no cleanup of other network debug helpers beyond the 4 listed above |
| 114 | +- no cleanup outside the 3 listed network debug consumer files |
| 115 | +- no refactor beyond this exact duplicate-removal batch |
0 commit comments