Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/loopover-engine/src/signals/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
13 changes: 13 additions & 0 deletions test/unit/signals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down