From cacf55960d8726c066b4602183e835d43fe17bae Mon Sep 17 00:00:00 2001 From: bohdansolovie Date: Mon, 22 Jun 2026 17:42:08 +0200 Subject: [PATCH 1/2] fix(scoring): exclude operational constants from unmodeled scoring drift Refs #809 Co-authored-by: Cursor --- src/scoring/model.ts | 20 +++++++++++++++++++- test/unit/scoring.test.ts | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/scoring/model.ts b/src/scoring/model.ts index 07b391a089..5314dad384 100644 --- a/src/scoring/model.ts +++ b/src/scoring/model.ts @@ -167,6 +167,24 @@ export function parsePythonNumberConstants(source: string, options: { knownOnly? return constants; } +/** + * Upstream operational/infra constants gittensory intentionally does not model in score previews. + * They are not scoring dimensions — surfacing them as "unmodeled drift" is noise (#809). + */ +const NON_SCORING_UPSTREAM_CONSTANT_NAMES = new Set([ + "SECONDS_PER_DAY", + "SECONDS_PER_HOUR", + "GITHUB_HTTP_TIMEOUT_SECONDS", + "MIRROR_HTTP_TIMEOUT_SECONDS", + "MIRROR_MAX_ATTEMPTS", + "TREE_SITTER_PARSE_TIMEOUT_MICROS", + "SCORING_SUBPROCESS_BUDGET_S", + "MAX_FILE_SIZE_BYTES", + "RECYCLE_UID", + "ISSUES_TREASURY_UID", + "MAX_ISSUE_ID", +]); + /** * Numeric constant names upstream gittensor defines that gittensory's scoring engine does NOT model. * The normal parse is `knownOnly` (it keeps only constants we already encode), which silently hides @@ -176,7 +194,7 @@ export function parsePythonNumberConstants(source: string, options: { knownOnly? */ export function findUnmodeledConstantKeys(allConstants: Record): string[] { return Object.keys(allConstants) - .filter((name) => !SCORING_CONSTANT_NAMES.has(name)) + .filter((name) => !SCORING_CONSTANT_NAMES.has(name) && !NON_SCORING_UPSTREAM_CONSTANT_NAMES.has(name)) .sort(); } diff --git a/test/unit/scoring.test.ts b/test/unit/scoring.test.ts index f589670214..d4d2187965 100644 --- a/test/unit/scoring.test.ts +++ b/test/unit/scoring.test.ts @@ -218,6 +218,30 @@ MAX_CODE_DENSITY_MULTIPLIER = 1.15 expect(unmodeled).not.toContain("TIME_DECAY_GRACE_PERIOD_HOURS"); // modeled as of #703 }); + it("excludes operational upstream constants from unmodeled scoring drift (#809)", () => { + const operationalOnly = findUnmodeledUpstreamConstants(` +SECONDS_PER_DAY = 86400 +SECONDS_PER_HOUR = 3600 +GITHUB_HTTP_TIMEOUT_SECONDS = 15 +MIRROR_HTTP_TIMEOUT_SECONDS = 30 +MIRROR_MAX_ATTEMPTS = 3 +TREE_SITTER_PARSE_TIMEOUT_MICROS = 5_000_000 +SCORING_SUBPROCESS_BUDGET_S = 120 +MAX_FILE_SIZE_BYTES = 1_000_000 +RECYCLE_UID = 0 +ISSUES_TREASURY_UID = 111 +MAX_ISSUE_ID = 999_999 +`); + expect(operationalOnly).toEqual([]); + + const withScoringGap = findUnmodeledUpstreamConstants(` +SECONDS_PER_DAY = 86400 +GITHUB_HTTP_TIMEOUT_SECONDS = 15 +NOVELTY_BONUS_SCALAR = 3 +`); + expect(withScoringGap).toEqual(["NOVELTY_BONUS_SCALAR"]); + }); + it("warns on the snapshot when upstream defines an unmodeled scoring dimension", async () => { const env = createTestEnv({ GITTENSOR_UPSTREAM_REPO: "custom/upstream", From 6ab9989b4621ccd0aa1d7070bb8f8f86026c5389 Mon Sep 17 00:00:00 2001 From: bohdansolovie Date: Mon, 22 Jun 2026 18:13:01 +0200 Subject: [PATCH 2/2] test(scoring): cover truncated unmodeled-constants warning branch Exercise the unmodeled.length > 12 ellipsis path in refreshScoringModelSnapshot so project coverage does not regress after operational constants are filtered. Co-authored-by: Cursor --- test/unit/scoring.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/unit/scoring.test.ts b/test/unit/scoring.test.ts index d4d2187965..ebc8df6078 100644 --- a/test/unit/scoring.test.ts +++ b/test/unit/scoring.test.ts @@ -242,6 +242,30 @@ NOVELTY_BONUS_SCALAR = 3 expect(withScoringGap).toEqual(["NOVELTY_BONUS_SCALAR"]); }); + it("truncates the unmodeled-constants warning when upstream defines more than 12 (#809)", async () => { + const env = createTestEnv({ + GITTENSOR_UPSTREAM_REPO: "custom/upstream", + GITTENSOR_UPSTREAM_REF: "staging", + }); + const manyUnmodeled = Array.from({ length: 15 }, (_, index) => `UNMODELED_CONST_${String(index).padStart(2, "0")} = ${index + 1}`).join("\n"); + vi.stubGlobal("fetch", async (input: RequestInfo | URL) => { + const url = input.toString(); + if (url.includes("constants.py")) return new Response(manyUnmodeled); + if (url.includes("programming_languages.json")) return Response.json({}); + return new Response("not found", { status: 404 }); + }); + + const refreshed = await refreshScoringModelSnapshot(env); + const warning = refreshed.warnings.find((entry) => /does not yet model/i.test(entry)); + expect(warning).toMatch(/UNMODELED_CONST_00/); + expect(warning).toMatch(/UNMODELED_CONST_11/); + expect(warning).not.toMatch(/UNMODELED_CONST_12/); + expect(warning).toMatch(/…/); + expect(refreshed.payload.constants).toMatchObject({ + unmodeledUpstreamConstants: expect.arrayContaining(["UNMODELED_CONST_00", "UNMODELED_CONST_14"]), + }); + }); + it("warns on the snapshot when upstream defines an unmodeled scoring dimension", async () => { const env = createTestEnv({ GITTENSOR_UPSTREAM_REPO: "custom/upstream",