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/added-close-stale-agent-findings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- An agent finding that the issue filter keeps off the queues is now `CLOSE` when every permalink it cites is gone from the default branch (`cited_lines_gone`), instead of waiting to be admitted or triaged. The enumeration reads the cited lines at the pinned commit and the same file on the default branch. It checks at most 3 findings per repository per pass, trusts a result for 6 hours, and treats a read failure as unknown. A file that is gone from the default branch counts as unknown too, because a rename keeps the lines. projectbluefin/testsuite#1085, for example, cited `SKILL.md:163` for a fallback the guide no longer described.
4 changes: 4 additions & 0 deletions src/docs/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ so the reason text can change without breaking them.
| `decided_not_admitted`, `agent_finding_not_admitted`, `person_issue_not_admitted` | `ADMIT` |
| `reporter_confirmation_stale` | `CLOSE` |
| `verified_done` | `CLOSE` |
| `cited_lines_gone` | `CLOSE` |
| `agent_filed_unacknowledged` | `TRIAGE` |
| `level_gate_hold`, `outreach_hold`, `policy_hold`, `hold_source_unknown` | `REVIEW` |
| `hive_pr_needs_human` (L3–L4) | `REVIEW` |
Expand Down Expand Up @@ -797,6 +798,7 @@ means the situation cannot occur at that level.
| PR of any author that `/api/review/pipeline` holds in `human_hold` for a review-swarm reason: a `requires_human` verdict (`review_requires_human`; one on an earlier head counts until a merge-eligible `approve` is recorded after it), a `reject` verdict (`review_rejected`) — either one released once a person's `APPROVED` review or `/hive approve` reply after the verdict has been recorded by the self-merge sweep, the release the sweep itself honours ([review-swarm.md](review-swarm.md)), a dispatch hold on the current head — reviews exhausted their retries, fix cap reached, no fixer agent (`review_dispatch_hold`; a hold on an older head does not count) — or the fix-cycle cap (`review_loop_cap`). `review.human_decision_label` does not change the decision. Once a person has answered the `requires_human` / `reject` verdict on the current head with an instruction (`/hive decision <instruction>` or a `CHANGES_REQUESTED` review, recorded after the verdict) the row is Not yours — "@who answered Hive's review on this head …; the hive is fixing it" — until a new head or a newer verdict, except on a PR the hive adopted whose branch it cannot push (fork-rehome-refused on the head, a fork without maintainer edits, an adoption escalated for a workflow-file diff, or a recorded capability blocker), which stays Yours — `DECIDE` (`adopted_push_refused`, naming why); a dispatch hold or the loop cap stays `REVIEW`, and a bare approval is left to the release rules above | Yours — `REVIEW` | same | Yours — `REVIEW`; a Hive PR that also carries `needs-human` waits for the adjudicator first, as in the row above | same |
| Sentinel-flagged PR | Yours — `INSPECT` | same | same | same |
| Issue Hive verified as done but could not close | Yours — `CLOSE` | same | same | same |
| Agent finding the issue filter refuses whose every cited permalink (`…/blob/<sha>/<path>#L<n>`, same repository) is gone from the default branch: none of the cited lines of 16 to 400 characters is still a line of the file. A file the default branch no longer has is not enough (a rename or move keeps the lines), nor is a citation with no such line or a path the pinned commit lacks. The enumeration checks it for up to 3 findings per repository per pass and trusts a result for 6 hours; the evidence lines read at a pinned SHA are kept (never the file), and a citation that settles as unknown costs no further reads | Yours — `CLOSE` (`cited_lines_gone`, naming the citation: close it, or admit it if the finding still holds) | same | same | same |
| Issue covered by an open PR | Not yours — the PR closes it on merge | same | same | same |
| Issue parked on a decision (`needs_decision`) that an open or held PR authored by this hive's App closes (GitHub closing reference) | Not yours — "Waits on hive PR #N, which closes it"; the park label stays, so the ask comes back if the PR closes unmerged. A closing PR by anyone else leaves it `DECIDE` | same | same | same |
| `blocked` with an open GitHub blocked-by link | Not yours — waiting on the linked item | same | same | same |
Expand All @@ -822,6 +824,8 @@ open hive-authored PR closes is Not yours; (6) untrusted reporter awaiting
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`;
(8b) an agent finding whose cited lines are gone from the default branch →
`CLOSE` (`cited_lines_gone`);
(9) agent-filed and unacknowledged where acknowledgment is required →
`TRIAGE`; (9b) an issue the issue filter refuses that carries
`approved-direction` → `ADMIT` (`decided_not_admitted`), that an agent filed
Expand Down
2 changes: 1 addition & 1 deletion src/docs/scale-envelope.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ones to:
2. **Truncation must preserve the prioritization signal, not cut an arbitrary slice.**
This holds today and is easy to assume backwards:
- Issues are sorted by actionable rank tier, then **oldest first** within each tier before any cap is applied
(`RankActionableIssues`, `src/pkg/github/client.go:5350-5360`, descending `AgeMinutes` within each tier).
(`RankActionableIssues`, `src/pkg/github/client.go:5361-5371`, descending `AgeMinutes` within each tier).
- PRs are sorted by **review class then oldest-first within class**
(`SortPullRequestsForReview`, `src/pkg/github/review_priority.go:334`;
fixes → refactors/docs → tests).
Expand Down
16 changes: 16 additions & 0 deletions src/pkg/dashboard/ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ const (
OwnershipReasonDecidedNotAdmitted = "decided_not_admitted"
OwnershipReasonAgentFindingNotAdmitted = "agent_finding_not_admitted"
OwnershipReasonPersonIssueNotAdmitted = "person_issue_not_admitted"
// OwnershipReasonCitedLinesGone: an agent finding the issue filter
// refuses whose cited lines are gone from the default branch
// (RepoWorkIssue.CitedLinesGone).
OwnershipReasonCitedLinesGone = "cited_lines_gone"
)

// ownershipReasonVerbs is the fixed reason-code set with the one verb each
Expand Down Expand Up @@ -113,6 +117,7 @@ var ownershipReasonVerbs = map[string]string{
OwnershipReasonDecidedNotAdmitted: OwnershipVerbAdmit,
OwnershipReasonAgentFindingNotAdmitted: OwnershipVerbAdmit,
OwnershipReasonPersonIssueNotAdmitted: OwnershipVerbAdmit,
OwnershipReasonCitedLinesGone: OwnershipVerbClose,
}

// OwnershipActionReleaseHold is the dashboard's existing release-hold action.
Expand Down Expand Up @@ -529,6 +534,10 @@ type issueOwnershipInput struct {
createdAt time.Time
updatedAt time.Time

// citedLinesGone is RepoWorkIssue.CitedLinesGone for a non-actionable
// row.
citedLinesGone string

// lane is the lane the classifier routed the issue to.
lane string
// liveClaim is true while the issue carries an unexpired ClaimedBy claim.
Expand Down Expand Up @@ -634,6 +643,12 @@ func decideIssueOwnership(in issueOwnershipInput, env ownershipEnv) Ownership {
if ownershipVerifiedDone(in, labels, env) {
return yourTurn(OwnershipReasonVerifiedDone, "Hive verified this is done but could not close it")
}
// (8b) an agent finding whose cited lines are gone from the default
// branch describes code main no longer has: close it rather than
// acknowledge or admit it (projectbluefin/testsuite#1085).
if in.citedLinesGone != "" {
return yourTurn(OwnershipReasonCitedLinesGone, "The cited lines no longer match main ("+in.citedLinesGone+") — close it, or admit it if the finding still holds")
}
// (9) agent-filed and unacknowledged while acknowledgment is required.
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")
Expand Down Expand Up @@ -967,6 +982,7 @@ func decideRepoOwnership(repos []FrontendRepo, cfg config.DashboardIssueBandsCon
authorIsHuman: item.AuthorIsHuman,
bucket: item.Bucket,
bucketReason: item.Reason,
citedLinesGone: item.CitedLinesGone,
decisionBlocker: decisionBlockerFor(nonEmpty(item.Repo, repoName)+"#"+strconv.Itoa(item.Number), item.OpenBlockers, decisionParks, repoName),
}
in.hiveClosingPR = hiveClosingPRFor(*repo, repoName, item.Number)
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) != 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))
if len(ownershipReasonVerbs) != 36+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, cited_lines_gone and the run and approval waits (#12380)", len(ownershipReasonVerbs))
}
verbs := map[string]bool{}
for _, verb := range ownershipVerbOrder {
Expand Down
64 changes: 64 additions & 0 deletions src/pkg/dashboard/ownership_cited_lines_gone_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package dashboard

import (
"strings"
"testing"
"time"

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

// An agent finding the issue filter refuses whose cited lines are gone from
// the default branch (RepoWorkIssue.CitedLinesGone, read by the enumeration)
// is CLOSE, not ADMIT or TRIAGE: projectbluefin/testsuite#1085 cited
// SKILL.md:163 for a fallback main no longer documented.
func TestCitedLinesGoneOffersClose(t *testing.T) {
l6 := ownershipEnv11565(6)
l6.selfAuthorizationHold = func(string) bool { return false }
l5 := ownershipEnv11565(5)
l5.selfAuthorizationHold = func(string) bool { return true }
gone := func(cite string, bucket, reason string, labels ...string) issueOwnershipInput {
in := nonActionable11565(bucket, reason, labels...)
in.citedLinesGone = cite
return in
}
closeIt := want11565{OwnershipVerbClose, OwnershipReasonCitedLinesGone}
for _, tc := range []struct {
name string
env ownershipEnv
in issueOwnershipInput
want want11565
}{
{"testsuite#1085 at L6", l6, gone("docs/skills/test-authoring/gnome/SKILL.md:163", repoWorkBucketFiltered, github.IssueFilterReason, "agent/reviewer"), closeIt},
{"at L5 it is CLOSE rather than TRIAGE", l5, gone("scripts/vm_validation_plan.py:108", repoWorkBucketFiltered, github.IssueFilterReason, "agent/reviewer"), closeIt},
{"a park keeps its ask", l6, gone("a.md:5", repoWorkBucketFiltered, config.DefaultNeedsDecisionLabel, "agent/reviewer", "stage/045-needs-decision"), want11565{OwnershipVerbDecide, OwnershipReasonParkedNeedsDecision}},
{"verified done stays verified done", l6, gone("a.md:5", repoWorkBucketFiltered, github.IssueFilterReason, "agent/reviewer", "hive/already-done"), want11565{OwnershipVerbClose, OwnershipReasonVerifiedDone}},
{"lines still on main: unchanged", l5, gone("", repoWorkBucketFiltered, github.IssueFilterReason, "agent/reviewer"), want11565{OwnershipVerbTriage, OwnershipReasonAgentFiledUnacknowledged}},
} {
t.Run(tc.name, func(t *testing.T) {
checkOwnership11565(t, decideIssueOwnership(tc.in, tc.env), tc.want)
})
}
got := decideIssueOwnership(gone("docs/x.md:163", repoWorkBucketFiltered, github.IssueFilterReason, "agent/reviewer"), l6)
if !strings.Contains(got.Reason, "no longer match main (docs/x.md:163)") {
t.Fatalf("reason %q must name the citation", got.Reason)
}
}

// End to end from the enumeration row the dashboard stores.
func TestRepoOwnershipClosesStaleFindingRow(t *testing.T) {
now := ownershipNow11565
env := ownershipEnv11565(6)
env.selfAuthorizationHold = func(string) bool { return false }
repos := []FrontendRepo{{Name: "testsuite", Full: "projectbluefin/testsuite", NonActionableIssues: []any{
github.RepoWorkIssue{Repo: "projectbluefin/testsuite", Number: 1085, Labels: []string{"agent/reviewer"},
Bucket: repoWorkBucketFiltered, Reason: github.IssueFilterReason, CitedLinesGone: "docs/skills/test-authoring/gnome/SKILL.md:163",
CreatedAt: now.Add(-24 * time.Hour), UpdatedAt: now.Add(-time.Hour)},
}}}
decideRepoOwnership(repos, config.DashboardIssueBandsConfig{}, env)
d := ownershipFor(repos[0].Ownership, ownershipKindIssue, 1085)
if d == nil || !d.YourTurn || d.Verb != OwnershipVerbClose || d.ReasonCode != OwnershipReasonCitedLinesGone {
t.Fatalf("#1085 = %+v, want CLOSE cited_lines_gone", d)
}
}
13 changes: 12 additions & 1 deletion src/pkg/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ type Client struct {
// the installation's answer (installationGrantsWorkflows).
workflowsSelfPush func(agent string) bool
workflowsGrant workflowsGrantCache
// citedLines caches the stale-finding check (issue_cited_lines.go).
citedLines citedCache
// reporterConfirmationEnabled restores the legacy close gate for all
// human-filed bug-family issues when configured. Nil/false means only
// per-issue opt-in markers activate the gate.
Expand Down Expand Up @@ -1981,6 +1983,8 @@ func (c *Client) splitRepo(repo string) (owner, repoName string) {
func (c *Client) fetchIssues(ctx context.Context, repo string, now time.Time, reporterTrustWaitBudget *reporterTrustWaitBudget) (actionable []Issue, held []HoldItem, totalIssues int, breakdown RepoIssueBreakdown, details []RepoWorkIssue, err error) {
issueFilter := c.getIssueFilter()
owner, repoName := c.splitRepo(repo)
// Stale-finding checks this pass may refresh (issue_cited_lines.go).
citedBudget := citedMaxChecksPerRepo
// Taken before the list call: a hold recorded after the listing snapshot
// must outlive this pass's prune of the local hold-source record.
passStart := time.Now().UTC()
Expand Down Expand Up @@ -2145,7 +2149,9 @@ func (c *Client) fetchIssues(ctx context.Context, repo string, now time.Time, re

if !issueFilter.Admits(labels) {
breakdown.Filtered++
details = append(details, c.workIssue(repo, issue, labels, "filtered", issueFilterReason))
row := c.workIssue(repo, issue, labels, "filtered", issueFilterReason)
row.CitedLinesGone = c.citedLinesGone(ctx, owner, repoName, issue, labels, &citedBudget)
details = append(details, row)
continue
}

Expand Down Expand Up @@ -5106,6 +5112,11 @@ type RepoWorkIssue struct {
Reason string `json:"reason,omitempty"`
// ReporterConfirmationGate mirrors Issue.ReporterConfirmationGate.
ReporterConfirmationGate bool `json:"reporter_confirmation_gate,omitempty"`
// CitedLinesGone names the citation ("path:163") of an agent finding the
// issue filter refuses when every permalink it cites is gone from the
// default branch (issue_cited_lines.go); "" when any is still there or
// it was not checked.
CitedLinesGone string `json:"cited_lines_gone,omitempty"`
// ClaimKind, ClaimedBy and ClaimPRStarted are Issue.ClaimKind /
// Issue.ClaimedBy / Issue.ClaimPRStarted, copied for the issue stage
// reconciler.
Expand Down
Loading
Loading