Skip to content

Commit 8c9a134

Browse files
author
DavidQ
committed
BUILD PR: centralize asStringArray across exact preset/group-registry batch.
1 parent 4c47175 commit 8c9a134

8 files changed

Lines changed: 113 additions & 36 deletions

File tree

docs/dev/CODEX_COMMANDS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_40_CLONE_SNAPSHOT_NETWORK_SAMPLE_C_BATCH.md exactly.
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_41_AS_STRING_ARRAY_PRESET_BATCH.md exactly.
55
Edit only these files:
6-
- src/shared/utils/snapshotCloneUtils.js (new file)
7-
- games/network_sample_c/game/ReconciliationLayerAdapter.js
8-
- games/network_sample_c/game/StateTimelineBuffer.js
6+
- src/shared/utils/arrayUtils.js (only to add/export asStringArray if missing, or minimum export fix if present)
7+
- tools/dev/advanced/debugPanelGroupRegistry.js
8+
- tools/dev/presets/debugPresetRegistry.js
99
Do not expand scope.
10-
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_40_CLONE_SNAPSHOT_NETWORK_SAMPLE_C_BATCH_delta.zip
10+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_41_AS_STRING_ARRAY_PRESET_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 cloneSnapshot across exact network_sample_c batch.
1+
BUILD PR: centralize asStringArray across exact preset/group-registry batch.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: continue duplicate-family extraction from the provided duplicate report.
1+
Next: run BUILD_PR_SHARED_EXTRACTION_42_CREATE_RESULT_COMMANDPACK_BATCH after this batch.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Rebuilt 40 as an execution-grade batch using the exact duplicate-report file list for cloneSnapshot(snapshot).
1+
Execution-grade batch for asStringArray using the exact duplicate-report file list.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# BUILD_PR_SHARED_EXTRACTION_41_AS_STRING_ARRAY_PRESET_BATCH
2+
3+
## Purpose
4+
Centralize duplicated `asStringArray(value)` implementations across the exact preset/group-registry batch identified in the duplicate report.
5+
6+
## Single PR Purpose
7+
Normalize ONLY this helper:
8+
9+
- `asStringArray(value)`
10+
11+
## Exact Files Allowed
12+
13+
### Shared source
14+
1. `src/shared/utils/arrayUtils.js`
15+
16+
### Consumer files
17+
2. `tools/dev/advanced/debugPanelGroupRegistry.js`
18+
3. `tools/dev/presets/debugPresetRegistry.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 asStringArray(value)`
26+
27+
Only the 2 listed consumer files are in scope.
28+
29+
## Shared Helper Assumption
30+
Use the existing shared utility:
31+
32+
`src/shared/utils/arrayUtils.js`
33+
34+
Fail fast unless that file exists and exports:
35+
36+
- `asStringArray`
37+
38+
If the file exists and contains `asStringArray` but does not export it correctly, the only allowed shared-file change is the minimum export-only fix.
39+
40+
If the helper does not exist in the shared file, add ONLY this helper to `src/shared/utils/arrayUtils.js` by copying one existing local implementation exactly, with no behavior change and no unrelated edits.
41+
42+
## Exact Consumer Changes
43+
For each of the 2 listed consumer files:
44+
45+
If the file contains a local function definition matching:
46+
```js
47+
function asStringArray(value)
48+
```
49+
then:
50+
- remove the local `asStringArray(value)` function definition
51+
- import `asStringArray` from the correct relative path to:
52+
- `src/shared/utils/arrayUtils.js`
53+
- if the file already imports from that module, add `asStringArray` with the minimum safe edit
54+
- do not duplicate imports
55+
- do not touch unrelated helpers
56+
- do not change logic
57+
58+
If a listed file already imports and uses shared `asStringArray`, leave it unchanged.
59+
60+
## Relative Import Rule
61+
Use the correct relative path from each consumer file to:
62+
63+
`src/shared/utils/arrayUtils.js`
64+
65+
Do not use aliases.
66+
Do not change `.js` extension usage.
67+
68+
## Hard Constraints
69+
- no engine changes outside `src/shared/utils/arrayUtils.js`
70+
- no files outside the 2 listed consumers
71+
- no repo-wide array helper cleanup
72+
- no behavior changes
73+
- keep one PR purpose only
74+
75+
## Validation Checklist
76+
1. Confirm no more than the 3 listed files changed
77+
2. Confirm `src/shared/utils/arrayUtils.js` exports `asStringArray`
78+
3. Confirm local `function asStringArray(value)` definitions no longer exist in changed listed consumer files
79+
4. Confirm changed consumer files import `asStringArray` from the correct relative path to `src/shared/utils/arrayUtils.js`
80+
5. Confirm no unrelated files changed
81+
6. Confirm no behavior changes were made
82+
83+
## Non-Goals
84+
- no cleanup of `ensureArray`
85+
- no cleanup of `asArray`
86+
- no cleanup outside the 2 listed consumer files
87+
- no refactor beyond this exact duplicate-removal batch

src/shared/utils/arrayUtils.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
import { sanitizeText } from "../../engine/debug/inspectors/shared/inspectorUtils.js";
2+
13
export function ensureArray(value) {
24
return Array.isArray(value) ? value : [];
35
}
6+
7+
export function asStringArray(value) {
8+
if (!Array.isArray(value)) {
9+
return [];
10+
}
11+
const unique = new Set();
12+
value.forEach((item) => {
13+
const token = sanitizeText(String(item));
14+
if (token) {
15+
unique.add(token);
16+
}
17+
});
18+
return Array.from(unique.values());
19+
}

tools/dev/advanced/debugPanelGroupRegistry.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,9 @@ debugPanelGroupRegistry.js
66
*/
77

88
import { sanitizeText } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
9+
import { asStringArray } from "../../../src/shared/utils/arrayUtils.js";
910
import { cloneJson } from "../../../src/shared/utils/jsonUtils.js";
1011

11-
function asStringArray(value) {
12-
if (!Array.isArray(value)) {
13-
return [];
14-
}
15-
const unique = new Set();
16-
value.forEach((item) => {
17-
const token = sanitizeText(String(item));
18-
if (token) {
19-
unique.add(token);
20-
}
21-
});
22-
return Array.from(unique.values());
23-
}
24-
2512
function normalizeGroupDescriptor(descriptor = {}) {
2613
const groupId = sanitizeText(descriptor.groupId);
2714
const title = sanitizeText(descriptor.title) || groupId;

tools/dev/presets/debugPresetRegistry.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,10 @@ debugPresetRegistry.js
66
*/
77

88
import { sanitizeText } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
9+
import { asStringArray } from "../../../src/shared/utils/arrayUtils.js";
910
import { isObject } from "../../../src/shared/utils/objectUtils.js";
1011
import { cloneJson } from "../../../src/shared/utils/jsonUtils.js";
1112

12-
function asStringArray(value) {
13-
if (!Array.isArray(value)) {
14-
return [];
15-
}
16-
const unique = new Set();
17-
value.forEach((item) => {
18-
const token = sanitizeText(String(item));
19-
if (token) {
20-
unique.add(token);
21-
}
22-
});
23-
return Array.from(unique.values());
24-
}
25-
2613
function normalizePresetDescriptor(descriptor = {}) {
2714
const presetId = sanitizeText(descriptor.presetId);
2815
const title = sanitizeText(descriptor.title) || presetId;

0 commit comments

Comments
 (0)