From 4ef88141617907128f2f86f5bcb95e4fd0344fb1 Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Tue, 10 Nov 2026 01:23:14 -0600 Subject: [PATCH] fix(aggregator): remove inline banding copies shadowing aa-explorer module (#7562) --- pm-stack/aggregator/src/render.ts | 24 +----------------------- pm-stack/aggregator/test/aa.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts index dabbe78da3..8edcb1822d 100644 --- a/pm-stack/aggregator/src/render.ts +++ b/pm-stack/aggregator/src/render.ts @@ -5048,29 +5048,7 @@ import { applyInequalityFilters, bandIndex, computeRecommendations, logEdges, no // price within 25% of the band leader; the scale select multiplies all // three. Lane charts visualize the same near-leader choices as the // comparison tables; they do not recalculate band membership. - function logEdges(vals, n) { - var xs = vals.filter(function (v) { return v != null && v > 0; }); - if (!xs.length) return []; - var mn = Math.min.apply(null, xs), mx = Math.max.apply(null, xs); - if (mn === mx) return [mn, mx]; - var edges = []; - for (var i = 0; i <= n; i++) edges.push(mn * Math.pow(mx / mn, i / n)); - return edges; - } - function scoreEdges(rows, n) { - var xs = rows.map(function (p) { return p.score; }).filter(function (v) { return v != null; }); - if (!xs.length) return []; - var mn = Math.min.apply(null, xs), mx = Math.max.apply(null, xs); - var edges = []; - for (var i = 0; i <= n; i++) edges.push(mn + ((mx - mn) * i) / n); - return edges; - } - function bandIndex(v, edges) { - for (var i = 0; i < edges.length - 1; i++) { - if (v >= edges[i] && (i === edges.length - 2 ? v <= edges[i + 1] : v < edges[i + 1])) return i; - } - return -1; - } + // logEdges/scoreEdges/bandIndex come from the aa-explorer-computations.js import above (#7562): no inline copies here - an inline definition would shadow the tested module implementation. function chipFor(p, leader) { var notes = []; if (leader && leader.key !== p.key) { diff --git a/pm-stack/aggregator/test/aa.test.ts b/pm-stack/aggregator/test/aa.test.ts index bdfcba886a..10311f7701 100644 --- a/pm-stack/aggregator/test/aa.test.ts +++ b/pm-stack/aggregator/test/aa.test.ts @@ -791,6 +791,25 @@ describe("aa routes (HTTP, fixtures)", () => { expect(asset).toContain("export function computeRecommendations"); expect(asset).toContain("export function projectTask"); }); + + test("/aa page script does not redefine the computations it imports (#7562)", async () => { + // Oracle: the emitted page must execute the tested module copies. + // Any inline "function (" for an imported name shadows the + // module implementation inside the page script (#3737 regression). + const page = await (await fetch("http://127.0.0.1:" + port + "/aa")).text(); + const importMatch = page.match(/import \{([^}]+)\} from "\/assets\/aa-explorer-computations\.js";/); + expect(importMatch).not.toBeNull(); + const imported = (importMatch as RegExpMatchArray)[1] + .split(",") + .map((part) => part.trim()) + .filter(Boolean); + expect(imported).toContain("logEdges"); + expect(imported).toContain("scoreEdges"); + expect(imported).toContain("bandIndex"); + for (const name of imported) { + expect(page).not.toMatch(new RegExp("function " + name + "\\s*\\(")); + } + }); }); describe("aa chart expand + zoom/pan (#3298)", () => {