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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **The hive no longer adopts a contributor PR when a person's or the hive's own open PR already covers the issue.** On #18866 the hive adopted contributor PR #18870 as #18879 while the owner's #18873 for the same issue was open, and the dashboard then offered "Let hive decide" over two mid-CI PRs. Before adopting, the engine (the `AutoAdoption` executor) and the "Let hive decide" ladder (new rung `covered-by-other-pr`, just before the adopt rung) now look for another open PR on the same base branch that closes the same issue and is an owner's, an `author/human`'s, a collaborator's (not driving a clanker) or the hive's. If there is one the contributor PR is closed as a duplicate of it with a thank-you note that credits the contributor, the head records `covered-by-open-pr`, and the tracker row says why; a write-back gate refusal or failed close leaves it open with adoption still off. The hive's own copy of the PR, another contributor's PR, a PR on another release line and a duplicate the merge queue holds behind this one do not count, so "green first, then earlier-opened" only breaks ties between equal-trust PRs. With only a person's or hive agent's live claim on the issue (no PR yet) the ladder recommends leaving the PR open and names the holder. ([#18900](https://github.com/hivecommons/hive/issues/18900), part of [#18890](https://github.com/hivecommons/hive/issues/18890)).
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The plain-words comment the delegate posts has four lines — **Hive decided** (
| `capability-gap` | the GitHub App lacks a permission; deciding cannot clear it | The blocker is a missing GitHub App permission (for example `workflows`). Approving a direction would only re-apply needs-human, so the park stays until the owner grants the permission or a person applies the change. |
| `ci-ratchet` | a CI hygiene gate, landed as a ratchet | A new CI hygiene gate lands as a ratchet: it records today's baseline and fails only on increases, so existing work is never blocked. |
| `contributor-offline` | the author hasn't been reachable since the nudge | The PR's author (or their clanker or hive) has been offline since the hive nudged them, so the hive takes the work over instead of waiting. The decision itself names which: the author's clanker, a connected hive, or the author. |
| `covered-by-other-pr` | a person's or the hive's PR already covers the issue; closed as a duplicate, not adopted | Another open PR from a person or from the hive covers the same issue (or a person or the hive holds a live claim on it). Adoption takes over work a contributor abandoned, and this work is not abandoned, so the hive closes the contributor PR as a duplicate with a thank-you note and credit instead of opening a copy beside it. Green first, then earlier-opened only breaks ties between PRs of equal trust. |
| `dedupe` | an older issue already tracks this | An older issue already tracks the same work; one thread keeps it moving. |
| `proposal-approve-evidence` | a proposal backed by an incident or a repeated class; approved | The hive-filed proposal names an incident it would have prevented, or prior instances of the same class fixed one at a time, so its cost is justified and it is approved as proposed. |
| `proposal-not-now` | a hive-filed proposal with no incident or recurrence behind it; declined for now | The proposal shows neither an incident it would have prevented nor a repeated class it would end, so its value is speculative. The hive declines it for now and closes it as not planned; re-propose with evidence. |
Expand Down
19 changes: 19 additions & 0 deletions src/docs/labels-and-control-signals/stage-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,25 @@ When a contributor-agent PR goes red the hive does not just relabel it (a human-
(`contributor-offline`, supersede now) only fires for an author who is not
reachable, the same condition. This follows the documented rule that a
contributor who has gone quiet is superseded now (#13975).
**A contributor PR another open PR already covers is never adopted**
([#18900](https://github.com/hivecommons/hive/issues/18900), child of
#18890: the hive adopted #18870 as #18879 while the owner's #18873 for the
same issue was open). Before it adopts, the automatic path (`adoptContributorPR`,
the executor behind the `AutoAdoption` clock) and the ladder (rung 5a,
`covered-by-other-pr`, just before rung 5) look for another open PR, on the
same base branch, that closes an issue this PR closes and is a person's (an
owner or `author/human`, or an owner/member/collaborator not driving a
clanker) or the hive's. If there is one the contributor PR is closed as a
duplicate of it with one thank-you note that credits the contributor, and the
head records the block `covered-by-open-pr` (tracker row: "another open PR
already covers the issue"); a write-back gate refusal or a failed close
leaves the PR open with adoption still off. The hive's own copy of this PR
(`Supersedes #N`), a PR on another release line, another contributor's PR and
a duplicate the merge queue holds behind this one do not count: "green first,
then earlier-opened" only breaks ties between PRs of equal trust. With no
competing PR but a live claim by a person or a hive agent on the issue, the
ladder recommends leaving the PR open and names the holder, and the engine
refuses adoption (`human-claim`, see [maintainer commands](../maintainer-commands.md#claiming-an-issue)).
2. Relay contributors (the author has a contributor profile and a live relay
connection) also receive the diagnosis in their relay session as a
`fix-pr` task with `priority: interrupt`. Presence = a relay heartbeat
Expand Down
6 changes: 6 additions & 0 deletions src/pkg/claims/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@ const ReasonLeaseExpired = "lease expired"
// HumanClaimReason: "human claim: assigned by andy".
const ReasonHumanClaim = "human claim"

// ReasonHiveClaim prefixes the reason for a live ledger claim by one of the
// hive's own agents: "hive claim: scanner". Adoption does not open a copy
// beside work the hive already holds (hivecommons/hive#18900). It is not a
// HumanClaimReason, so it never triggers the contributor yank.
const ReasonHiveClaim = "hive claim"

const humanClaimBy = " by "

// HumanClaimReason renders the admission/release reason for a person's claim
Expand Down
69 changes: 66 additions & 3 deletions src/pkg/dashboard/delegated_pr_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

gh "github.com/google/go-github/v72/github"
"github.com/hivecommons/hive/pkg/claims"
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/delegatedecision"
"github.com/hivecommons/hive/pkg/github"
Expand Down Expand Up @@ -125,16 +126,61 @@ func (s *Server) gatherDelegatedPRContext(ctx context.Context, repo string, pr *
winner, _ := delegatedTrainDuplicate(s.stageStoreOrShared(), repo, number)
in.Competing = append(in.Competing, delegatedecision.CompetingPR{
Number: number, HiveAuthored: s.deps.GHClient.IsHiveAuthorLogin(other.GetUser().GetLogin()),
Mergeable: mergeable,
Current: state != "behind" && state != "unknown" && state != "" && !other.GetDraft(),
HeldDuplicate: winner == pr.GetNumber(),
PersonAuthored: s.delegatedPersonAuthoredCompetitor(other),
Mergeable: mergeable,
Current: state != "behind" && state != "unknown" && state != "" && !other.GetDraft(),
HeldDuplicate: winner == pr.GetNumber(),
})
}
in.IssueClaimHolder, in.IssueClaimIssue = s.delegatedIssueClaimHolder(repo, pr)
in.TrainDuplicateOf, in.TrainDuplicateIssue = delegatedTrainDuplicate(s.stageStoreOrShared(), repo, pr.GetNumber())
in.ClaimConflictWith, in.ClaimConflictIssue = delegatedClaimConflict(s.stageStoreOrShared(), repo, pr.GetNumber())
return nil
}

// delegatedPersonAuthoredCompetitor reports whether a competing PR was
// pushed by a person: author/human, one of this hive's owners, or an
// owner/member/collaborator who is not driving a clanker (a contributor
// relay's PR is a clanker's whoever its login is). The ladder lets only a
// person's or the hive's competitor cover a contributor PR's issue
// (hivecommons/hive#18900).
func (s *Server) delegatedPersonAuthoredCompetitor(other *gh.PullRequest) bool {
var labels []string
for _, l := range other.Labels {
labels = append(labels, l.GetName())
}
if s.delegatedHumanAuthor(labels) || s.isAuthorizedUserLogin(other.GetUser().GetLogin()) {
return true
}
if s.delegatedClankerAuthor(labels) {
return false
}
switch strings.ToUpper(other.GetAuthorAssociation()) {
case "OWNER", "MEMBER", "COLLABORATOR":
return true
}
return false
}

// delegatedIssueClaimHolder names the person or hive agent holding a live
// claim in the issue ledger on an issue pr closes, with that issue; "" when
// none. Contributor and external claims are not a person's or the hive's.
func (s *Server) delegatedIssueClaimHolder(repo string, pr *gh.PullRequest) (string, int) {
l := s.claimsLedger()
if l == nil {
return "", 0
}
for _, ref := range github.ParseClaimedIssues(pr.GetTitle()+"\n"+pr.GetBody(), repo) {
if ref.Issue <= 0 || (ref.Repo != "" && !strings.EqualFold(ref.Repo, repo)) {
continue
}
if c, ok := l.Lookup(repo, ref.Issue); ok && (c.Kind == claims.KindHuman || c.Kind == claims.KindAgent) {
return c.Holder, ref.Issue
}
}
return "", 0
}

// delegatedClaimConflict reads the stage store for the cross-lane
// same-issue hold the merge queue recorded on a PR
// (hivecommons/hive#15810): the other claimant and the shared issue, 0
Expand Down Expand Up @@ -205,6 +251,23 @@ func (s *Server) delegatedHumanAuthor(labels []string) bool {
return isHuman
}

// delegatedClankerAuthor: the labels carry the configured author/clanker
// label, i.e. a contributor relay drove the PR.
func (s *Server) delegatedClankerAuthor(labels []string) bool {
clanker := authorKindLabelPfx + authorKindClanker
if s != nil && s.deps != nil && s.deps.Config != nil {
if c := strings.TrimSpace(s.deps.Config.Governor.Labels.Author.Clanker); c != "" {
clanker = c
}
}
for _, l := range labels {
if strings.EqualFold(strings.TrimSpace(l), clanker) {
return true
}
}
return false
}

// isAuthorizedUserLogin: login is one of this hive's dashboard.authorized_users.
func (s *Server) isAuthorizedUserLogin(login string) bool {
login = strings.TrimSpace(strings.TrimPrefix(login, "@"))
Expand Down
2 changes: 2 additions & 0 deletions src/pkg/dashboard/stage_tracker_adoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ func stageTrackerAdoptionText(author string, a StageTrackerAdoption, now time.Ti
text += " — maintainer-owned: automatic adoption is disabled by maintainer_policy=never"
case a.BlockedBy == stagelabels.AdoptBlockedOperatorAdmission:
text += " — contributor-managed: operator approval recorded for this head; existing review/CI requirements still apply"
case a.BlockedBy == stagelabels.AdoptBlockedCoveredByOpenPR:
text += " — another open PR (a person's or the hive's) already covers the issue: the hive will not adopt this one"
case a.BlockedBy == stagelabels.AdoptBlockedHumanClaim:
text += " — an owner or maintainer has claimed the issue: the hive will not adopt this PR unless they release the claim"
case a.BlockedBy != "":
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/static-src/js/tracker-filter-fetch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25014,6 +25014,7 @@ <h2 class="config-title" id="activity-monitor-labels-title">All labels</h2>
"contributor-lane:sentinel-blocked": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."},
"contributor-lane:workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."},
"contributor-offline": {"kind": "rule", "plain": "the author hasn't been reachable since the nudge", "detail": "The PR's author (or their clanker or hive) has been offline since the hive nudged them, so the hive takes the work over instead of waiting. The decision itself names which: the author's clanker, a connected hive, or the author."},
"covered-by-other-pr": {"kind": "rule", "plain": "a person's or the hive's PR already covers the issue; closed as a duplicate, not adopted", "detail": "Another open PR from a person or from the hive covers the same issue (or a person or the hive holds a live claim on it). Adoption takes over work a contributor abandoned, and this work is not abandoned, so the hive closes the contributor PR as a duplicate with a thank-you note and credit instead of opening a copy beside it. Green first, then earlier-opened only breaks ties between PRs of equal trust."},
"dco": {"kind": "reason", "plain": "a commit is missing its sign-off", "detail": "A commit on the branch is missing its Developer Certificate of Origin sign-off; the author must sign it off."},
"dco-missing": {"kind": "reason", "plain": "a commit is missing its sign-off", "detail": "A commit on the branch is missing its Developer Certificate of Origin sign-off; the author must sign it off."},
"dedupe": {"kind": "rule", "plain": "an older issue already tracks this", "detail": "An older issue already tracks the same work; one thread keeps it moving."},
Expand Down
2 changes: 2 additions & 0 deletions src/pkg/delegatedecision/decision_glossary.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ var glossary = []GlossaryEntry{
// Rules — why the delegate chose what it chose.
{Slug: RuleContributorOffline, Kind: GlossaryRule, Plain: "the author hasn't been reachable since the nudge",
Detail: "The PR's author (or their clanker or hive) has been offline since the hive nudged them, so the hive takes the work over instead of waiting. The decision itself names which: the author's clanker, a connected hive, or the author."},
{Slug: RuleCoveredByOtherPR, Kind: GlossaryRule, Plain: "a person's or the hive's PR already covers the issue; closed as a duplicate, not adopted",
Detail: "Another open PR from a person or from the hive covers the same issue (or a person or the hive holds a live claim on it). Adoption takes over work a contributor abandoned, and this work is not abandoned, so the hive closes the contributor PR as a duplicate with a thank-you note and credit instead of opening a copy beside it. Green first, then earlier-opened only breaks ties between PRs of equal trust."},
{Slug: RuleAlreadyFixed, Kind: GlossaryRule, Plain: "the issue was already fixed by a merged PR; closed as superseded",
Detail: "The issue this PR fixes is already closed and a merged PR closed it (or a merged PR declares it supersedes this one), so nothing is left to deliver. The hive closes the PR as superseded with a note naming the merging PR; it never adopts it."},
{Slug: RuleMergeableAsIs, Kind: GlossaryRule, Plain: "mergeable and green as it is; handed to the merge queue",
Expand Down
Loading
Loading