Skip to content

Commit 6c2e1b0

Browse files
author
DavidQ
committed
BUILD PR: centralize vector toFiniteNumber/roundNumber helpers with exact two-file consumer replacement.
1 parent 74727bf commit 6c2e1b0

9 files changed

Lines changed: 109 additions & 27 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
MODEL: GPT-5.3-codex
1+
MODEL: GPT-5.4-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_48_RUNTIME_ASSET_VALIDATION_BATCH.md exactly.
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_49_VECTOR_TO_FINITE_NUMBER_ROUND_BATCH.md exactly.
55
Edit only these files:
6-
- tools/shared/runtimeAssetValidationUtils.js (new file)
7-
- tools/shared/runtimeAssetLoader.js
8-
- tools/shared/runtimeStreaming.js
9-
Do not expand scope.
10-
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_48_RUNTIME_ASSET_VALIDATION_BATCH_delta.zip
6+
- tools/shared/vector/vectorGeometryMath.js
7+
- tools/shared/vector/vectorAssetContract.js
8+
Fail fast with no code edits if the consumer replacement cannot be completed inside those exact two files.
9+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_49_VECTOR_TO_FINITE_NUMBER_ROUND_BATCH_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD PR: centralize runtime asset validation/registry helpers across exact tools/shared batch.
1+
BUILD PR: centralize vector toFiniteNumber/roundNumber helpers with exact two-file consumer replacement.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: run BUILD_PR_SHARED_EXTRACTION_49_VECTOR_TO_FINITE_NUMBER_ROUND_BATCH after this batch.
1+
Next: after 49, continue the next exact duplicate cluster only.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Execution-grade batch for validatePackageManifest/createRegistryDefinition using the exact duplicate-report file list.
1+
Rebuilt BUILD 49 as an execution-grade two-file batch with explicit dead-code prevention and fail-fast rules.

docs/dev/reports/file_tree.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
docs only
1+
docs/pr/BUILD_PR_SHARED_EXTRACTION_49_VECTOR_TO_FINITE_NUMBER_ROUND_BATCH.md
2+
docs/dev/codex_commands.md
3+
docs/dev/commit_comment.txt
4+
docs/dev/next_command.txt
5+
docs/dev/reports/change_summary.txt
6+
docs/dev/reports/validation_checklist.txt
7+
docs/dev/reports/file_tree.txt
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Exact file list present; exact helper list present; one PR purpose only.
1+
Exact file list present; exact helper list present; consumer replacement required; dead-code blocked; one PR purpose only.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# BUILD_PR_SHARED_EXTRACTION_49_VECTOR_TO_FINITE_NUMBER_ROUND_BATCH
2+
3+
## Purpose
4+
Centralize the exact duplicated numeric helpers in the vector lane so the consumer stops carrying local copies and uses the shared implementation instead.
5+
6+
## Single PR Purpose
7+
Normalize ONLY these helpers:
8+
- `toFiniteNumber(value, fallback = NaN)`
9+
- `roundNumber(value)`
10+
11+
## Exact Files Allowed
12+
1. `tools/shared/vector/vectorGeometryMath.js`
13+
2. `tools/shared/vector/vectorAssetContract.js`
14+
15+
Do not edit any other file.
16+
17+
## Required Starting Check
18+
Open both listed files first.
19+
20+
Fail fast and stop with no code edits if any of the following is true:
21+
- either listed file does not exist
22+
- `tools/shared/vector/vectorAssetContract.js` does not contain local definitions and also does not need these imports
23+
- the shared file already exports the exact helpers and the consumer already imports and uses them correctly
24+
- completing the batch would require touching any file outside the exact 2-file list
25+
26+
## Shared Source Rule
27+
`tools/shared/vector/vectorGeometryMath.js` is the only allowed shared source for this batch.
28+
29+
Allowed shared-file edits are limited to exactly one of these cases:
30+
1. **Export-only fix**: the helper implementation already exists in the file, but the helper is not exported correctly.
31+
2. **Missing-helper add**: copy only the missing helper implementation(s) from `tools/shared/vector/vectorAssetContract.js` into `tools/shared/vector/vectorGeometryMath.js` with no behavior change.
32+
33+
Do not rewrite existing math helpers.
34+
Do not reorder unrelated exports.
35+
Do not perform cleanup outside these two helpers.
36+
37+
## Consumer Replacement Rule
38+
For `tools/shared/vector/vectorAssetContract.js`:
39+
- remove only the local definitions of:
40+
- `toFiniteNumber(value, fallback = NaN)`
41+
- `roundNumber(value)`
42+
- import the shared helper(s) from:
43+
- `./vectorGeometryMath.js`
44+
- if an import from `./vectorGeometryMath.js` already exists, extend that import with the minimum safe edit
45+
- do not create duplicate import lines
46+
- do not touch unrelated local helpers
47+
- do not change call sites except as required to use the imported helpers
48+
49+
## Dead-Code Prevention Rule
50+
This BUILD is valid only if at least one concrete consumer replacement occurs in:
51+
- `tools/shared/vector/vectorAssetContract.js`
52+
53+
Do not add or export a shared helper unless the consumer file in this same PR is switched away from its local duplicate.
54+
55+
## Relative Import Rule
56+
Use exactly:
57+
- `./vectorGeometryMath.js`
58+
59+
Do not change path style.
60+
Do not change extension style.
61+
Do not introduce aliases.
62+
63+
## Hard Constraints
64+
- no files outside the exact 2-file list
65+
- no wildcard scope
66+
- no repo-wide vector cleanup
67+
- no behavior changes
68+
- no renames
69+
- no formatting-only pass
70+
- keep one PR purpose only
71+
72+
## Validation Checklist
73+
1. Confirm only these 2 files changed:
74+
- `tools/shared/vector/vectorGeometryMath.js`
75+
- `tools/shared/vector/vectorAssetContract.js`
76+
2. Confirm `tools/shared/vector/vectorGeometryMath.js` exports:
77+
- `toFiniteNumber`
78+
- `roundNumber`
79+
3. Confirm `tools/shared/vector/vectorAssetContract.js` no longer contains local definitions for those helpers
80+
4. Confirm `tools/shared/vector/vectorAssetContract.js` imports the helpers from `./vectorGeometryMath.js`
81+
5. Confirm at least one real consumer replacement occurred in `tools/shared/vector/vectorAssetContract.js`
82+
6. Confirm no unrelated helpers or files changed
83+
7. Confirm no behavior changes were introduced
84+
85+
## Non-Goals
86+
- no cleanup outside this exact duplicate-removal batch
87+
- no additional vector helper extraction
88+
- no import normalization beyond this exact consumer replacement
89+
- no follow-on dedupe work

tools/shared/vector/vectorAssetContract.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parseSvgPathData } from "./vectorGeometryMath.js";
1+
import { parseSvgPathData, toFiniteNumber, roundNumber } from "./vectorGeometryMath.js";
22
import { cloneJson } from "../../../src/shared/utils/jsonUtils.js";
33

44
export const VECTOR_ASSET_FORMAT = "toolbox.vector.asset";
@@ -21,18 +21,6 @@ function sanitizeText(value) {
2121
return typeof value === "string" ? value.trim() : "";
2222
}
2323

24-
function toFiniteNumber(value, fallback = NaN) {
25-
const numeric = Number(value);
26-
return Number.isFinite(numeric) ? numeric : fallback;
27-
}
28-
29-
function roundNumber(value) {
30-
if (!Number.isFinite(value)) {
31-
return value;
32-
}
33-
return Number(value.toFixed(6));
34-
}
35-
3624
export function parseViewBoxString(viewBox) {
3725
const parts = sanitizeText(viewBox).split(/\s+/).map((value) => Number(value));
3826
if (parts.length !== 4 || parts.some((value) => !Number.isFinite(value))) {

tools/shared/vector/vectorGeometryMath.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const PATH_TOKEN_PATTERN = /[AaCcHhLlMmQqSsTtVvZz]|-?\d*\.?\d+(?:e[-+]?\d+)?/g;
22

3-
function toFiniteNumber(value, fallback = NaN) {
3+
export function toFiniteNumber(value, fallback = NaN) {
44
const numeric = Number(value);
55
return Number.isFinite(numeric) ? numeric : fallback;
66
}
77

8-
function roundNumber(value) {
8+
export function roundNumber(value) {
99
if (!Number.isFinite(value)) {
1010
return value;
1111
}

0 commit comments

Comments
 (0)