diff --git a/src/queue-intelligence.ts b/src/queue-intelligence.ts index 51352273c5..422935f810 100644 --- a/src/queue-intelligence.ts +++ b/src/queue-intelligence.ts @@ -43,7 +43,7 @@ const MILLISECONDS_PER_DAY = 1000 * 60 * 60 * 24; /** * #9432: ordinary English that carries gittensor meaning ONLY in context. Each of these is a word a perfectly * safe review of this codebase's own gate/scoring code uses naturally -- "updates the ranking comparator", - * "this improves reviewability", "the reward path". They are still matched by default (unchanged), but a repo + * "this improves reviewability", "the farming loop". They are still matched by default (unchanged), but a repo * that has POSITIVELY confirmed via {@link isPublicScoreTermSafeForRepo}'s allowlist that this vocabulary is * safe public language for it can exempt them, exactly as bare "score" already could. * @@ -51,12 +51,10 @@ const MILLISECONDS_PER_DAY = 1000 * 60 * 60 * 24; * VALUE, and a value never appears as a bare noun -- it appears qualified ("reward estimate 12 TAO", "trust * score 0.82", "score preview"). Every one of those QUALIFIED forms lives in * {@link ALWAYS_FORBIDDEN_PUBLIC_COMMENT_WORDS} below and stays enforced for every repo, allowlisted or not. - * A bare "reward" or "ranking" with no number attached leaks nothing on its own. This generalizes the exact + * A bare "ranking" or "cohort" with no number attached leaks nothing on its own. This generalizes the exact * judgment `allowBareScoreTerm` already made for "score" to its siblings, rather than inventing a new one. */ export const AMBIGUOUS_PUBLIC_COMMENT_WORDS = [ - "rewards", - "reward", "farming", "rankings", "ranking", @@ -80,6 +78,10 @@ export const ALWAYS_FORBIDDEN_PUBLIC_COMMENT_WORDS = [ "reward estimate", "estimated rewards", "estimated reward", + // #9702: a bare "reward"/"rewards" names the private concept regardless of repo -- moved here from the + // AMBIGUOUS tier so `allowBareScoreTerm` can never let it through (it was reaching allowlisted repos verbatim). + "rewards", + "reward", "private reviewability", "reviewability internals", "private scoreability", @@ -233,17 +235,18 @@ export function shouldWarnPublicScoreTermsAllowlistUnset(env: Record { + it("REGRESSION (#9432): an allowlisted repo keeps a sentence using ordinary review English — 'reviewability', 'ranking', 'cohort'", () => { // These are words a safe review of this codebase's own gate code uses naturally. Before the tiering they // were matched unconditionally, so a sentence like "this improves reviewability" was dropped from the // published narrative for every repo, allowlisted or not. @@ -436,13 +436,40 @@ describe("sanitizePublicComment — allowBareScoreTerm option (#public-score-ter it("SECURITY: a QUALIFIED private value stays blocked for an allowlisted repo even though its bare noun is exempt", () => { // The decisive property behind the tiering: a leaked value is always qualified, and the qualified form - // lives in the always-forbidden tier. "reward" is exempt; "reward estimate 12 TAO" is not. + // lives in the always-forbidden tier. "ranking" is exempt; "private ranking" is not. expect(() => sanitizePublicComment("the reward estimate is 12 TAO", { allowBareScoreTerm: true })).toThrow(); expect(() => sanitizePublicComment("raw trust score 0.82 for this miner", { allowBareScoreTerm: true })).toThrow(); expect(() => sanitizePublicComment("wallet 5Gv... and hotkey", { allowBareScoreTerm: true })).toThrow(); }); }); +describe("sanitizePublicComment — bare 'reward' is never skippable (#9702)", () => { + it("REGRESSION (#9702): a bare 'reward' is rejected even for an allowlisted repo — the doc's safety claim now holds in code", () => { + // Before #9702, allowBareScoreTerm swapped in ALWAYS_FORBIDDEN, which did not contain a bare "reward" -- + // so `ghs_`-style installation-token adjacent gittensor "reward" language reached an allowlisted repo's + // public surface verbatim, contradicting the JSDoc that claimed "reward" was NEVER skippable. + expect(() => sanitizePublicComment("12 TAO reward for this", { allowBareScoreTerm: true })).toThrow(/reward/i); + expect(() => sanitizePublicComment("nice rewards here", { allowBareScoreTerm: true })).toThrow(/reward/i); + }); + + it("preserves the intended relaxation: a bare 'score' still passes for an allowlisted repo", () => { + expect(sanitizePublicComment("this scores well", { allowBareScoreTerm: true })).toBe("this scores well"); + }); + + it("is not a behaviour swap: a bare 'reward' still throws with the flag off (unchanged default)", () => { + expect(() => sanitizePublicComment("12 TAO reward for this")).toThrow(/reward/i); + }); + + it("INVARIANT (#9702): 'reward'/'rewards' live in the always-forbidden tier and never in the ambiguous tier", () => { + const always = new Set(ALWAYS_FORBIDDEN_PUBLIC_COMMENT_WORDS); + const ambiguous = new Set(AMBIGUOUS_PUBLIC_COMMENT_WORDS); + for (const neverSkippable of ["reward", "rewards"]) { + expect(always.has(neverSkippable), neverSkippable).toBe(true); + expect(ambiguous.has(neverSkippable), neverSkippable).toBe(false); + } + }); +}); + describe("isPublicScoreTermSafeForRepo (#public-score-terms-scoping)", () => { it("denies (fail-closed) when the env var is unset", () => { expect(isPublicScoreTermSafeForRepo({}, "JSONbored/metagraphed")).toBe(false);