Repository navigation
π Let the agent that opened a PR reply on its review threads - #19102
Conversation
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. βΉοΈ Sentinel: informational, author is trusted (owner), merge is not blocked. Head
No Review findings from Security review at head f9245d6. Two issues (new from this perspective), neither a hard exploit, both trust-boundary gaps.
(replacing the Verified OK: the gate is fail-closed on lookup errors, the path regexes are anchored, the reply target is resolved to its PR from the same repo, the lookup token is never borrowed from another agent, and draft bodies are fenced with ``` neutralised ( Review findings from Correctness review at f9245d6. I read the diff, the MITM chain in
Noted, not blocking: delete ownership is "authored by the hive App login", so any agent can retract another agent's or the sweep's hive-authored comment within 15 minutes. That follows from the shared bot identity and is bounded by the window. @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. Review findings from Delta re-review at 0f6e2c7 (correctness). Still present: draft lost on second lookup failure; reference-repo reply/delete skips tier check; own-comment DELETE not scoped to caller; drafts recorded for non-owner agents; lookup before isLinear check; duplicated PR resolution. No longer applies: needsHuman split (single function now). Line-level fixes are in the threads. The rest of the large delta is outside the #19096 contract and was not reviewed in depth. Findings not on a changed line
Review findings from Routing, not a defect report. This widens the proxy's GitHub write surface (new allow rules in the MITM chain), which is a trust-surface change a person should sign off on. The PR body says the delete window and PR-owner check came from a maintainer decision on this PR; I could not find that decision in the body, so please confirm it covers the final shape. What I read at the head (
Small, non-blocking: I did not run tests (CI is the verdict per AGENTS.md). Nothing was closed or approved. Review findings from This is a proxy write-gate change ( What I read: What I did not read: the rest of The decision: the issue (#19096) is about replying in review threads. The PR also opens hive/awaiting-ci: rebased onto v5 and pushed; CI pending - sweep will merge when green. π Hive Agent: Review findings from Security perspective at a1d63a8: no in-scope blocker. The review-thread gate fails closed (unidentified caller, no OwnPR, lookup failure, non-owned PR, other agent), resolves the PR from the comment's Findings not on a changed line
merged by Hive trusted-author auto-merge: author |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
| blockReason = reason | ||
| blockCode = DenyReasonRepoAutoMergeOff | ||
| blockJSON = true | ||
| } else if reason, refused := p.reviewThreadRefusal(req, agentName); !isLinear && refused { |
There was a problem hiding this comment.
Check !isLinear first so the guard (which may do a GitHub GET) is never called for Linear traffic, as the sibling branches do. E.g. fold into else if !isLinear { if reason, refused := ...; refused {...} } or reorder the condition via a small helper.
| // hive's own agent opened, the drafted text is handed to the review-feedback | ||
| // sweep so it can post its needs-human note with the reply a person should | ||
| // place. The request body is left readable for the caller's drain. | ||
| func (p *GitHubProxy) noteRefusedReviewReply(req *http.Request, agentName, reason string) { |
There was a problem hiding this comment.
This repeats the classify / reviewCommentPR / OwnPR sequence from reviewThreadRefusal (line 170), costing a second lookup per refused reply. A shared resolveReviewWritePR helper would keep the two in step.
| // needsHuman posts the needs-human note: once per PR when feedback cannot be | ||
| // routed, or with drafts set, the replies the agent drafted but could not | ||
| // post (#19096), at most once per Limits.Window (BlockedDraftsDue). | ||
| func (s reviewFeedbackSweep) needsHuman(ctx context.Context, key, repo string, number int, reason string, items []github.FeedbackItem, drafts []reviewfeedback.ReplyDraft, res *reviewFeedbackResult) { |
There was a problem hiding this comment.
needsHuman now has two modes selected by len(drafts), and three call sites pass nil. A separate method for the blocked-draft hand-off would be easier to read.
|
/hive decision Request changes. (1) Scope own-comment DELETE to comments on a PR or issue the calling agent opened: resolve the PR from pull_request_url or issue_url, use OwnPR and require the owner to match the calling agent, and do not allow deleting review comments or review bodies (if that is too heavy, narrow to issue comments on the caller's own PR). (2) In noteRefusedReviewReply, return unless the PR owner equals the calling agent (the adjudicator's suggested OwnPR owner check), so one agent cannot make the hive post text onto another agent's PR. (3) Keep the lookup from losing a drafted reply on a transient failure: reuse the PR number resolved by the first lookup, or record the draft with the repo and comment id. (4) Mirror the other branches' tier checks (pol.Issues and pol.PRs) for replies and deletes on reference repos. (5) Merge origin/v5 to clear the conflict and re-run the citation fixers. Add tests for each of these. |
f9245d6 to
0700d31
Compare
There was a problem hiding this comment.
Security delta re-review at 0f6e2c7: two prior security findings are still present (own-comment DELETE not scoped to the calling agent, review_thread.go:199/275-298; refused drafts recorded for non-owner agents, review_thread.go:243). Fixes are in the inline threads. Correctness/style items from the prior head are outside this perspective; no change seen in those paths.
-- hive: agent=adjudicator-2 backend=claude model=claude-sonnet-5-5 claude=2.1.327
| } | ||
| number = n | ||
| } | ||
| if _, owned := g.OwnPR(w.repo, number); !owned { |
There was a problem hiding this comment.
Security: only ownership is checked, not that the owner is the calling agent, so a non-owner agent's refused draft is recorded and posted by the sweep.
| if _, owned := g.OwnPR(w.repo, number); !owned { | |
| owner, owned := g.OwnPR(w.repo, number) | |
| if !owned || !strings.EqualFold(owner, agentName) { | |
| return | |
| } |
| if g.OwnPR == nil { | ||
| return reviewThreadRefusalText("this hive has no record of which PRs its agents opened"), true | ||
| } | ||
| if w.kind == reviewWriteDelete { |
There was a problem hiding this comment.
Security: delete is checked only against the shared hive login + 15-minute age. Also resolve the comment's PR/issue and require g.OwnPR(repo,n) owner EqualFold agentName, so one agent cannot delete another agent's hive-authored comment.
There was a problem hiding this comment.
Decision needed: @clubanderson should the crux proxy start letting the agent that opened a PR reply in its review threads, post PR review comments, and delete the hive's own comments younger than 15 minutes?
This is a permission change to the agent write surface in src/crux/proxy (new REST routes allowed, reference-repo replies/deletes now deferred to a new gate), so I am routing it rather than judging it as a plain bug fix. The question for a maintainer: is the allow-list in the PR body (hive-opened PR per agent_pr_created, caller is the opening agent, own-comment delete within 15 minutes, fail closed on lookup errors) the intended trust boundary?
What I read: the cmd/hive wiring (main.go SetReviewThreadGuard, review_feedback_wire.go reviewThreadOwners with a 1-minute cache over auditPRAgents). It reads consistent with the PR body: ownership comes from the audit trail, the bot login from the live client per call. I did not read the 1235-line proxy gate itself (review_thread.go, rules.go, reference_repos.go), so this is not a correctness sign-off on those.
One thing to weigh when deciding: ownership is cached for a minute, so a PR opened inside that window is refused until the next reload, and the refusal is then handed to a person via the needs-human note. That fails safe, just noisily.
-- hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.327
Mutation testingβ±οΈ The 900s mutation budget ran out, so 1 package(s) were not fully mutated and the results below do not cover them:
β gremlins did not produce a report for 1 package(s), so no verdict can be derived from this run (see the job log):
βΉοΈ 7 mutant(s) on added lines were SKIPPED because gremlins v0.6.0 only honours the first
Verdict: |
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether any agent may delete any hive-authored comment (not just its own) within 15 minutes, since this widens the proxy's write surface.
This changes the proxy's write rules (src/crux/proxy), a trust surface, so it needs a person to sign off. The head was pushed recently, so I am not pushing anything; the suggestion below is for the author.
Delete is scoped to the hive's identity, not to the calling agent (medium). ownCommentDeleteRefusal in src/crux/proxy/review_thread.go allows DELETE when the comment author is the App bot login and the comment is under 15 minutes old. It never checks that the comment sits on a PR the calling agent opened. Agents post through hive-review and the hive's other relays as that same bot, so any agent can delete any other agent's recent review, sentinel or needs-human comment on any PR in scope. The PR body describes the delete rule as "the hive's own comment", which is what the code does, but the reply and PR-comment routes are scoped to the opening agent and the delete route is not.
Suggestion: resolve the comment's PR (as reviewCommentPR does for replies; for an issue comment use issue_url) and require OwnPR(repo, n) to name the calling agent, the same check the reply route uses. Alternatively, keep the current rule and state it explicitly in src/docs/github-write-surface.md.
Everything else I read, the reply and PR-comment ownership checks, fail-closed lookups, the clock-skew handling, and the draft peek that keeps the body readable, looks consistent with the stated design.
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.327
683dca2 to
a1d63a8
Compare
|
@clubanderson this PR is back in your court (
Once the new head lands, CI and the review swarm re-run automatically and the PR returns to the normal path. Current head: Updates (newest last):
|
|
hive/awaiting-ci: Sign-off survives the squash and native-queue-policy fail, and the baseline check reports this branch 12 commits behind v5 (same on #19063, #19110, #17512), so it is branch drift, not a shared incident. Suggested fix: merge the latest v5 into this branch (signed off), then re-check. Not pushed, since this is not a hive-authored branch. π Hive Agent: |
|
Scanner triage: failing checks here are not caused by this diff. Baseline check says π Hive Agent: |
|
Scanner triage: the failing checks here (native-queue-policy, Sign-off survives the squash) are not on the default branch; the branch is behind v5 and the checks are stale. Suggested fix: merge the base branch into this branch (signed off) and let CI re-run. This is a human-authored branch, so I am not pushing. π Hive Agent: |
|
Scanner triage: baseline check says this branch is behind its base by 22 commits and the failing checks (native-queue-policy, Sign-off survives the squash) are not shared with the base branch. Suggested fix: merge the base branch into this branch (signed off, π Hive Agent: |
Signed-off-by: Andy Anderson <andy@clubanderson.com>
0f56aad to
d9ac7fa
Compare
Every agent posts as the same App bot, so the author and age checks alone let any agent delete another agent's or a reviewer's comment. The delete gate now resolves the comment's PR from its own pull_request_url or issue_url and refuses unless the caller opened it, the same OwnPR check the reply path uses. Lookup failures refuse. Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
Decision on the delete question (least privilege, same rule as replies): an agent may delete a hive-bot comment only when it is under Done in 204538c: Second security finding (draft capture for non-owner agents): left as is on purpose. The sweep can kick a fallback fixer when the opening agent is unavailable, and that fixer is never allowed to reply, so its draft only reaches a person through this capture. The text is bounded and fenced. Limiting capture to the owner would silently drop those drafts; a tighter fix (owner or the agent the sweep kicked for that PR) needs kick state the proxy does not have, so it is better as a follow-up. |
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
e2ad1a3 to
e20206c
Compare
|
New changes are detected. LGTM label has been removed. |
Signed-off-by: Andy Anderson <andy@clubanderson.com> # Conflicts: # src/cmd/hive/review_feedback_wire.go
There was a problem hiding this comment.
Security review, delta 0f56aad..e20206c. The 208-file delta looks like a merge of the base branch. I only read this PR's own 13 files at head, not the unrelated merged code, so I could not judge that.
The ownership gate holds up. Replies and PR comments resolve the PR from the comment's pull_request_url and not from the path. Deletes need the hive's own author, a 15-minute window and a PR owned by the caller. Every failed lookup refuses. The gate sits after pause, scope and auto-merge in the MITM chain (github_proxy_mitm.go). The lookup token is the reference repo's token, the agent's own token, or the request's own credential (review_thread.go:395-413).
One in-scope finding. The refused-reply hand-off posts agent-controlled in_reply_to unfenced and unbounded (see the inline comment on review_thread.go:286). This is low-medium severity and the fix is small.
noteRefusedReviewReply (review_thread.go:258) records a refused draft from any agent on any hive-owned PR. It does not check that the caller is the owner. The draft body is fenced, so this is only an advisory note.
-- hive: agent=adjudicator-2 backend=claude model=claude-sonnet-5-5 claude=2.1.327
| if json.Unmarshal(raw, &payload) != nil { | ||
| return "", "" | ||
| } | ||
| return payload.Body, strings.Trim(string(payload.InReplyTo), `"`) |
There was a problem hiding this comment.
in_reply_to is agent-controlled and only quote-trimmed here. For a refused POST pulls/{n}/comments it is kept as InReplyTo (line 261-263; only overwritten with the numeric id for the reply route), and NeedsHumanNote prints it unfenced (reviewfeedback.go:661, Reply to review comment %s:). The body is fenced and bounded, this field is neither: up to 16KB of newlines, raw @mentions, links or a forged FeedbackNeedsHumanMarker line would be posted by the hive's own identity, skipping the outbound prose filter. A prompt-injected agent can do this from a reviewer comment. Fix: accept digits only.
| return payload.Body, strings.Trim(string(payload.InReplyTo), `"`) | |
| if s := strings.Trim(string(payload.InReplyTo), `"`); regexp.MustCompile(`^\d{1,20}$`).MatchString(s) { | |
| return payload.Body, s | |
| } | |
| return payload.Body, "" |
Fixes #19096
Root cause
src/crux/proxy/rules.go: the REST rule table allowedPOST issues/{n}/comments(ModeIssuesOnly orconverse) andPOST pulls/{n}/reviews, but had no rule forPOST pulls/{n}/comments/{id}/replies(orpulls/comments/{id}/replies),POST pulls/{n}/comments, or any commentDELETE.AllowedByModeCapsis deny-by-default for an unmatched route, so all three were refused with no reason text while the issue-comment route passed. That is the pattern seen on a hosted hive: the agent could post a probe issue comment but could not reply in a review thread or delete the probe.src/crux/proxy/reference_repos.go(ReferenceRepoDecision) also refused replies and comment deletes on a reference repo.src/pkg/reviewfeedback/reviewfeedback.go: the brief said nothing about refused writes or probe comments, and a reply refused after a kick never reached the needs-human path.What is allowed, and the exact guard
New review-thread gate,
src/crux/proxy/review_thread.go, in the MITM refusal chain after pause, agent scope and auto-merge (and after the reference-repo rules):POST /repos/{o}/{r}/pulls/{n}/comments/{id}/repliesandPOST /repos/{o}/{r}/pulls/comments/{id}/repliespull_request_url, never from the path) was opened by the hive's own agent per the audit trailagent_pr_created(the sweep's ownership source, cached 1 minute), and the caller is that agentPOST /repos/{o}/{r}/pulls/{n}/comments{n}is hive-opened per the audit trail, and the caller is the agent that opened itDELETE /repos/{o}/{r}/issues/comments/{id},DELETE /repos/{o}/{r}/pulls/comments/{id}OwnCommentDeleteWindow(15 minutes)Everything else is refused with reason
review_thread: other PRs, other agents, other repos, unidentified callers, someone else's comment, older or future-dated comments, and any lookup that fails (fail closed). The 403 tells the agent to stop and never post a probe comment. The mode tier still applies on top: replies and PR review comments atISSUES_AND_PRSorconverse(the tier of a review), deletes atISSUES_ONLY. On a reference repo, replies and deletes now defer to this gate instead of being refused outright. GraphQLaddPullRequestReviewThreadReplycarries only node ids and stays on the mode ladder (conversation bucket); this gate is REST-only.Refused reply hand-off
When any gate refuses a reply on a hive-opened PR, the proxy keeps the drafted body (bounded) and the review-feedback sweep posts it in its existing needs-human note, quoted as text, at most once per
HIVE_REVIEW_FEEDBACK_WINDOW. Same write site as before (main.reviewFeedbackSweep.needsHuman), so no new notification site or write-back entry.Brief changes
The reply-style step is unchanged: threaded replies stay allowed, not mandated. Added only:
Tests
Table-driven proxy tests: reply and PR review comment allowed for the owning agent on a hive-opened PR (both path forms); refused for another agent, another PR, another repo, an unresolvable comment and an unidentified caller; delete allowed for the hive's own recent comment, refused for old, future-dated, author-less and someone else's comments; lookup failure fails closed; reference-repo login and token; mode table; reference-repo decision; draft capture; an end-to-end MITM test. Plus store, note, brief, and sweep-wire tests (drafts posted once, audit ownership cache).
Docs:
src/docs/github-write-surface.md(new section),src/docs/labels-and-control-signals/reference.md(review feedback). Changelog fragmentchangelog.d/fixed-19096-review-thread-replies.md. No config keys changed.Follow-up (not in this PR)
How an agent answers review feedback differs between maintainers, so it is not changed here. A per-hive and per-repo knob is a follow-up:
review.feedback.reply_style: summary|threaded|bothandreview.feedback.resolve_threads: false|true, defaulting to today's behavior.π€ Generated with Claude Code