From 0adcdaa1e57105bab464a134dff2bdf36c17386b Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Thu, 28 May 2026 12:46:27 -0300 Subject: [PATCH] feat(open-sse): propagate quotaSoftDeprioritize from chatCore to combo candidate (B/G2) Replace `void quotaSoftDeprioritize` with a live call to setCandidateQuotaSoftPenalty when isCombo && comboStepId are set and enforceQuotaShare returned deprioritize=true. Uses dynamic import so the combo service is only loaded for combo requests. Fail-open: import/call errors log a warn but never block the request (consistent with the existing quota enforcement fail-open policy in B/F7). --- open-sse/handlers/chatCore.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/open-sse/handlers/chatCore.ts b/open-sse/handlers/chatCore.ts index 18358ff38b..dd7f7b4113 100644 --- a/open-sse/handlers/chatCore.ts +++ b/open-sse/handlers/chatCore.ts @@ -3418,9 +3418,18 @@ export async function handleChatCore({ ); } } - // Suppress unused variable lint warning — quotaSoftDeprioritize is available for - // combo.ts to read when candidateBuilder populates quotaSoftPenalty in the future. - void quotaSoftDeprioritize; + // G2: Propagate soft penalty to the current candidate so combo scoring can deprioritize. + if (quotaSoftDeprioritize && isCombo && comboStepId) { + try { + const { setCandidateQuotaSoftPenalty } = await import("../services/combo"); + setCandidateQuotaSoftPenalty(comboExecutionKey, comboStepId, true); + } catch (err) { + log?.warn?.( + "QUOTA_SHARE", + `[quotaShare] could not set soft penalty on candidate: ${err instanceof Error ? err.message : String(err)}` + ); + } + } // === /Quota Share enforcement PRE-hook === // Get executor for this provider (with optional upstream proxy routing)