|
| 1 | +# BUILD PR — VECTOR NUMBER NORMALIZATION TO SHARED MATH |
| 2 | + |
| 3 | +## PR Purpose |
| 4 | +Move the numeric normalization helpers introduced in PR 49 out of the vector-domain file and into the canonical shared math home. |
| 5 | + |
| 6 | +## Why This BUILD Exists |
| 7 | +PR 49 introduced: |
| 8 | +- `toFiniteNumber(value, fallback = NaN)` |
| 9 | +- `roundNumber(value)` |
| 10 | + |
| 11 | +inside: |
| 12 | +- `tools/shared/vector/vectorGeometryMath.js` |
| 13 | + |
| 14 | +Per current repo rule, number-related helpers belong under: |
| 15 | +- `src/shared/math/numberNormalization.js` |
| 16 | + |
| 17 | +This BUILD performs only that extraction for the exact PR 49 vector lane. |
| 18 | + |
| 19 | +## Exact Target Files |
| 20 | +Create: |
| 21 | +- `src/shared/math/numberNormalization.js` |
| 22 | + |
| 23 | +Modify: |
| 24 | +- `tools/shared/vector/vectorGeometryMath.js` |
| 25 | +- `tools/shared/vector/vectorAssetContract.js` |
| 26 | + |
| 27 | +## Exact Required Changes |
| 28 | + |
| 29 | +### 1) Create shared math module |
| 30 | +Create: |
| 31 | +- `src/shared/math/numberNormalization.js` |
| 32 | + |
| 33 | +Export exactly: |
| 34 | +- `toFiniteNumber(value, fallback = NaN)` |
| 35 | +- `roundNumber(value)` |
| 36 | + |
| 37 | +Behavior must match PR 49 exactly: |
| 38 | +- `toFiniteNumber`: |
| 39 | + - converts with `Number(value)` |
| 40 | + - returns numeric value when finite |
| 41 | + - otherwise returns `fallback` |
| 42 | +- `roundNumber`: |
| 43 | + - returns input unchanged when not finite |
| 44 | + - otherwise returns `Number(value.toFixed(6))` |
| 45 | + |
| 46 | +Do not add any other helpers in this PR. |
| 47 | + |
| 48 | +### 2) Update vectorGeometryMath.js |
| 49 | +In: |
| 50 | +- `tools/shared/vector/vectorGeometryMath.js` |
| 51 | + |
| 52 | +Remove the local implementations of: |
| 53 | +- `toFiniteNumber` |
| 54 | +- `roundNumber` |
| 55 | + |
| 56 | +Import those helpers from: |
| 57 | +- `../../../src/shared/math/numberNormalization.js` |
| 58 | + |
| 59 | +Keep all existing vector geometry exports and behavior unchanged otherwise. |
| 60 | + |
| 61 | +### 3) Update vectorAssetContract.js |
| 62 | +In: |
| 63 | +- `tools/shared/vector/vectorAssetContract.js` |
| 64 | + |
| 65 | +Stop importing `toFiniteNumber` and `roundNumber` from `./vectorGeometryMath.js`. |
| 66 | + |
| 67 | +Import: |
| 68 | +- `parseSvgPathData` from `./vectorGeometryMath.js` |
| 69 | +- `toFiniteNumber` and `roundNumber` from `../../../src/shared/math/numberNormalization.js` |
| 70 | + |
| 71 | +No other logic changes. |
| 72 | + |
| 73 | +## Non-Goals |
| 74 | +- Do not touch any files outside the three exact target files above. |
| 75 | +- Do not scan the repo for other number helpers. |
| 76 | +- Do not merge with `asFiniteNumber`, `normalizeNumber`, `sanitizeFiniteNumber`, or any other helper. |
| 77 | +- Do not touch `samples/shared/worldGameStateSystem.js`. |
| 78 | +- Do not touch `src/advanced/state/transitions.js`. |
| 79 | +- Do not change fallback defaults. |
| 80 | +- Do not rename exports. |
| 81 | +- Do not perform broader cleanup. |
| 82 | + |
| 83 | +## Acceptance Criteria |
| 84 | +- `src/shared/math/numberNormalization.js` exists and exports only the two exact functions above. |
| 85 | +- `tools/shared/vector/vectorGeometryMath.js` no longer defines local `toFiniteNumber` or `roundNumber`. |
| 86 | +- `tools/shared/vector/vectorAssetContract.js` imports numeric helpers from shared math, not vectorGeometryMath. |
| 87 | +- Runtime behavior of the vector lane remains unchanged. |
| 88 | +- No dead imports. |
| 89 | +- No unused local helper definitions remain in the touched files. |
| 90 | + |
| 91 | +## Validation |
| 92 | +- Verify the three exact target files are the only code files changed. |
| 93 | +- Verify import paths resolve correctly. |
| 94 | +- Verify no local `toFiniteNumber` or `roundNumber` definitions remain in: |
| 95 | + - `tools/shared/vector/vectorGeometryMath.js` |
| 96 | + - `tools/shared/vector/vectorAssetContract.js` |
0 commit comments