From a625596f4d4dfc8b668f800efef62888bce31f59 Mon Sep 17 00:00:00 2001 From: Joshua Horton Date: Thu, 30 Oct 2025 12:50:51 -0500 Subject: [PATCH] fix(web): assert matching transition IDs in SearchPath constructor --- .../src/main/correction/search-quotient-spur.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts index c8bb9f653e..ef0e3b22de 100644 --- a/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts +++ b/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts @@ -74,10 +74,16 @@ export abstract class SearchQuotientSpur implements SearchQuotientNode { inputStartIndex: 0 } }; + const inputSrc = inputSource as TokenInputSource; + + const transitionId = (inputs?.[0].sample.id); + if(transitionId !== undefined && inputSrc?.trueTransform.id != transitionId) { + throw new Error("Input distribution and input-source transition IDs must match"); + } this.parentNode = parentNode; this.inputSource = inputSource as TokenInputSource; - this.lowestPossibleSingleCost = (parentNode?.lowestPossibleSingleCost ?? 0) - Math.log(this.inputSource?.bestProbFromSet ?? 1); + this.lowestPossibleSingleCost = (parentNode?.lowestPossibleSingleCost ?? 0) - Math.log(inputSrc?.bestProbFromSet ?? 1); this.inputs = inputs?.length > 0 ? inputs : null; this.inputCount = (parentNode?.inputCount ?? 0) + (this.inputs ? 1 : 0); }