From f0f19f6696deab67316536f4a82f2e08c0029d63 Mon Sep 17 00:00:00 2001 From: real-venus Date: Fri, 17 Jul 2026 01:34:10 -0700 Subject: [PATCH] fix(signals): make shouldPublishPrIntelligenceComment respect commentMode for oss_maintainer (#6776) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The oss_maintainer branch returned `commentMode === "all_prs" || detection.detected || detection.source !== "official_gittensor_api"`. The third disjunct is a tautology: `detection.source` is only ever "official_gittensor_api" (paired with detected: true) or undefined, so it is true whenever `detected` is false — making the whole branch unconditionally true. For every oss_maintainer-audience repo, `commentMode: "detected_contributors_only"` silently behaved like `"all_prs"`, defeating the gate. Drops the tautological disjunct so the branch gates on commentMode + detection, matching the documented single source of truth (`shouldPublishPrComment`). Adds the previously-absent oss_maintainer branch tests, including the regression: detected_contributors_only + an undetected contributor now returns false. Closes #6776 --- packages/loopover-engine/src/signals/engine.ts | 6 +++++- test/unit/signals.test.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/loopover-engine/src/signals/engine.ts b/packages/loopover-engine/src/signals/engine.ts index 2d2634fbd..09e9a3def 100644 --- a/packages/loopover-engine/src/signals/engine.ts +++ b/packages/loopover-engine/src/signals/engine.ts @@ -1419,7 +1419,11 @@ export function detectGittensorContributor( export function shouldPublishPrIntelligenceComment(settings: RepositorySettings, detection: ContributorDetection): boolean { if (settings.commentMode === "off") return false; if (settings.publicSurface !== "comment_and_label" && settings.publicSurface !== "comment_only") return false; - if (settings.publicAudienceMode === "oss_maintainer") return settings.commentMode === "all_prs" || detection.detected || detection.source !== "official_gittensor_api"; + // #6776: gate on commentMode, not the audience. The dropped `detection.source !== "official_gittensor_api"` + // disjunct was a tautology -- source is only ever "official_gittensor_api" (paired with detected: true) or + // undefined, so it was true whenever `detected` was false, making the whole branch unconditionally true and + // silently treating `detected_contributors_only` as `all_prs` for every oss_maintainer repo. + if (settings.publicAudienceMode === "oss_maintainer") return settings.commentMode === "all_prs" || detection.detected; return detection.detected && detection.source === "official_gittensor_api"; } diff --git a/test/unit/signals.test.ts b/test/unit/signals.test.ts index e108ceb10..8df900400 100644 --- a/test/unit/signals.test.ts +++ b/test/unit/signals.test.ts @@ -820,6 +820,19 @@ describe("world-class backend signals", () => { expect(shouldPublishPrIntelligenceComment({ ...settings, commentMode: "all_prs" }, undetected)).toBe(false); expect(shouldPublishPrIntelligenceComment({ ...settings, commentMode: "all_prs" }, cachedDetected)).toBe(false); expect(shouldPublishPrIntelligenceComment({ ...settings, commentMode: "all_prs" }, { ...cachedDetected, source: "official_gittensor_api" })).toBe(true); + + // #6776: the oss_maintainer branch must respect commentMode, not silently treat detected_contributors_only + // as all_prs. (The dropped `source !== "official_gittensor_api"` disjunct was a tautology making it always true.) + const ossSettings = { ...settings, publicAudienceMode: "oss_maintainer" as const }; + // commentMode: all_prs short-circuits true even for an undetected contributor. + expect(shouldPublishPrIntelligenceComment({ ...ossSettings, commentMode: "all_prs" }, undetected)).toBe(true); + // REGRESSION: detected_contributors_only + an undetected contributor → false (previously an always-true tautology). + expect(shouldPublishPrIntelligenceComment({ ...ossSettings, commentMode: "detected_contributors_only" }, undetected)).toBe(false); + // A detected (even non-official) contributor still comments: the gate is now commentMode + detected, with no + // audience/source carve-out — locking in the intended, tautology-free semantics. + expect(cachedDetected.detected).toBe(true); + expect(cachedDetected.source).not.toBe("official_gittensor_api"); + expect(shouldPublishPrIntelligenceComment({ ...ossSettings, commentMode: "detected_contributors_only" }, cachedDetected)).toBe(true); }); it("returns hold/caution opportunities for inactive and issue-discovery lanes", () => {