Skip to content

Commit bbbaf98

Browse files
author
DavidQ
committed
Close the remaining number/string/id exact-cluster normalization residue
BUILD_PR_LEVEL_03_EXACT_CLUSTER_NUMBER_STRING_ID_CLOSEOUT
1 parent b556d53 commit bbbaf98

26 files changed

Lines changed: 275 additions & 145 deletions

docs/MASTER_ROADMAP_HIGH_LEVEL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
- [x] Asteroids numeric sanitizers promoted into shared math
201201
- [x] duplicated `asObject` / `asArray` consumers moved to shared utils
202202
- [.] shared math is now a real active layer and should continue by exact-cluster extraction only
203-
- [ ] remaining number/string/id helpers still need exact-cluster normalization
203+
- [x] remaining number/string/id helpers still need exact-cluster normalization
204204

205205
---
206206

docs/dev/CODEX_COMMANDS.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,30 @@ MODEL: GPT-5.4
22
REASONING: high
33

44
COMMAND:
5-
Create `BUILD_PR_ROADMAP_TOOL_RULES_PROMOTION_AND_CLEANUP`.
5+
Create `BUILD_PR_LEVEL_03_EXACT_CLUSTER_NUMBER_STRING_ID_CLOSEOUT`.
66

7-
1. Locate these roadmap items:
8-
- no standalone showcase-only tool tracks
9-
- tools header accordion added to reduce vertical real-estate usage
10-
- tool-shell UI compaction is useful but does not replace tool-boundary normalization work
11-
- any follow-up tool UI cleanup should remain subordinate to shared-boundary and data-contract work
7+
Goal:
8+
Close the final remaining Shared Foundation checkpoint item:
9+
- remaining number/string/id helpers still need exact-cluster normalization
1210

13-
2. Reclassify them as rules/instructions:
14-
- move them to the top roadmap rules/instructions area
15-
- remove checklist/status markers
16-
- preserve wording exactly
11+
Required work:
12+
1. Find the remaining duplicated or fragmented helper clusters in:
13+
- number
14+
- string
15+
- id
16+
2. Normalize them using exact-cluster extraction only.
17+
3. Move them into the correct `src/shared` homes.
18+
4. Update consumers as needed.
19+
5. Do NOT perform a broad repo-wide cleanup pass.
20+
6. Do NOT do blind dedupe.
21+
7. Update roadmap status markers only.
22+
8. Report whether the item can now be truthfully marked complete.
1723

18-
3. Do NOT:
19-
- delete content
20-
- rewrite wording
21-
- alter unrelated roadmap text
22-
23-
4. Ensure the checklist/task area only contains actionable work after the move.
24-
25-
5. Final packaging step is REQUIRED:
24+
Final packaging step is REQUIRED:
2625
- package ALL changed files into this exact repo-structured ZIP:
27-
`<project folder>/tmp/BUILD_PR_ROADMAP_TOOL_RULES_PROMOTION_AND_CLEANUP.zip`
26+
`<project folder>/tmp/BUILD_PR_LEVEL_03_EXACT_CLUSTER_NUMBER_STRING_ID_CLOSEOUT.zip`
2827

2928
Hard rules:
30-
- move, do not delete
31-
- no wording changes
29+
- exact-cluster work only
3230
- no unrelated repo changes
3331
- no missing ZIP

docs/dev/COMMIT_COMMENT.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Promote tool roadmap rules out of checklist tracking
2-
BUILD_PR_ROADMAP_TOOL_RULES_PROMOTION_AND_CLEANUP
1+
Close the remaining number/string/id exact-cluster normalization residue
2+
BUILD_PR_LEVEL_03_EXACT_CLUSTER_NUMBER_STRING_ID_CLOSEOUT
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# BUILD_PR_LEVEL_03_EXACT_CLUSTER_NUMBER_STRING_ID_CLOSEOUT Report
2+
3+
## Exact Clusters Normalized
4+
- `string` helpers:
5+
- canonical home: `src/shared/string/stringHelpers.js`
6+
- public surface: `src/shared/string/index.js`
7+
- `id` helpers:
8+
- canonical home: `src/shared/id/idUtils.js`
9+
- public surface: `src/shared/id/index.js`
10+
- `number` helpers:
11+
- canonical home: `src/shared/number/numberUtils.js`
12+
- public surface: `src/shared/number/index.js`
13+
14+
## Compatibility Surfaces Kept
15+
- `src/shared/utils/stringUtils.js` now re-exports from `src/shared/string/stringHelpers.js`
16+
- `src/shared/utils/idUtils.js` now re-exports from `src/shared/id/idUtils.js`
17+
- `src/shared/utils/numberUtils.js` now re-exports from `src/shared/number/numberUtils.js`
18+
19+
## Consumers Updated
20+
- `src/shared/utils/index.js` now routes string/id/number exports through canonical homes.
21+
- `samples/shared/numberUtils.js` now imports from `src/shared/number/index.js` (single clustered number source).
22+
- `tools/shared/debugInspectorData.js` now imports number helpers from `src/shared/number/index.js`.
23+
- `tools/Performance Profiler/main.js` now imports number helpers from `src/shared/number/index.js`.
24+
- `tools/Replay Visualizer/main.js` now imports number helpers from `src/shared/number/index.js`.
25+
- `tools/shared/stringUtils.js` now imports `trimSafe` from `src/shared/string/index.js`.
26+
27+
## Focused Validation
28+
- `node --check` on all touched JS files: PASS
29+
- `node tests/shared/SharedNumberStringIdCloseout.test.mjs`: PASS
30+
- `node tests/shared/SharedFoundationCombinedPass.test.mjs`: PASS
31+
32+
## Roadmap Marker
33+
- Updated to complete:
34+
- `remaining number/string/id helpers still need exact-cluster normalization`
35+
- in both roadmap copies:
36+
- `docs/dev/roadmaps/MASTER_ROADMAP_HIGH_LEVEL.md`
37+
- `docs/MASTER_ROADMAP_HIGH_LEVEL.md`
38+
39+
## Completion Decision
40+
- The checkpoint item is now truthfully complete based on canonical `src/shared/{string,id,number}` cluster homes, compatibility-preserving wrappers, and passing focused validation.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
- Added roadmap cleanup PR for tool-governance rules
2-
- Moves tool-governance items from checklist/status tracking to top-level roadmap instructions
3-
- Preserves wording and avoids deletion
1+
- Added final exact-cluster closeout PR for remaining number/string/id helper normalization
2+
- Intended to close the last open item in the recent Shared Foundation consolidation checkpoint
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
- all specified tool-governance items moved to top-level rules/instructions area
2-
- wording preserved exactly
3-
- checklist/status markers removed from those items
4-
- roadmap task areas left with actionable work only
1+
- remaining number helper residue addressed
2+
- remaining string helper residue addressed
3+
- remaining id helper residue addressed
4+
- only exact-cluster normalization used
5+
- roadmap updated by status markers only
6+
- final checkpoint item either marked complete or exact blockers reported
57
- output ZIP created at:
6-
<project folder>/tmp/BUILD_PR_ROADMAP_TOOL_RULES_PROMOTION_AND_CLEANUP.zip
8+
<project folder>/tmp/BUILD_PR_LEVEL_03_EXACT_CLUSTER_NUMBER_STRING_ID_CLOSEOUT.zip

docs/dev/roadmaps/MASTER_ROADMAP_HIGH_LEVEL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
- [x] duplicated `asNumber` consumers migrated to shared math
209209
- [x] Asteroids numeric sanitizers promoted into shared math
210210
- [x] duplicated `asObject` / `asArray` consumers moved to shared utils
211-
- [ ] remaining number/string/id helpers still need exact-cluster normalization
211+
- [x] remaining number/string/id helpers still need exact-cluster normalization
212212

213213
---
214214

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# BUILD_PR_LEVEL_03_EXACT_CLUSTER_NUMBER_STRING_ID_CLOSEOUT
2+
3+
## Purpose
4+
Close the final remaining item in the Shared Foundation consolidation checkpoint:
5+
6+
- remaining number/string/id helpers still need exact-cluster normalization
7+
8+
## Scope
9+
Finish exact-cluster normalization for the remaining reusable helper residue in:
10+
- number helpers
11+
- string helpers
12+
- id helpers
13+
14+
## Rules
15+
- exact-cluster extraction only
16+
- no broad repo-wide cleanup pass
17+
- no blind dedupe
18+
- normalize only helpers that are clearly reusable and correctly owned by `src/shared`
19+
- preserve domain boundaries
20+
21+
## Required work
22+
1. Identify the remaining duplicated or fragmented number/string/id helper clusters.
23+
2. Normalize those helpers into the correct `src/shared` homes.
24+
3. Update consumers as needed.
25+
4. Keep changes surgical.
26+
5. Mark the checkpoint item complete only if truthfully supported.
27+
28+
## Validation
29+
Codex must report:
30+
- which exact clusters were normalized
31+
- where the helpers now live
32+
- what consumers were updated
33+
- whether the final checkpoint item can now be marked complete
34+
35+
## Packaging
36+
`<project folder>/tmp/BUILD_PR_LEVEL_03_EXACT_CLUSTER_NUMBER_STRING_ID_CLOSEOUT.zip`

samples/shared/numberUtils.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
export {
2+
isFiniteNumber,
23
toFiniteNumber,
34
asFiniteNumber,
4-
asPositiveInteger
5-
} from "../../src/shared/math/numberNormalization.js";
6-
7-
export {
8-
isFiniteNumber,
5+
asPositiveInteger,
96
asPositiveNumber
10-
} from "../../src/shared/utils/numberUtils.js";
7+
} from "../../src/shared/number/index.js";

src/shared/id/idUtils.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { sanitizeText } from "../string/index.js";
2+
3+
export function isValidId(value) {
4+
return typeof value === "string" && value.trim().length > 0;
5+
}
6+
7+
export function normalizeId(value, fallback = "") {
8+
const normalized = sanitizeText(value)
9+
.toLowerCase()
10+
.replace(/[^a-z0-9._-]+/g, "-")
11+
.replace(/-+/g, "-")
12+
.replace(/^-|-$/g, "");
13+
return normalized || sanitizeText(fallback);
14+
}
15+
16+
export function createId(prefix = "id", randomSource = Math.random) {
17+
const safePrefix = normalizeId(prefix, "id");
18+
const raw = typeof randomSource === "function" ? randomSource() : Math.random();
19+
const token = Number(raw).toString(36).slice(2, 10);
20+
return `${safePrefix}-${token || "00000000"}`;
21+
}
22+
23+
export function createStableId(parts = [], fallback = "id") {
24+
const normalized = (Array.isArray(parts) ? parts : [parts])
25+
.map((part) => normalizeId(part))
26+
.filter(Boolean);
27+
const safeFallback = normalizeId(fallback, "id");
28+
return normalized.length > 0 ? normalized.join(".") : safeFallback;
29+
}
30+
31+
export function generateId(prefix = "id", randomSource = Math.random) {
32+
return createId(prefix, randomSource);
33+
}

0 commit comments

Comments
 (0)