diff --git a/src/noise-prototypes.ts b/src/noise-prototypes.ts index ac62dbf..4dc8827 100644 --- a/src/noise-prototypes.ts +++ b/src/noise-prototypes.ts @@ -83,6 +83,23 @@ export class NoisePrototypeBank { } this.builtinCount = this.vectors.length; this._initialized = true; + + // Degeneracy check: if all prototype vectors are nearly identical, the + // embedding model does not produce discriminative outputs (e.g. a + // deterministic mock that ignores text). In that case the noise bank + // would flag every input as noise, so we disable ourselves. + if (this.vectors.length >= 2) { + const sim = cosine(this.vectors[0], this.vectors[1]); + if (sim > 0.98) { + this.debugLog( + `noise-prototype-bank: degenerate embeddings detected (pairwise cosine=${sim.toFixed(4)}), disabling noise filter`, + ); + this._initialized = false; + this.vectors = []; + return; + } + } + this.debugLog( `noise-prototype-bank: initialized with ${this.builtinCount} built-in prototypes`, );