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