Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,7 @@
## 2026-09-09 - Eliminate Array Spread in Zoomed Chart Bounds
**Learning:** Using `Math.min(...spread)` and `Math.max(...spread)` to calculate bounds on zoomable ensemble scatter plots maps the array to the call stack. This creates call stack pressure, garbage collection hits, and scales poorly on zooming.
**Action:** Replace `Math.min/max(...spread)` bounds calculations with a standard single-pass `for` loop in charting hot paths.

## 2026-09-09 - Eliminate Math.max(...map) chains
**Learning:** Calling Math.max(...array.map()) creates intermediate arrays and pushes them all to the call stack via the spread operator, leading to GC pressure and potential stack overflow for large arrays.
**Action:** Replace Math.max(...array.map()) and Math.min(...array.map()) with a standard single-pass for loop, allocating no intermediate memory and eliminating spread overhead.
30 changes: 15 additions & 15 deletions manuals/tools/handoff-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,61 @@
"issue_url": "https://github.com/D-sorganization/Tools/issues/4730",
"pr_url": "https://github.com/D-sorganization/Tools/pull/5055",
"commit_evidence": {
"local_head_sha": "9248c87c10a8da1bb07e0bc8c0daa8ba491d0c7a",
"local_head_sha": "6abb9b1e455864973675a5930bc6e3ce5819d822",
"remote_head_sha": null,
"reviewed_tree_sha": "42d8f4d038e3819b98b4671fe67d80246bcf8704",
"reviewed_tree_sha": "94cbccaa786669c1503c0744d830cca83f1510d1",
"merge_sha": null
},
"branch_and_worktree": {
"branch": "palette/add-focus-states-to-torque-panel-2699792544054811075",
"branch": "bolt-optimization-math-max-map-114777708485744154",
"worktree": "C:\\Users\\diete\\Repositories\\Tools",
"is_clean": true
"is_clean": false
},
"check_evidence": {
"check_design_manual_governance": {
"command": "python -m scripts.check_design_manual_governance",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
},
"build_tools_module_inventory": {
"command": "python -m scripts.build_tools_module_inventory --check",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
},
"lint_tools_textbook_chapters": {
"command": "python -m scripts.lint_tools_textbook_chapters",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
},
"check_tools_exemplars": {
"command": "python -m scripts.check_tools_exemplars",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
},
"check_tools_calculation_freshness": {
"command": "python -m scripts.check_tools_calculation_freshness --check",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
},
"check_tools_manual_qa": {
"command": "python -m scripts.check_tools_manual_qa --check",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
},
"check_tools_publication_projection": {
"command": "python -m scripts.check_tools_publication_projection --check",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
},
"render_tools_design_manual": {
"command": "python -m scripts.render_tools_design_manual --check",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
},
"check_tools_handoff": {
"command": "python -m scripts.check_tools_handoff --check",
"status": "passed",
"timestamp": "2026-09-10T10:33:04Z"
"timestamp": "2026-09-10T10:54:22Z"
}
},
"artifact_and_test_digests": {
Expand Down Expand Up @@ -112,7 +112,7 @@
"TOOLS-HUMAN-APPROVAL-PENDING",
"TOOLS-MARKERLESS-EXEMPLAR-BLOCKED"
],
"expiry_timestamp": "2026-12-09T10:33:04Z"
"expiry_timestamp": "2026-12-09T10:54:22Z"
},
"blockers": [
{
Expand All @@ -127,7 +127,7 @@
}
],
"next_dependency": "TOOLS-M0 (#4708 / #4734) and parent epic DOC-TOOLS (#4707) closure",
"freshness_timestamp": "2026-09-10T10:33:04Z",
"freshness_timestamp": "2026-09-10T10:54:22Z",
"governed_handoff_files": {
"AGENT_HANDOFF.md": {
"path": "AGENT_HANDOFF.md",
Expand Down
2 changes: 1 addition & 1 deletion manuals/tools/manifests/module-inventory.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
"path": "manuals/tools/manifests/module-inventory/entries-src-p1am-control-system.json"
},
{
"content_sha256_lf": "79b71001801822b1e45008de285dff878e16b0f0ef27157ecee8db109226b5c0",
"content_sha256_lf": "9f0c666384438e9d8b82c9d9e410a2de1bc8086ef783047232c02e28f84af1ee",
"entry_count": 167,
"package": "src/pendulum_simulator",
"path": "manuals/tools/manifests/module-inventory/entries-src-pendulum-simulator.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2288,10 +2288,10 @@
},
{
"authority_status": "provisional",
"bytes_lf": 2826,
"bytes_lf": 3143,
"classification": "calculation",
"classification_basis": "path-marker:force",
"content_sha256_lf": "f67202fb46382c304a2eb1f584fd38d35a41558200e3dfaae6ecd56f343f3da6",
"content_sha256_lf": "875fb1b44047d23a56b9281aff17ab752073202d01af1c1cf7cc88ef7b146599",
"family": "pendulum-calculation",
"id": "TOOLS-MODULE-SRC-PENDULUM-SIMULATOR-PENDULUM-WEB-SCRIPTS-AUDITFORCESOURCEFAIRNESS-TS-712B4AD4E89D",
"language": "typescript",
Expand Down Expand Up @@ -3526,10 +3526,10 @@
},
{
"authority_status": "provisional",
"bytes_lf": 19240,
"bytes_lf": 19469,
"classification": "calculation",
"classification_basis": "path-marker:force",
"content_sha256_lf": "3d30558b024a2a25b48052b140dba396f4290688d0dbaf81679c0408d6b3c875",
"content_sha256_lf": "97633b6d5f2727c1667a06cec6ae1eec6fe4d18fe33714c7e2283017bc284696",
"family": "pendulum-calculation",
"id": "TOOLS-MODULE-SRC-PENDULUM-SIMULATOR-PENDULUM-WEB-SRC-FORCESOURCEARTIFACT-TS-20BDD5DAD377",
"language": "typescript",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ const fullyFair = inSpeedBand.filter(item => inEffortCaps.includes(item));
const speed = (item: typeof scenarios[number]) => item.series.clubhead_speed_m_s[
item.series.clubhead_speed_m_s.length - 1
] ?? 0;
const extrema = <T>(values: T[], value: (item: T) => number) => values.length === 0 ? null : {
min: Math.min(...values.map(value)),
max: Math.max(...values.map(value)),
const extrema = <T>(values: T[], value: (item: T) => number) => {
if (values.length === 0) return null;
// ⚡ Bolt Optimization: Use single-pass loop instead of Math.min(...)/Math.max(...) combined with .map() to avoid GC pressure and call stack limits
let min = Infinity;
let max = -Infinity;
for (let i = 0; i < values.length; i++) {
const val = value(values[i]);
if (val < min) min = val;
if (val > max) max = val;
}
return { min, max };
};

process.stdout.write(`${JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,12 @@ function validateObjectiveDominance(scenarios: ForceSourceScenario[]): void {
if (Math.abs(ownScore - scenario.score) > tolerance) {
throw new TypeError(`${scenario.objective} score does not match its registered series`);
}
const displayedBest = Math.max(...scores.map(score => score[scenario.objective]));
// ⚡ Bolt Optimization: Single-pass for loop instead of Math.max(...map()) to avoid intermediate arrays
let displayedBest = -Infinity;
for (let i = 0; i < scores.length; i++) {
const v = scores[i][scenario.objective];
if (v > displayedBest) displayedBest = v;
}
if (ownScore < displayedBest - tolerance) {
throw new RangeError(`${scenario.objective} loses its objective to another displayed scenario`);
}
Expand Down
17 changes: 15 additions & 2 deletions src/pendulum_simulator/pendulum-web/tests/forceSourceStudy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,14 @@ describe('force-source artifact contract', () => {
artifact.scenarios.find(item => item.objective === 'coriolis_impulse')?.profile_id,
);
for (const [index, scenario] of artifact.scenarios.entries()) {
// ⚡ Bolt Optimization: Single-pass for loop to avoid intermediate array allocation
let maxScore = -Infinity;
for (let i = 0; i < crossScores.length; i++) {
const s = crossScores[i][scenario.objective];
if (s > maxScore) maxScore = s;
}
expect(crossScores[index][scenario.objective]).toBeCloseTo(
Math.max(...crossScores.map(scores => scores[scenario.objective])),
maxScore,
10,
);
expect(scenario.series.arm_angle_rad[0]).toBe(artifact.initial_pose.arm_angle_rad);
Expand Down Expand Up @@ -377,8 +383,15 @@ describe('cross-objective optimizer certification', () => {
const speed = scenarios.find(item => item.objective === 'clubhead_speed');

expect(speed).toBeDefined();
// ⚡ Bolt Optimization: Single-pass loop replaces Math.max(...map())
let maxSpeed = -Infinity;
for (let i = 0; i < crossScores.length; i++) {
if (crossScores[i].clubhead_speed > maxSpeed) {
maxSpeed = crossScores[i].clubhead_speed;
}
}
expect(speed?.score).toBeCloseTo(
Math.max(...crossScores.map(scores => scores.clubhead_speed)),
maxSpeed,
10,
);
expect(new Set(scenarios.map(item => item.comparison_contract_id)).size).toBe(1);
Expand Down
Loading