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
1 change: 1 addition & 0 deletions changelog.d/fixed-admit-filter-refused-issues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Issues that the issue filter (`project.issue_filter.require_labels`) keeps off every agent queue now reach the inbox as `ADMIT` when someone has to let them in. That covers an issue carrying `approved-direction`: `/hive decision` and `/hive approve` apply that label, not the filter's. It also covers an agent's finding where agents self-authorize and no `TRIAGE` row applies (by default at L6), and an undecided issue a person filed. The reason names the labels that admit the issue. Before, on projectbluefin, testsuite#1091, server#622, dakota-iso#294 and others got an un-park reply saying "still outside the agent queue", while sitting in band "outside" with no verb. Agent findings such as testsuite#1085 and documentation#1630 had no inbox row either.
9 changes: 8 additions & 1 deletion src/docs/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ so the reason text can change without breaking them.
| `parked_needs_decision` | `DECIDE` |
| `parked_needs_spec` | `SPEC` |
| `untrusted_reporter` | `ADMIT` |
| `decided_not_admitted`, `agent_finding_not_admitted`, `person_issue_not_admitted` | `ADMIT` |
| `reporter_confirmation_stale` | `CLOSE` |
| `verified_done` | `CLOSE` |
| `agent_filed_unacknowledged` | `TRIAGE` |
Expand Down Expand Up @@ -762,6 +763,9 @@ means the situation cannot occur at that level.
| Unclaimed issue filed by a person | Not yours — backlog | Not yours — backlog, or a lane will act | Not yours — a lane will act | same |
| Issue filed by an agent, not yet acknowledged, while the self-authorization hold is active (by default below L6) | — (no agent files issues) | Yours — `TRIAGE` | Yours — `TRIAGE` | Not yours by default (agents self-authorize); Yours — `TRIAGE` when the hold is configured on |
| Issue from an untrusted reporter awaiting an admission label | Yours — `ADMIT` | same | same | same |
| Issue the issue filter (`project.issue_filter.require_labels`) refuses that carries `approved-direction` (a `/hive decision` or `/hive approve` applies it, not the filter's label) | Yours — `ADMIT` (`decided_not_admitted`; the reason names the labels that admit it) | same | same | same |
| Agent-filed issue the issue filter refuses, where the TRIAGE row above does not apply (agents self-authorize, by default at L6) | — (no agent files issues) | — (TRIAGE applies) | — (TRIAGE applies) | Yours — `ADMIT` (`agent_finding_not_admitted`: admit it, or close it if it no longer applies) |
| Person-filed issue the issue filter refuses, undecided (only the missing `require_labels` keeps it out: holds, exempt, tracking, `blocked`, parks, reporter confirmation, reporter triage and standing dashboards are decided before the filter and keep their own rows; a bot's issue stays Not yours) | Yours — `ADMIT` (`person_issue_not_admitted`: admit it so the hive works it, or close it) | same | same | same |
| Parked: `needs-decision` / `needs-direction` / `needs-human` | Yours — `DECIDE` / `STEER` / `REVIEW` | same | same | same — no lane ever takes a parked issue |
| Parked: `needs-spec` | Yours — `SPEC` | same | same | same |
| Agent PR held by the level gate (decided from the hold's recorded source, not from the repository's level) | — (no agent opens PRs) | Yours — `REVIEW` | Yours — `REVIEW` | A level hold placed before the level was raised stays until released: Yours — `REVIEW`. Outreach-lane PRs keep their hold: Yours — `REVIEW` |
Expand Down Expand Up @@ -802,7 +806,10 @@ admission → `ADMIT`; (7) awaiting reporter confirmation → Not yours until it
has had no activity for the stale period, then `CLOSE`
(`reporter_confirmation_stale`); (8) verified done but not closed → `CLOSE`;
(9) agent-filed and unacknowledged where acknowledgment is required →
`TRIAGE`; (10) for a pull request with a hold, the hold sources decide and no
`TRIAGE`; (9b) an issue the issue filter refuses that carries
`approved-direction` → `ADMIT` (`decided_not_admitted`), that an agent filed
→ `ADMIT` (`agent_finding_not_admitted`), or that a person filed → `ADMIT`
(`person_issue_not_admitted`); (10) for a pull request with a hold, the hold sources decide and no
later row applies; for any other pull request, the PR rows of the table; (11)
otherwise Not yours. The safety net then applies
only to items that came out Not yours. Last, the gate rules apply to items
Expand Down
55 changes: 55 additions & 0 deletions src/pkg/dashboard/ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ const (
OwnershipReasonPersonPRNeedsHuman = "person_pr_needs_human"
OwnershipReasonReviewRequiresHuman = "review_requires_human"
OwnershipReasonStaleSafetyNet = "stale_safety_net"
// The issue filter (project.issue_filter.require_labels) keeps these off
// every agent queue, so only a maintainer adding a required label lets
// them move: a decided issue, and an agent's finding where agents
// self-authorize (no TRIAGE row covers it).
OwnershipReasonDecidedNotAdmitted = "decided_not_admitted"
OwnershipReasonAgentFindingNotAdmitted = "agent_finding_not_admitted"
OwnershipReasonPersonIssueNotAdmitted = "person_issue_not_admitted"
)

// ownershipReasonVerbs is the fixed reason-code set with the one verb each
Expand Down Expand Up @@ -103,6 +110,9 @@ var ownershipReasonVerbs = map[string]string{
OwnershipReasonPersonPRNeedsHuman: OwnershipVerbReview,
OwnershipReasonReviewRequiresHuman: OwnershipVerbReview,
OwnershipReasonStaleSafetyNet: OwnershipVerbReview,
OwnershipReasonDecidedNotAdmitted: OwnershipVerbAdmit,
OwnershipReasonAgentFindingNotAdmitted: OwnershipVerbAdmit,
OwnershipReasonPersonIssueNotAdmitted: OwnershipVerbAdmit,
}

// OwnershipActionReleaseHold is the dashboard's existing release-hold action.
Expand Down Expand Up @@ -282,6 +292,9 @@ type ownershipEnv struct {
// author in repo (automerge.Engine.MergeLaneTakesAuthor); nil turns the
// hand-merge rule off.
mergeLaneTakesAuthor func(repo, author string) bool
// admitLabels are project.issue_filter.require_labels: the labels that
// let an issue the filter refuses onto the agent queues.
admitLabels []string
}

func (e ownershipEnv) laneCanOpenPRFor(lane, repo string) bool {
Expand All @@ -308,6 +321,20 @@ func (e ownershipEnv) selfAuthorizationHoldFor(repo string) bool {
return e.selfAuthorizationHold(repo)
}

// admitPhrase names what admits an issue the filter refuses.
func (e ownershipEnv) admitPhrase() string {
var named []string
for _, l := range e.admitLabels {
if l = strings.TrimSpace(l); l != "" {
named = append(named, "`"+l+"`")
}
}
if len(named) == 0 {
return "add an admission label to admit it"
}
return "add " + strings.Join(named, " or ") + " to admit it"
}

func (e ownershipEnv) releaseOnApproveFor(repo string) bool {
return e.releaseOnApprove != nil && e.releaseOnApprove(repo)
}
Expand Down Expand Up @@ -482,6 +509,9 @@ type issueOwnershipInput struct {
number int
labels []string
acknowledged bool
// authorIsHuman is the enumeration's reporter classification
// (RepoWorkIssue.AuthorIsHuman) for a non-actionable row.
authorIsHuman bool
// openLinkedPR is set when the issue has an open (unmerged) linked PR or
// open PR claim context.
openLinkedPR bool
Expand Down Expand Up @@ -608,6 +638,29 @@ func decideIssueOwnership(in issueOwnershipInput, env ownershipEnv) Ownership {
if role := issueAgentRole(in.labels); role != "" && !in.acknowledged && !labels[ownershipLabelApprovedDirection] && env.selfAuthorizationHoldFor(in.repo) {
return yourTurn(OwnershipReasonAgentFiledUnacknowledged, "Filed by agent "+role+" — acknowledge it or close it")
}
// (9b) refused by the issue filter: no lane will ever see it, so a
// decided issue (`/hive decision` and `/hive approve` apply
// approved-direction, not the filter's label), an agent's finding or a
// person's issue waits on a maintainer admitting it. Only the filter's
// own refusal counts: holds, exempt, tracking, blocked, park and
// reporter-confirmation rows and standing dashboards carry other
// buckets or reasons (client.go fetchIssues decides those first). projectbluefin/testsuite#1091 was
// approved at 20:31Z on 11-05; the un-park reply said "still outside the
// agent queue", and no inbox listed it.
if in.bucket == repoWorkBucketFiltered && in.bucketReason == github.IssueFilterReason {
if labels[ownershipLabelApprovedDirection] {
return yourTurn(OwnershipReasonDecidedNotAdmitted, "Decided, but the issue filter keeps it off the agent queue — "+env.admitPhrase())
}
if role := issueAgentRole(in.labels); role != "" {
return yourTurn(OwnershipReasonAgentFindingNotAdmitted, "Filed by agent "+role+"; the issue filter keeps it off the agent queue — "+env.admitPhrase()+", or close it if it no longer applies")
}
// A person's issue nobody has decided: the filter only ever lets it
// in by a maintainer's label. A bot's (not a standing dashboard,
// which never reaches this bucket) stays outside.
if in.authorIsHuman {
return yourTurn(OwnershipReasonPersonIssueNotAdmitted, "A person filed this; the issue filter keeps it off the agent queue — "+env.admitPhrase()+" so the hive works it, or close it")
}
}
// (11) otherwise not your turn; the safety net may still apply.
if issueSafetyNetCovers(in, labels, env) && env.stale(in.createdAt, in.updatedAt) {
return safetyNetOwnership(env.untouchedDays(in.createdAt, in.updatedAt))
Expand Down Expand Up @@ -911,6 +964,7 @@ func decideRepoOwnership(repos []FrontendRepo, cfg config.DashboardIssueBandsCon
createdAt: item.CreatedAt,
updatedAt: item.UpdatedAt,
reporterGate: item.ReporterConfirmationGate,
authorIsHuman: item.AuthorIsHuman,
bucket: item.Bucket,
bucketReason: item.Reason,
decisionBlocker: decisionBlockerFor(nonEmpty(item.Repo, repoName)+"#"+strconv.Itoa(item.Number), item.OpenBlockers, decisionParks, repoName),
Expand Down Expand Up @@ -1012,6 +1066,7 @@ func newOwnershipEnv(cfg *config.Config, agentStatuses map[string]*crux.Process,
}
env.unparkCommandsRefused = func(repo string) bool { return labelDrivenRefusesUnparkCommands(cfg, repo) }
env.releaseOnApprove = cfg.RepoReleaseOnApprove
env.admitLabels = cfg.Project.IssueFilter.RequireLabelsForNotice()
env.laneCanOpenPR = laneCanOpenPRAt(env, agentStatuses)
return env
}
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/dashboard/ownership_11565_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ func TestOwnershipSafetyNet11565(t *testing.T) {
}

func TestOwnershipFixedSets11565(t *testing.T) {
if len(ownershipReasonVerbs) != 32+len(operatorWaitReasonVerbs) {
t.Fatalf("reason codes = %d, want the 20 of #11507, review_requires_human (#12329), blocked_unexplained (#12376), the three review-hold codes of #12377, the three PR gates of #12378, superseded_recommended_close (#13114), superseded_extra_files_review (#14176), adjudicator_handed_off (#13183), adopted_push_refused and the run and approval waits (#12380)", len(ownershipReasonVerbs))
if len(ownershipReasonVerbs) != 35+len(operatorWaitReasonVerbs) {
t.Fatalf("reason codes = %d, want the 20 of #11507, review_requires_human (#12329), blocked_unexplained (#12376), the three review-hold codes of #12377, the three PR gates of #12378, superseded_recommended_close (#13114), superseded_extra_files_review (#14176), adjudicator_handed_off (#13183), adopted_push_refused, the three issue-filter ADMIT codes and the run and approval waits (#12380)", len(ownershipReasonVerbs))
}
verbs := map[string]bool{}
for _, verb := range ownershipVerbOrder {
Expand Down
129 changes: 129 additions & 0 deletions src/pkg/dashboard/ownership_issue_filter_admit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package dashboard

import (
"strings"
"testing"
"time"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/github"
)

// The issue filter (project.issue_filter.require_labels) keeps an issue off
// every agent queue until a maintainer adds a required label. On
// projectbluefin (L6) the un-park replies of 11-05 20:19-20:37Z said "still
// outside the agent queue … A maintainer adding it admits this one" on
// testsuite#1091, server#622, dakota-iso#294 and others, and the agent
// findings testsuite#1085/#1090/#1094 and documentation#1630 had no TRIAGE
// row at L6: all sat in band "outside" with no verb and no inbox row.
func filterRefused(labels ...string) issueOwnershipInput {
return nonActionable11565(repoWorkBucketFiltered, github.IssueFilterReason, labels...)
}

func personRefused(labels ...string) issueOwnershipInput {
in := filterRefused(labels...)
in.authorIsHuman = true
return in
}

func TestIssueFilterRefusedDecidedAndAgentFindingsAreAdmit(t *testing.T) {
l6 := ownershipEnv11565(6)
l6.selfAuthorizationHold = func(string) bool { return false }
l6.admitLabels = []string{"triage/accepted"}
l5 := ownershipEnv11565(5)
l5.selfAuthorizationHold = func(string) bool { return true }
l5.admitLabels = []string{"triage/accepted"}

decided := want11565{OwnershipVerbAdmit, OwnershipReasonDecidedNotAdmitted}
finding := want11565{OwnershipVerbAdmit, OwnershipReasonAgentFindingNotAdmitted}
person := want11565{OwnershipVerbAdmit, OwnershipReasonPersonIssueNotAdmitted}
for _, tc := range []struct {
name string
env ownershipEnv
in issueOwnershipInput
want want11565
}{
{"testsuite#1091: agent finding, /hive decision applied approved-direction", l6, filterRefused("security", "agent/sec-check", "approved-direction", "hive/workflows-lane"), decided},
{"server#622: needs-triage too", l6, filterRefused("agent/ci-maintainer", "needs-kind", "needs-triage", "approved-direction", "ci", "hive/workflows-lane"), decided},
{"utah-packages#882: a lapsed claim label does not hide it", l6, filterRefused("security", "agent/sec-check", "hive/claimed-by-sec-check", "approved-direction"), decided},
{"a person's decided issue", l6, filterRefused("kind/feature", "approved-direction"), decided},
{"decided at L5 too", l5, filterRefused("agent/quality", "approved-direction"), decided},
{"testsuite#1085: reviewer finding at L6", l6, filterRefused("agent/reviewer"), finding},
{"testsuite#1100: quality finding at L6", l6, filterRefused("testing", "agent/quality"), finding},
{"agent finding at L5 stays TRIAGE", l5, filterRefused("agent/reviewer"), want11565{OwnershipVerbTriage, OwnershipReasonAgentFiledUnacknowledged}},
{"a person's undecided issue", l6, personRefused("kind/bug"), person},
{"a person's undecided issue at L5", l5, personRefused(), person},
{"a person's decided issue is decided", l6, personRefused("approved-direction"), decided},
{"a bot's issue (not a dashboard) stays outside", l6, filterRefused("dependencies"), notYours11565},
{"a person's issue held by a park keeps the park", l6, func() issueOwnershipInput {
in := nonActionable11565(repoWorkBucketFiltered, config.DefaultNeedsSpecLabel, "needs-spec")
in.authorIsHuman = true
return in
}(), want11565{OwnershipVerbSpec, OwnershipReasonParkedNeedsSpec}},
{"a person's exempt issue stays outside", l6, func() issueOwnershipInput {
in := nonActionable11565(repoWorkBucketFiltered, "Exempt label", "wontfix")
in.authorIsHuman = true
return in
}(), notYours11565},
{"a person's issue under reporter triage stays untrusted_reporter", l6, func() issueOwnershipInput {
in := nonActionable11565(repoWorkBucketReporterTriage, "", "kind/bug")
in.authorIsHuman = true
return in
}(), want11565{OwnershipVerbAdmit, OwnershipReasonUntrustedReporter}},
{"a decision park keeps DECIDE", l6, nonActionable11565(repoWorkBucketFiltered, config.DefaultNeedsDecisionLabel, "approved-direction", "stage/045-needs-decision"), want11565{OwnershipVerbDecide, OwnershipReasonParkedNeedsDecision}},
{"filtered for another reason is not the filter's", l6, nonActionable11565(repoWorkBucketFiltered, "epic", "approved-direction", "epic"), notYours11565},
{"an admitted decided issue is not ADMIT", l6, freshIssue11565("approved-direction", "triage/accepted"), notYours11565},
} {
t.Run(tc.name, func(t *testing.T) {
checkOwnership11565(t, decideIssueOwnership(tc.in, tc.env), tc.want)
})
}

got := decideIssueOwnership(filterRefused("agent/sec-check", "approved-direction"), l6)
if !strings.Contains(got.Reason, "`triage/accepted`") {
t.Fatalf("reason %q must name the label that admits it", got.Reason)
}
l6.admitLabels = []string{"triage/accepted", "hive-ok"}
if got := decideIssueOwnership(filterRefused("agent/reviewer"), l6); !strings.Contains(got.Reason, "add `triage/accepted` or `hive-ok` to admit it, or close it") {
t.Fatalf("reason %q must name every admitting label and offer closing", got.Reason)
}
if got := decideIssueOwnership(personRefused(), l6); !strings.Contains(got.Reason, "A person filed this") || !strings.Contains(got.Reason, "so the hive works it, or close it") {
t.Fatalf("person reason %q", got.Reason)
}
l6.admitLabels = nil
if got := decideIssueOwnership(filterRefused("approved-direction"), l6); !strings.Contains(got.Reason, "add an admission label") {
t.Fatalf("reason %q without configured labels", got.Reason)
}
}

// End to end from the enumeration rows the dashboard stores, with the labels
// read from configuration: the rows are in the inbox as ADMIT.
func TestRepoOwnershipAdmitsFilterRefusedRows(t *testing.T) {
now := ownershipNow11565
row := func(n int, labels ...string) github.RepoWorkIssue {
return github.RepoWorkIssue{Repo: "projectbluefin/testsuite", Number: n, Labels: labels,
Bucket: repoWorkBucketFiltered, Reason: github.IssueFilterReason,
CreatedAt: now.Add(-24 * time.Hour), UpdatedAt: now.Add(-time.Hour)}
}
human := func(r github.RepoWorkIssue) github.RepoWorkIssue { r.AuthorIsHuman = true; return r }
cfg := &config.Config{}
cfg.Project.IssueFilter.RequireLabels = []string{"triage/accepted"}
env := newOwnershipEnv(cfg, nil, "", now, nil)
env.selfAuthorizationHold = func(string) bool { return false }
repos := []FrontendRepo{{Name: "testsuite", Full: "projectbluefin/testsuite", NonActionableIssues: []any{
row(1091, "security", "agent/sec-check", "approved-direction"),
row(1085, "agent/reviewer"),
human(row(1087)),
row(1200, "dependencies"),
}}}
decideRepoOwnership(repos, config.DashboardIssueBandsConfig{}, env)
for n, code := range map[int]string{1091: OwnershipReasonDecidedNotAdmitted, 1085: OwnershipReasonAgentFindingNotAdmitted, 1087: OwnershipReasonPersonIssueNotAdmitted} {
d := ownershipFor(repos[0].Ownership, ownershipKindIssue, n)
if d == nil || !d.YourTurn || d.Verb != OwnershipVerbAdmit || d.ReasonCode != code || !strings.Contains(d.Reason, "`triage/accepted`") {
t.Errorf("#%d = %+v, want ADMIT %s naming triage/accepted", n, d, code)
}
}
if d := ownershipFor(repos[0].Ownership, ownershipKindIssue, 1200); d != nil && d.YourTurn {
t.Errorf("#1200 (a bot's, undecided) = %+v, want not your turn", d)
}
}
4 changes: 3 additions & 1 deletion src/pkg/dashboard/static-src/js/label-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
if (own.verb === 'TRIAGE') {
after.push({ type: 'note', text: 'Adding the approved-direction label, assigning a person, or closing it acknowledges it.' });
}
if (own.verb === 'ADMIT') {
// The issue-filter ADMIT rows name the filter's own labels in the
// reason; admissionLabels are reporter trust's.
if (own.verb === 'ADMIT' && own.reason_code === 'untrusted_reporter') {
const labels = (ctx.admissionLabels || []).filter(Boolean);
after.push({ type: 'note', text: labels.length ? 'Add the label ' + labels.join(' or ') + ' to admit it.' : 'Add an admission label to admit it.' });
}
Expand Down
4 changes: 3 additions & 1 deletion src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34876,7 +34876,9 @@ <h4 style="margin:14px 0 6px">Approval and audit records</h4>${approval}`;
if (own.verb === 'TRIAGE') {
after.push({ type: 'note', text: 'Adding the approved-direction label, assigning a person, or closing it acknowledges it.' });
}
if (own.verb === 'ADMIT') {
// The issue-filter ADMIT rows name the filter's own labels in the
// reason; admissionLabels are reporter trust's.
if (own.verb === 'ADMIT' && own.reason_code === 'untrusted_reporter') {
const labels = (ctx.admissionLabels || []).filter(Boolean);
after.push({ type: 'note', text: labels.length ? 'Add the label ' + labels.join(' or ') + ' to admit it.' : 'Add an admission label to admit it.' });
}
Expand Down
Loading
Loading