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

Function matchArchetype

scripts/archetypes.ts:165–181  ·  view source on GitHub ↗
(dims: Record<Dimension, number>)

Source from the content-addressed store, hash-verified

163 * Returns FALLBACK_ARCHETYPE if no defined archetype is within threshold.
164 */
165export function matchArchetype(dims: Record<Dimension, number>): Archetype {
166 let best: Archetype = FALLBACK_ARCHETYPE;
167 let bestScore = Infinity; // lower is better
168 // Threshold: if no archetype scores below this, return Polymath.
169 // Max possible distance in [0,1]^5 is sqrt(5) ≈ 2.236. 0.55 = ~half the space.
170 const THRESHOLD = 0.55;
171 for (const arch of ARCHETYPES) {
172 const dist = euclidean(dims, arch.center);
173 // Scale by tightness — tighter archetypes require smaller actual distance.
174 const scaled = dist / (arch.tightness || 1);
175 if (scaled < bestScore && scaled <= THRESHOLD) {
176 bestScore = scaled;
177 best = arch;
178 }
179 }
180 return best;
181}
182
183/** All archetype names, useful for tests and /plan-tune stats. */
184export function getAllArchetypeNames(): string[] {

Callers 1

plan-tune.test.tsFile · 0.90

Calls 1

euclideanFunction · 0.85

Tested by

no test coverage detected