From 16ccc5ce55c2fcbd37b3934e660c6a6cafb18a76 Mon Sep 17 00:00:00 2001 From: philluiz2323 Date: Sun, 26 Jul 2026 07:38:29 -0700 Subject: [PATCH] fix(scoring): skip unmodeled-drift sync on garbage upstream constants bodies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fail-closed path freezes last-good when constants.py is garbage-but-200, but with no verified last-good the refresh still fell through and ran syncUnmodeledScoringConstantDrift on HTTP-ok alone — opening a spurious drift report from HTML/LFS junk. Gate the sync on constantsUsable instead. Closes #8902 --- src/scoring/model.ts | 4 +++- test/unit/scoring.test.ts | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/scoring/model.ts b/src/scoring/model.ts index 071a89eb3f..3aa27aec2a 100644 --- a/src/scoring/model.ts +++ b/src/scoring/model.ts @@ -134,7 +134,9 @@ export async function refreshScoringModelSnapshot(env: Env): Promise { const url = input.toString(); - if (url.includes("constants.py")) return new Response("rate limited"); + // HTML garbage that still parses a few IDENT = number lines (or none) — below the recognized floor. + // Include a fake "unmodeled" CONSTANT so findUnmodeledUpstreamConstants would fire if the drift + // sync still ran on garbage (#8902). + if (url.includes("constants.py")) { + return new Response("rate limited\nFAKE_UNMODELED_CONSTANT = 1\n"); + } if (url.includes("programming_languages.json")) return Response.json({}); return new Response("not found", { status: 404 }); }); @@ -611,6 +616,8 @@ NOVELTY_BONUS_SCALAR = 3 expect(refreshed.sourceKind).toBe("fallback"); // labeled fallback, NOT a deceptive raw-github expect(refreshed.warnings.join(" ")).toMatch(/parsed only \d+ recognized constant/i); expect(refreshed.constants.MERGED_PR_BASE_SCORE).toBe(25); // the hardcoded default + // Guard must check constantsUsable, not merely HTTP-ok — no spurious drift report (#8902). + await expect(listUpstreamDriftReports(env)).resolves.toEqual([]); }); it("bootstraps to defaults (fallback) on a failed fetch ONLY when there is no verified last-good", async () => {