Skip to content

fix(signals): count scoped related-work as the union of PR-specific and preflight clusters#425

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
philluiz2323:fix/pr-panel-scoped-overlap-union
Jun 6, 2026
Merged

fix(signals): count scoped related-work as the union of PR-specific and preflight clusters#425
JSONbored merged 2 commits into
JSONbored:mainfrom
philluiz2323:fix/pr-panel-scoped-overlap-union

Conversation

@philluiz2323
Copy link
Copy Markdown
Contributor

Summary

The public PR panel comment (buildPublicPrIntelligenceComment, src/signals/engine.ts) derived the "Duplicate risk" row's scoped-overlap count from the maximum of two cluster-source lengths, while the panel's "Review context" details section listed their deduplicated union:

const scopedOverlapCount = Math.max(prCollisionClusters.length, args.preflight.collisions.length);   // before: max
// ...
const overlapDetails = relatedWorkDetails(args.pr, prCollisionClusters, args.preflight.collisions);   // dedup union internally

The two sources are different filtered subsets of the same collision report (shared id scheme): prCollisionClusters are clusters whose items include this PR, and args.preflight.collisions are clusters that term-overlap the planned contribution. A cluster can be in one set and not the other, so max(|A|, |B|) understates |A ∪ B|. The result was a self-inconsistent comment: the "Duplicate risk" row could say "3 scoped related-work signals" while the details block directly below enumerated 4+ items, and the understated count also flipped duplicateRiskAction guidance. Closes #424.

Scope

  • src/signals/engine.ts:
    • Compute the deduplicated union of prCollisionClusters and args.preflight.collisions once (scopedOverlapClusters), and use its length for scopedOverlapCount.
    • Refactor relatedWorkDetails to take that same deduped cluster set, so the headline count and the listed items are computed from one source and can never diverge again.
  • test/unit/signals-coverage.test.ts:
    • Fail-on-revert: a PR that sits in 2 repo collision clusters disjoint from 3 preflight clusters now renders "5 scoped related-work signals" (the union); the old Math.max(2, 3) = 3 value is asserted absent.

Validation

  • npx tsc --noEmit -- clean.
  • npx vitest run test/unit/signals-coverage.test.ts test/unit/signals.test.ts test/unit/signals-v2.test.ts -- pass (including the new test).
  • Full suite -- 1132 passed, 1 skipped (excluding the two unparseable upstream test files and one unrelated mcp-cli timeout that passes in isolation).
  • Branch coverage 97.02% (above the 97% gate); engine.ts 98.05% branch.

Safety

  • No output-shape change: the panel renders the same rows/sections; only the (now correct, union) scoped-overlap count and the matching action text change, and only when the two cluster sets differ.
  • The existing scoped-overlap test (PR-specific clusters empty) is unaffected because union == max there.

Notes

displayScopedCount still caps the rendered value at 9+; this fix corrects the underlying count below that cap and keeps it consistent with the related-work items the panel lists.

@philluiz2323 philluiz2323 requested a review from JSONbored as a code owner June 5, 2026 15:27
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 5, 2026
@github-actions github-actions Bot added the bug Something isn't working label Jun 5, 2026
@gittensory
Copy link
Copy Markdown

gittensory Bot commented Jun 5, 2026

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #425 is no longer open. No action.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

@gittensory gittensory Bot added the gittensory:reviewed Gittensor contributor context label Jun 5, 2026
@philluiz2323 philluiz2323 force-pushed the fix/pr-panel-scoped-overlap-union branch from eafc0d6 to 907ba33 Compare June 5, 2026 22:04
@github-actions github-actions Bot added the gittensor:bug Gittensor-scored bug fix label Jun 6, 2026
Copy link
Copy Markdown
Owner

@JSONbored JSONbored left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philluiz2323 this is ready from my side.

A few notes:

  • The fix matches the actual #424 bug: the public panel count now uses the deduped union of PR-specific and preflight clusters.
  • The regression covers the case that used to undercount related work.
  • Non-Gittensory checks are green, and I do not have code changes to request.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 6, 2026
@JSONbored JSONbored merged commit c65da03 into JSONbored:main Jun 6, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working gittensor:bug Gittensor-scored bug fix gittensory:reviewed Gittensor contributor context lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: Done

2 participants