Repository navigation
🐛 gfi: withdraw the invite once a PR covers the issue; never advertise relay-refused issues #18834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hivecommons-hive
merged 3 commits into
hivecommons:v6
from
Danathar:fix/gfi-withdraw-covered-skip-relay-refused
Nov 18, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
c041719
🐛 gfi: withdraw the invite once a PR covers the issue; never advertis…
Danathar 0d8365a
Merge branch 'v6' into fix/gfi-withdraw-covered-skip-relay-refused
hivecommons-hive[bot] 2fed82f
Merge branch 'v6' into fix/gfi-withdraw-covered-skip-relay-refused
hivecommons-hive[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Good-first-issue curation no longer keeps inviting newcomers to issues the contributor relay will not hand out. An advertised issue that a pull request later covers (its `claimed_by_pr` row, `linked-pr`, or `stage/040-covered-by-pr`) now loses `good first issue` and `help wanted` on the next sweep, and its welcome comment is edited to say a pull request covers it; a relay contributor's or person's own claim still keeps the label until the issue closes. The sweep also skips any issue matching `hub.contribute_skip_labels` (`needs-triage` by default, logged as `relay-skip:<label>`), so an untriaged issue is never advertised; an already-advertised issue that later gains such a label keeps its invite, since triage adds and removes it all the time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,8 +101,11 @@ func gfiPublicOrigin(cfg *config.Config) string { | |
| // gfiSweepOptions builds the per-call options shared by the sweep and hooks. | ||
| func gfiSweepOptions(cfg *config.Config, dashSrv *dashboard.Server, logger *slog.Logger) gfi.SweepOptions { | ||
| gc := cfg.GoodFirstIssue | ||
| policy := gc.Policy(github.HardSuppressIssueLabels()) | ||
| // Never advertise what the contributor relay refuses to hand out. | ||
| policy.RelaySkip = cfg.Hub.MatchContributeSkipLabel | ||
| opts := gfi.SweepOptions{ | ||
| Policy: gc.Policy(github.HardSuppressIssueLabels()), | ||
| Policy: policy, | ||
| Links: gfi.Links{Origin: gfiPublicOrigin(cfg), HiveID: cfg.HiveID, DocsBase: gc.DocsURL}, | ||
| Template: gc.CommentTemplate, | ||
| Logger: logger, | ||
|
|
@@ -155,12 +158,14 @@ func gfiCandidates(org string, result *github.ActionableResult, allowed func(str | |
| out = append(out, c) | ||
| } | ||
| // Issues the enumeration filtered out (blocked, held, parked on a | ||
| // person) that still wear the label are handed to the sweep so it can | ||
| // withdraw the advertisement (hivecommons/hive#13267); the labels alone | ||
| // decide, so the missing body is harmless. | ||
| // person) or set aside because a pull request covers them, that still | ||
| // wear the label, are handed to the sweep so it can withdraw the | ||
| // advertisement (hivecommons/hive#13267); the labels and the coverage | ||
| // alone decide, so the missing body is harmless. | ||
| for _, repo := range sortedRepoKeys(result.WorkDetailsByRepo) { | ||
| for _, row := range result.WorkDetailsByRepo[repo].Issues { | ||
| if row.Number <= 0 || row.Bucket != "filtered" || !gfi.HasLabel(row.Labels) { | ||
| covered := row.Bucket == "claimed_by_pr" | ||
| if row.Number <= 0 || row.Bucket != "filtered" && !covered || !gfi.HasLabel(row.Labels) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Readability nit: this condition mixes covered := row.Bucket == "claimed_by_pr"
if row.Number <= 0 || !(row.Bucket == "filtered" || covered) || !gfi.HasLabel(row.Labels) { |
||
| continue | ||
| } | ||
| full := qualifyClaimRepo(org, row.Repo) | ||
|
|
@@ -174,6 +179,16 @@ func gfiCandidates(org string, result *github.ActionableResult, allowed func(str | |
| // the label (hivecommons/hive#14613). | ||
| c.Body = gfi.TrackingMarker | ||
| } | ||
| if covered { | ||
| c.HasLinkedPR = true | ||
| // A relay contributor or person who claimed the issue and | ||
| // opened the PR is the outcome the label exists for: it stays | ||
| // until the issue closes (gfi.Sweeper.Convert), so Score | ||
| // reports "claimed", which is never withdrawn. | ||
| if kind := claims.Kind(row.ClaimKind); (kind == claims.KindContributor || kind == claims.KindHuman) && strings.TrimSpace(row.ClaimedBy) != "" { | ||
| c.ClaimedBy = row.ClaimedBy | ||
| } | ||
| } | ||
| if labelled[c.Key()] { | ||
| continue | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| package gfi | ||
|
|
||
| import ( | ||
| "context" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| // relaySkipNeedsTriage stands in for hub.contribute_skip_labels with the | ||
| // labels the default set shares with the GFI gates (`blocked`, `tracking`) | ||
| // plus `needs-triage`. | ||
| func relaySkipNeedsTriage(labels []string) (string, bool) { | ||
| for _, l := range labels { | ||
| switch strings.ToLower(strings.TrimSpace(l)) { | ||
| case "needs-triage", "blocked", "tracking": | ||
| return l, true | ||
| } | ||
| } | ||
| return "", false | ||
| } | ||
|
|
||
| func TestScoreRelaySkip(t *testing.T) { | ||
| p := Policy{RelaySkip: relaySkipNeedsTriage} | ||
| c := good() | ||
| c.Labels = append(c.Labels, "needs-triage") | ||
| if d := Score(c, p, now); d.Eligible || d.Skip != SkipRelaySkip+":needs-triage" { | ||
| t.Fatalf("needs-triage: %+v", d) | ||
| } | ||
| if d := Score(c, Policy{}, now); !d.Eligible { | ||
| t.Fatalf("no matcher, no relay gate: %+v", d) | ||
| } | ||
| if d := Score(good(), p, now); !d.Eligible { | ||
| t.Fatalf("control: %+v", d) | ||
| } | ||
| // The withdrawable gates still come first: `blocked` is in the relay's | ||
| // default skip set too, and must keep withdrawing. | ||
| c = good() | ||
| c.Labels = append(c.Labels, "blocked", "needs-triage") | ||
| if d := Score(c, p, now); d.Skip != "excluded-label:blocked" || !Withdrawable(d.Skip) { | ||
| t.Fatalf("blocked: %+v", d) | ||
| } | ||
| } | ||
|
|
||
| func TestWithdrawableCoveredAndRelaySkip(t *testing.T) { | ||
| for _, s := range []string{SkipLinkedPR, "excluded-label:stage/040-covered-by-pr", "excluded-label:Stage/040-Covered-By-PR"} { | ||
| if !Withdrawable(s) { | ||
| t.Errorf("%q should withdraw", s) | ||
| } | ||
| } | ||
| for _, s := range []string{SkipRelaySkip + ":needs-triage", SkipRelaySkip + ":question", "excluded-label:stage/030-pr-in-progress"} { | ||
| if Withdrawable(s) { | ||
| t.Errorf("%q should not withdraw", s) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // projectbluefin/website#1031: advertised at stage/010, then a pull request | ||
| // covered it. The next sweep takes both labels off and edits the welcome | ||
| // comment to say a PR covers it, without calling it "not newcomer work". | ||
| func TestSweepWithdrawsIssueAPullRequestCovers(t *testing.T) { | ||
| forge := newFakeForge() | ||
| s := NewSweeper() | ||
| var events []Event | ||
| opts := quietOpts() | ||
| opts.Audit = func(e Event) { events = append(events, e) } | ||
|
|
||
| c := good() | ||
| c.Labels = append([]string{Label, HelpWantedLabel}, c.Labels...) | ||
| c.HasLinkedPR = true | ||
| forge.comments[c.Key()] = []string{Marker + "\n### 🌱 Good first issue"} | ||
|
|
||
| res := s.Sweep(context.Background(), forge, []Candidate{c}, opts) | ||
| if len(res.Withdrawn) != 1 || res.Skipped[SkipLinkedPR] != 1 || len(res.Selected) != 0 || res.Errors != 0 { | ||
| t.Fatalf("result %+v", res) | ||
| } | ||
| if got := strings.Join(forge.removed[c.Key()], ","); got != Label+","+HelpWantedLabel { | ||
| t.Fatalf("removed %q", got) | ||
| } | ||
| if n := forge.commentCount(c.Repo, c.Number); n != 1 { | ||
| t.Fatalf("comment count %d (must edit, not add)", n) | ||
| } | ||
| body := forge.comments[c.Key()][0] | ||
| if !strings.Contains(body, SupersededMarker) || !strings.Contains(body, "a pull request now covers this issue, so it is no longer open to new contributors") || !strings.Contains(body, "https://hive.example/contribute") { | ||
| t.Fatalf("comment %q", body) | ||
| } | ||
| if strings.Contains(body, "Sorry for the noise") || strings.Contains(body, "not open to new contributors —") { | ||
| t.Fatalf("covered note reuses the not-newcomer-work wording: %q", body) | ||
| } | ||
| if len(events) != 1 || events[0].Action != "withdraw" || events[0].Reason != SkipLinkedPR { | ||
| t.Fatalf("events %+v", events) | ||
| } | ||
|
|
||
| // The covered stage label alone withdraws the same way. | ||
| staged := good() | ||
| staged.Number = 1032 | ||
| staged.Labels = append([]string{Label}, "stage/040-covered-by-pr") | ||
| if res := s.Sweep(context.Background(), forge, []Candidate{staged}, opts); len(res.Withdrawn) != 1 { | ||
| t.Fatalf("stage/040: %+v", res) | ||
| } | ||
| if body := forge.comments[staged.Key()][0]; !strings.Contains(body, "a pull request now covers this issue") { | ||
| t.Fatalf("stage/040 comment %q", body) | ||
| } | ||
| } | ||
|
|
||
| // A relay contributor (or person) who claimed the issue and opened the PR is | ||
| // the outcome the label exists for: it stays until the issue closes. | ||
| func TestSweepLeavesClaimedCoveredIssueAlone(t *testing.T) { | ||
| forge := newFakeForge() | ||
| s := NewSweeper() | ||
| c := good() | ||
| c.Labels = append([]string{Label, HelpWantedLabel}, c.Labels...) | ||
| c.HasLinkedPR = true | ||
| c.ClaimedBy = "newcomer" | ||
| res := s.Sweep(context.Background(), forge, []Candidate{c}, quietOpts()) | ||
| if len(res.Withdrawn) != 0 || len(forge.removed[c.Key()]) != 0 || res.Skipped["claimed"] != 1 { | ||
| t.Fatalf("claimed covered issue withdrawn: %+v removed=%v", res, forge.removed[c.Key()]) | ||
| } | ||
| } | ||
|
|
||
| // An issue wearing a relay-skip label is never advertised; one already | ||
| // advertised that later gains it keeps the invite (triage flaps the label). | ||
| func TestSweepRelaySkipNeverSelectsNorWithdraws(t *testing.T) { | ||
| forge := newFakeForge() | ||
| s := NewSweeper() | ||
| opts := quietOpts() | ||
| opts.Policy.RelaySkip = relaySkipNeedsTriage | ||
|
|
||
| untriaged := good() | ||
| untriaged.Labels = append(untriaged.Labels, "needs-triage") | ||
| res := s.Sweep(context.Background(), forge, []Candidate{untriaged}, opts) | ||
| if len(res.Selected) != 0 || res.Skipped[SkipRelaySkip+":needs-triage"] != 1 || forge.commentCount(untriaged.Repo, untriaged.Number) != 0 { | ||
| t.Fatalf("untriaged issue advertised: %+v", res) | ||
| } | ||
|
|
||
| advertised := good() | ||
| advertised.Number = 1688 | ||
| advertised.Labels = append([]string{Label, HelpWantedLabel, "needs-triage"}, advertised.Labels...) | ||
| res = s.Sweep(context.Background(), forge, []Candidate{advertised}, opts) | ||
| if len(res.Withdrawn) != 0 || len(forge.removed[advertised.Key()]) != 0 { | ||
| t.Fatalf("relay-skip withdrew an advertised issue: %+v removed=%v", res, forge.removed[advertised.Key()]) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed &&/|| without parentheses. Suggest: