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).
This commit is contained in:
diegosouzapw
2026-05-28 12:46:27 -03:00
parent 0de8c6aef4
commit 0adcdaa1e5

View File

@@ -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)