MCPcopy Create free account
hub / github.com/garrytan/gstack / primaryDimensionFor

Function primaryDimensionFor

scripts/declared-annotation.ts:87–106  ·  view source on GitHub ↗
(signalKey: string)

Source from the content-addressed store, hash-verified

85 * Returns null if the signal_key isn't in the map.
86 */
87export function primaryDimensionFor(signalKey: string): Dimension | null {
88 const entry = SIGNAL_MAP[signalKey];
89 if (!entry) return null;
90 const totals: Partial<Record<Dimension, number>> = {};
91 for (const choice of Object.keys(entry)) {
92 for (const dd of entry[choice]) {
93 totals[dd.dim] = (totals[dd.dim] ?? 0) + Math.abs(dd.delta);
94 }
95 }
96 let best: Dimension | null = null;
97 let bestVal = -Infinity;
98 for (const d of ALL_DIMENSIONS) {
99 const v = totals[d] ?? 0;
100 if (v > bestVal) {
101 bestVal = v;
102 best = d;
103 }
104 }
105 return bestVal > 0 ? best : null;
106}
107
108/**
109 * Given a signal_key, return a one-line plain-English annotation when

Callers 2

getDeclaredAnnotationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected