mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-27 02:14:30 +01:00
chore(plan-tune): remove applySignal and newDimensionTotals (#3435)
Both lost their last production caller when --derive moved onto accumulateSignals; only three unit tests referenced them. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
edd202c42d
commit
c3d045f609
2 files changed
-56
No files matched your search
@@ -306,29 +306,6 @@ export function resolveOptionKey(question_id: string, choice: string): string |
|
||||
return tie ? undefined : best;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a user choice for a question to the running dimension totals.
|
||||
*
|
||||
* @param dims - running total of dimension nudges (mutated)
|
||||
* @param signal_key - from the question registry entry
|
||||
* @param user_choice - the option key the user selected
|
||||
* @returns list of dimension deltas applied (empty if no mapping)
|
||||
*/
|
||||
export function applySignal(
|
||||
dims: Record<Dimension, number>,
|
||||
signal_key: string,
|
||||
user_choice: string,
|
||||
): DimensionDelta[] {
|
||||
const subMap = SIGNAL_MAP[signal_key];
|
||||
if (!subMap) return [];
|
||||
const deltas = subMap[user_choice];
|
||||
if (!deltas) return [];
|
||||
for (const { dim, delta } of deltas) {
|
||||
dims[dim] = (dims[dim] ?? 0) + delta;
|
||||
}
|
||||
return deltas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that every signal_key referenced in the registry has a matching
|
||||
* entry in SIGNAL_MAP. Called by tests to catch drift.
|
||||
@@ -353,17 +330,6 @@ export function validateRegistrySignalKeys(): {
|
||||
return { missing, extra };
|
||||
}
|
||||
|
||||
/** Empty dimension totals — starting point for derivation. */
|
||||
export function newDimensionTotals(): Record<Dimension, number> {
|
||||
return {
|
||||
scope_appetite: 0,
|
||||
risk_tolerance: 0,
|
||||
detail_preference: 0,
|
||||
autonomy: 0,
|
||||
architecture_care: 0,
|
||||
};
|
||||
}
|
||||
|
||||
/** Sigmoid clamp: map accumulated delta total to [0, 1]. */
|
||||
export function normalizeToDimensionValue(total: number): number {
|
||||
// Simple sigmoid: each 1.0 of accumulated delta approaches saturation.
|
||||
|
||||
@@ -29,9 +29,7 @@ import {
|
||||
} from '../scripts/one-way-doors';
|
||||
import {
|
||||
SIGNAL_MAP,
|
||||
applySignal,
|
||||
validateRegistrySignalKeys,
|
||||
newDimensionTotals,
|
||||
normalizeToDimensionValue,
|
||||
resolveOptionKey,
|
||||
ALL_DIMENSIONS,
|
||||
@@ -246,26 +244,6 @@ describe('psychographic signal map', () => {
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
|
||||
test('applySignal mutates dimension totals per mapping', () => {
|
||||
const dims = newDimensionTotals();
|
||||
const applied = applySignal(dims, 'scope-appetite', 'expand');
|
||||
expect(applied.length).toBeGreaterThan(0);
|
||||
expect(dims.scope_appetite).toBeCloseTo(0.06, 5);
|
||||
});
|
||||
|
||||
test('applySignal returns [] for unknown signal_key', () => {
|
||||
const dims = newDimensionTotals();
|
||||
const applied = applySignal(dims, 'no-such-signal', 'anything');
|
||||
expect(applied).toEqual([]);
|
||||
expect(dims.scope_appetite).toBe(0);
|
||||
});
|
||||
|
||||
test('applySignal returns [] for unknown user_choice', () => {
|
||||
const dims = newDimensionTotals();
|
||||
const applied = applySignal(dims, 'scope-appetite', 'definitely-not-a-real-choice');
|
||||
expect(applied).toEqual([]);
|
||||
});
|
||||
|
||||
test('normalizeToDimensionValue maps 0 → 0.5 (neutral)', () => {
|
||||
expect(normalizeToDimensionValue(0)).toBeCloseTo(0.5, 5);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user