Repository navigation
π Activity Monitor: PR-scoped row actions on nested PRs; Let hive decide per PR, never silently one - #15056
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@clubanderson this PR is held at Why:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
There was a problem hiding this comment.
Security perspective β no blocker; one advisory (low).
prs hint is accepted unverified and uncapped β src/pkg/dashboard/api_repo_item_decide_delegated.go:81,284,373-394. When the client sends prs, delegatedNestedOpenPRs only dedupes/sorts it; the tracker's linked_prs is consulted only when the hint is empty (line 374). So an issue job will fan out decideDelegatedOne(..., "pr", ...) β including QueuePRAutoMergeWithNote under mergerRole (line 692) β over any PR numbers the caller names, up to whatever fits in the 16 KiB body (line 49), in one request and one audit record attributed to the issue. Authorization is repo-scoped (canToggleRepoHold, lines 224β228) so no new authority is granted, but the "nested under this issue" invariant the PR body promises is only enforced client-side. Suggested hardening:
func (s *Server) delegatedNestedOpenPRs(repoFull string, number int, hint []int) []int {
- if len(hint) == 0 && s != nil {
+ var tracked []int
+ if s != nil {
s.statusMu.RLock()
status := s.status
s.statusMu.RUnlock()
if status != nil {
- hint = delegatedNestedPRNumbers(s.buildStageTracker(status, s.stageStoreOrShared(), time.Now().UTC()).Items, repoFull, number)
+ tracked = delegatedNestedPRNumbers(s.buildStageTracker(status, s.stageStoreOrShared(), time.Now().UTC()).Items, repoFull, number)
}
}
+ if len(hint) == 0 {
+ hint = tracked
+ } else if tracked != nil {
+ // Keep only PRs the tracker itself pairs with this issue.
+ ok := map[int]bool{}
+ for _, n := range tracked { ok[n] = true }
+ kept := hint[:0]
+ for _, n := range hint { if ok[n] { kept = append(kept, n) } }
+ hint = kept
+ }
+ if len(hint) > delegatedFanOutMaxPRs { hint = hint[:delegatedFanOutMaxPRs] }(plus const delegatedFanOutMaxPRs = 20 or similar). Falls back to trusting the hint only when the tracker has no snapshot.
β hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (correctness) β approve; one low advisory.
Server fan-out, per-PR job keys, sort/dedupe/never-self, "fail only when every PR failed", and the client tally/toast paths all check out against the tests (TestDelegatedDecisionIssueWithTwoPRsDecidesEach, TestStageTrackerPRScopedRowActions).
Low β poll budget is per request, fan-out is serial. runDelegatedDecisionPerPR (api_repo_item_decide_delegated.go:309-337) runs decideDelegatedOne for each PR one after another under the issue's single job, but the SPA still waits at most STAGE_TRACKER_DELEGATE_POLL_MAX Γ STAGE_TRACKER_DELEGATE_POLL_MS = 40 Γ 1.5 s = 60 s (index.html:16214-16215, 16967). With 3+ nested PRs (or slow GitHub calls) the client hits still deciding β check the row shortly (index.html:17032) and the issue toast reads as an error, the per-PR sub-row toasts (stageTrackerDelegatedSubResults) are never shown, and the per-PR jobs continue server-side. Two PRs is likely fine; suggest scaling the budget by the number of PRs in the request:
async function stageTrackerAwaitDelegated(url, job, max) {
const budget = Math.max(STAGE_TRACKER_DELEGATE_POLL_MAX, Number(max) || 0);
for (let i = 0; i < budget && !stageTrackerDelegatedDone(job); i++) {
and at the call site (index.html:17029) pass STAGE_TRACKER_DELEGATE_POLL_MAX * (Array.isArray(req.body.prs) ? req.body.prs.length : 1).
β hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
β¦ide per PR, never silently one An issue row with two nested PRs (one Ready for human merge, one Needs human decision) offered a single Decide that acted on 'its nested PR' β ambiguous, all or nothing. Every nested PR sub-row now carries its own gutter (checkbox + β―) and its menu / popover act on that PR (runRowAction receives the PR row object). An issue with β₯2 open nested PRs offers 'Let hive decide β all N PRs'; the server fans the delegated decision out per PR (prs hint or tracker linked_prs), registers each under the PR's own job key and answers with items + a decided-each summary. Sub-rows are selectable; the selection bar gains 'Let hive decide (N selected)' with a sent/decided/no-op tally. Close as superseded pre-fills the one sibling. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
a2d1e1d to
9d32c43
Compare
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply. |
There was a problem hiding this comment.
docs-currency (read at a2d1e1d)
src/docs/api-reference.md:288 still documents the old decide-delegated request/response shape. This PR adds the prs request hint (api_repo_item_decide_delegated.go:81) and the per-PR items array on the job (:105, element shape :110-116), and dashboard-sections.md now tells operators to send "prs": [15017, 15020] and read items. But the API reference row for POST/GET β¦/items/{number}/decide-delegated still says the body is {"type", "reason", "caption", "sentinel_reason"} and the job is {id, status, decision, notes, error} β so the reference contradicts the section doc for the one endpoint this PR changes. Suggested edit to that row (two fragments on line 288):
-Body `{"type": "issue"|"pr", "reason", "caption", "sentinel_reason"}`.
+Body `{"type": "issue"|"pr", "reason", "caption", "sentinel_reason", "prs": [n, β¦]}` (`prs` β optional hint, `type: "issue"` only: the issue's open nested PR numbers; omitted, the server reads them from the tracker's `linked_prs`).
-`POST` answers 202 with the job (`{id, status: "running"|"done"|"failed", decision: {verdict, rule, text, rationale, actions, keeps_park}, notes, error}`)
+`POST` answers 202 with the job (`{id, status: "running"|"done"|"failed", decision: {verdict, rule, text, rationale, actions, keeps_park}, notes, error, result, items}`; an issue with two or more open nested PRs is decided per PR β each under the PR's own job key β and `items` lists one `{number, type, status, decision, notes, error, result}` per PR with a summary `result.action: "decided-each"`)Everything else I checked matches the code: items field names, decided-each (row_action_result.go), the outcome/next wording (delegatedPerPRResult), linked_prs being open PRs only (stage_tracker.go:405), and the changelog fragment name/category.
β hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Intent alignment (read at head 9d32c43; dispatched as a2d1e1d). The diff does what #15055 asks β per-PR gutter/menu, decide:delegate-all, server fan-out with items β but two gaps:
1. The Decisions "awaiting" filter now hides exactly the #15009 case. stageTrackerActedMatches (static/index.html:14789) treats !!stageTrackerDecisionTarget(item) as "parked on a person". This PR makes stageTrackerDecisionTarget return null for an issue with β₯2 parked nested PRs (index.html:16547-16548), and the filter runs on top-level items only (index.html:15811), so an issue whose two PRs both wait on a human drops out of awaiting. Not covered by the diff or its tests.
case 'awaiting': return (!!stageTrackerDecisionTarget(item) || stageTrackerParkedNestedPRs(item).length > 1) && (!src || state === 'failed');
2. Server fans out without a hint, overriding the issue's own Decide. delegatedNestedOpenPRs falls back to the tracker's linked_prs when req.PRs is empty (api_repo_item_decide_delegated.go, runDelegatedDecision β delegatedNestedOpenPRs). The UI still offers a plain Decideβ¦ on an issue parked at 045 whose nested PRs are open but not parked (index.html:16549-16550, and the docs added in this PR say "the issue's own Decideβ¦ stays only when the issue itself is parked at 045"), sending {type:"issue"} with no prs. The server then decides (and comments on) each PR instead of the issue the operator confirmed. The contract (#15055 Β§3) is "must not pick one"; the server never picked one for type:"issue" β it decided the issue β so the explicit prs hint alone satisfies it. Suggest fanning out only on the hint:
- if prs := s.delegatedNestedOpenPRs(repoFull, number, req.PRs); len(prs) >= delegatedFanOutMinPRs {
+ if prs := s.delegatedNestedOpenPRs(repoFull, number, req.PRs); len(req.PRs) > 0 && len(prs) >= delegatedFanOutMinPRs {(or drop the tracker fallback and TestDelegatedNestedPRNumbersFromTracker with it).
Advisory, non-blocking: the selection bar's Let hive decide (N selected) (index.html:16670) judges decide:delegate, so a selection that includes the parent issue with β₯2 parked PRs is greyed "Not applicable to #N" rather than routed through delegate-all.
β hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
There was a problem hiding this comment.
Style / maintainability review (read at head 9d32c43; the dispatch named a2d1e1d, the PR has since moved).
1. api-reference.md still documents the old decide-delegated wire shape β src/docs/api-reference.md:289 spells out the body as {"type", "reason", "caption", "sentinel_reason"} and the response as {id, status, decision, notes, error}. This PR adds the prs hint (api_repo_item_decide_delegated.go, delegatedDecisionRequest.PRs) and the items[] / result.action: "decided-each" response (delegatedDecisionJob.Items, rowActionDecidedEach), but only dashboard-sections.md was updated. A consumer reading the reference will not find the per-PR mode.
-Body `{"type": "issue"|"pr", "reason", "caption", "sentinel_reason"}`. `POST` answers 202 with the job (`{id, status: "running"|"done"|"failed", decision: {verdict, rule, text, rationale, actions, keeps_park}, notes, error}`);
+Body `{"type": "issue"|"pr", "reason", "caption", "sentinel_reason", "prs": [nβ¦]}` β `prs` (issue only) names the open nested PRs; two or more (or two or more in the tracker's `linked_prs` when omitted) make the job decide each PR on its own. `POST` answers 202 with the job (`{id, status: "running"|"done"|"failed", decision: {verdict, rule, text, rationale, actions, keeps_park}, notes, error, result, items: [{number, type, status, decision, notes, error, result}]}` β `items` is set, `decision` unset and `result.action` is `decided-each` when the issue was decided per PR; each PR's job is also readable on its own path);2. Orphaned doc comment β static/index.html:16523-16527: the five-line "Pure: the item a row's Decideβ¦ acts onβ¦" comment that used to head stageTrackerDecisionTarget now sits directly above stageTrackerPRParked (its own comment follows at 16528), while stageTrackerDecisionTarget at 16539 has no header. Move the block down to just above function stageTrackerDecisionTarget.
3. Dead fallback in stageTrackerMenuTargets β static/index.html:16789: const list = row ? row.parentNode : sub.closest('#activity-monitor-panel'). A [data-ham-sub-key] node is always rendered inside its issue's .ham-row (stageTrackerSubRowHtml output is interpolated into the row template at 15057/15110), so row is non-null whenever sub is, and the panel branch is unreachable β and if it ever ran, stageTrackerRowKeys(panel) scans panel.children for data-ham-key and would return []. Simplify:
if (!row) return null;
const key = sub ? sub.dataset.hamSubKey : row.dataset.hamKey;
const list = row.parentNode;
Advisory (no change requested): stageTrackerSelectionActions at index.html:16670 relies on submenu[0] being decide:delegate by position of decideIds β submenu.find(s => s.id === 'decide:delegate') would survive a reorder. In Go, delegatedNestedOpenPRs guards s != nil on its own receiver (api_repo_item_decide_delegated.go, ~L373) β no caller passes a nil *Server; and the summary finish closure in runDelegatedDecisionPerPR sets j.Error on the first failure then clears it unless all failed β computing failed first and assigning Error once would read straighter.
β hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Security (delta re-review, head 9d32c43) β no new findings; the prs hint item from the previous review is still present and remains advisory.
Still present (low): src/pkg/dashboard/api_repo_item_decide_delegated.go:374-397 (delegatedNestedOpenPRs) takes the client's prs list as authoritative whenever it is non-empty: it only drops <=0, the issue itself and duplicates, then the fan-out at :297-351 decides and executes each number serially (own GitHub fetches + actions), bounded only by the 16 KiB body (:49) β a couple of thousand numbers. The tracker's linked_prs is consulted only when the hint is empty (:378-382), so the server never checks the listed PRs are actually nested under the issue the row claimed. Authorization is the same as N individual calls (:231-237, same mergerRole :261-262), so this is amplification/accidental scope rather than escalation β but the request is easy to tighten:
--- a/src/pkg/dashboard/api_repo_item_decide_delegated.go
+++ b/src/pkg/dashboard/api_repo_item_decide_delegated.go
@@ func (s *Server) delegatedNestedOpenPRs(repoFull string, number int, hint []int) []int {
- if len(hint) == 0 && s != nil {
+ var known []int
+ if s != nil {
s.statusMu.RLock()
status := s.status
s.statusMu.RUnlock()
if status != nil {
- hint = delegatedNestedPRNumbers(s.buildStageTracker(status, s.stageStoreOrShared(), time.Now().UTC()).Items, repoFull, number)
+ known = delegatedNestedPRNumbers(s.buildStageTracker(status, s.stageStoreOrShared(), time.Now().UTC()).Items, repoFull, number)
}
}
+ if len(hint) == 0 {
+ hint = known
+ } else if known != nil {
+ // The row's hint may only narrow the tracker's own pairing.
+ ok := map[int]bool{}
+ for _, n := range known {
+ ok[n] = true
+ }
+ kept := hint[:0]
+ for _, n := range hint {
+ if ok[n] {
+ kept = append(kept, n)
+ }
+ }
+ hint = kept
+ }
+ if len(hint) > delegatedFanOutMaxPRs {
+ hint = hint[:delegatedFanOutMaxPRs]
+ }(plus const delegatedFanOutMaxPRs = 25 next to delegatedFanOutMinPRs at :290.) The audit line at :347-348 already records per_pr, so the trail is intact either way.
β hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 9d32c43. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
There was a problem hiding this comment.
Correctness β delta re-review at 9d32c43 (previous head a2d1e1d). The delta is the #14992 merge plus one author change: settleDelegatedJob wired into both decide paths. No in-scope blocker; one advisory from the new wiring.
Fan-out issue job settles on the ledger as applied with no detail β src/pkg/dashboard/api_repo_item_decide_delegated.go:371 calls settleDelegatedJob(key, β¦) for the issue job after runDelegatedDecisionPerPR. That job has Decision == nil and Result.Action == "decided-each" (lines 350β369), so settleOperatorAction (src/pkg/dashboard/operator_actions.go:449β473) takes none of its branches: outcome is applied, detail "", even when every PR was a no-op (status stays done unless all failed). The β badge on #15009 would then say nothing about which PR got what. No test covers settle on the fan-out path (api_repo_item_decide_delegated_test.go never reads the ledger). Suggested handling in settleOperatorAction, before the no-op check:
if job.Decision != nil {
β¦
}
+ if job.Result != nil && job.Result.Action == rowActionDecidedEach {
+ outcome, detail = operatorActionOutcomeApplied, job.Result.Next
+ if len(job.Notes) > 0 {
+ detail += ": " + strings.Join(job.Notes, "; ")
+ }
+ allNoop := len(job.Items) > 0
+ for _, it := range job.Items {
+ if it.Error != "" || it.Result == nil || it.Result.Action != rowActionNoop {
+ allNoop = false
+ }
+ }
+ if allNoop {
+ outcome = operatorActionOutcomeNoOp
+ }
+ }
if job.Result != nil && job.Result.Action == rowActionNoop {Previous correctness finding β still present, still advisory: static/index.html:17160 stageTrackerAwaitDelegated keeps the fixed 40 Γ 1500 ms budget while the fan-out runs N serial decideDelegatedOne calls; a slow 3-PR issue can time out client-side while the server job is still running (the job is still readable by GET afterwards, so no data loss).
Out of scope (pre-existing from #14992, surfaced by the merge): recordOperatorAction (operator_actions.go:407β440) writes the pending record after the handler returns, while delegatedDecisionRunAsync (api_repo_item_decide_delegated.go:65) starts the job goroutine before that β a job that finishes fast (e.g. every nested PR answered "already running" at line 331) can Settle before the record exists, leaving it pending forever.
β hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Fixes #15055
Owner (2026-10-28 14:19 ET): issue row #15009 has two nested PRs β #15017 Ready for human merge Β· untrusted author and #15020 Needs human decision + hold β and "no way to Let hive decide for one or more of the PRs; it's all or nothing." The β― menu / Let hive decide / Approve lived on the issue row and acted on "its nested PR", which with β₯2 PRs silently picked one.
What changes
SPA (
static/index.html)stageTrackerLinkedPRItem(issue, lp), turns a nested PR into a full row item (number, repo, head,parent,siblings) and is used by the sub-row renderer,stageTrackerItemByKey,stageTrackerDecisionTargetand the popover'sstageTrackerDecisionOfβ sorunRowAction(action, row)always receives the PR row object.stageTrackerRowToolsHtml(pr): checkbox + β―); CSS.ham-sub > .ham-row-tools,.ham-sub.ham-selected(tokens only). Its menu offers the PR-scoped Decide set (Let hive decide, Approve, Close as superseded byβ¦, Won't fixβ¦, Give directionβ¦), Hold/Release, etc. A PR Ready for human merge (manual_merge/human_merge_reason) counts as parked.decide:delegate-all, hint per PR), posting{type:"issue", prs:[β¦]}.stageTrackerRowKeys/ApplySelection/hamSelectClick/stageTrackerMenuTargetscover[data-ham-sub-key]nodes; the selection bar gains Let hive decide (N selected); delegate summaries read "N sent Β· d decided Β· n no-op[ Β· f failed]" (stageTrackerDelegateTally).items) produce one result toast per PR on its own sub-row plus the issue summary (stageTrackerDelegatedSubResults); Close as superseded byβ¦ pre-fills the one sibling.Server (
api_repo_item_decide_delegated.go)delegatedDecisionRequest.PRshint;runDelegatedDecisionon an issue with β₯2 open nested PRs (hint or trackerlinked_prs) runsrunDelegatedDecisionPerPR: onedecideDelegatedOneper PR under the PR's own job key (a PR already deciding β per-item error, not a second run),Itemson the job, summaryResult{Action:"decided-each"}with outcome "feat: ntfy notifications on every agent kickΒ #17 approved (rule); feat: agents pull latest instructions on every kickΒ #20 β¦" and next "2 sent Β· 1 decided Β· 1 no-op". Fails only when every PR failed. One or zero nested PRs: unchanged.rowActionDecidedEachconstant.Tests β Go:
TestDelegatedDecisionIssueWithTwoPRsDecidesEach(mock gains PR #9),β¦OnePRHintDecidesIssue,TestDelegatedNestedPRNumbersFromTracker. Renderer (node):TestStageTrackerPRScopedRowActions(sub-row gutter, menu per sub-row targets its own number, issue with two parked PRs βdecide:delegate-alland no single Decide, requestprs, selection over sub keys, bulk chip, tally,runRowAction('decide:delegate-all')β 3 toasts keyed on issue + each PR); applicability / LetHiveDecide / popover / gutter fixtures updated for the new ordering, tally and shared builder.Docs β
dashboard-sections.md(Row actions, Multi-select, Let hive decide β How it runs); changelogfixed-pr-scoped-row-actions.md.Additive to #14995, #15014, #15013, #15011, #15016 and open #14992. Cites #15009 / #15017 / #15020. Nothing merges; no queue items were acted on.