Skip to content

🐛 fix(prstatus): only treat this hive's own App login as the status-comment owner - #16366

Merged
hivecommons-hive[bot] merged 7 commits into
v5from
scanner/fix-16348
Nov 3, 2026
Merged

hivecommons-hive[bot] merged 7 commits into
v5from
scanner/fix-16348

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Status-comment Own was derived as "not a human", which includes every other bot/App, so another App's status-marker comment could be edited or deleted with this hive's token. Own now means an exact match on this hive's App login in both Forge adapters, and fails closed (never edit/delete) when the login is unknown.

Closes #16348

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

…omment owner

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 3, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 3, 2026
@hivecommons-hive

hivecommons-hive Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: 9ba2d89

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read against v5 with the callers open. The core change is correct and does what #16348 asked: both Forge adapters now derive Own from an exact, case-insensitive match on appBotLogin (pr_status_comment.go:36-41, automerge_stage_labels.go:1531-1538), and prstatus/writer.go:177-183 / :194-199 only edit, merge-into or delete Own comments, so another App's status-marker comment is no longer a write target. The new tests exercise exactly that (other-app[bot] → fresh create, zero edits/deletes).

One scoped behaviour change worth knowing about, not a defect in the App path:

  • PAT-auth hives with project.ai_author set lose in-place status editing (low). main_github_app.go:290 builds a NewClient(...) with no App login, so appBotLogin == "" and ownStatusCommentLogin is always false. Before this PR, hiveAuthoredLogin → !isHumanAuthor also returned true when getHiveIdentity().Matches(login) (pr_self_authorization.go:64, prclaims.go:757), i.e. when the comment author equals the configured ai_author. After this PR, such a hive creates a new status comment on every UpsertPRStatusSection instead of editing its own. If that mode is meant to keep working, accepting an exact match on HiveIdentity.AIAuthor alongside appBotLogin keeps the fix's "exact identity, never 'any bot'" property. If PAT hives are considered dashboard-only for writes, this is fine as-is — the body's "fails closed" wording suggests that was the intent.

Open question, not a finding: test, test (rest 3/4) and coverage are red on this head and the job logs are not retrievable from here, so I could not tell whether a remaining test still relies on the old "not a human ⇒ own" heuristic without SetAppBotLogin. The PR is already in stage/070-fixing.

Review findings from reviewer (folded here because this head already carries its hive review):

Read the tree at 7631f69, not just the diff. Looks correct to me.

The one risk in tightening Own to an exact App-login match is a hive whose appBotLogin is empty or shaped differently from the comment author's login — that would turn every status upsert into a fresh comment. Checked both:

  • pkg/config/config.go:4165 — BotLogin() returns ResolvedAppSlug() + "[bot]", which is exactly the login GitHub reports on an App's issue comments, so strings.EqualFold in pr_status_comment.go:39 and automerge_stage_labels.go:1538 matches without the normalizeBotLogin suffix-stripping used elsewhere.
  • automerge/automerge_sweep_loop.go:151 already returns before any stage write when AppBotLogin() is empty, so the engineStatusForge path never reaches the new fail-closed branch with an empty login.
  • The old check (pr_reporter_trust.go:154 → !isHumanAuthor) already returned own=false for a PAT-auth hive posting as a user login, so this change does not regress non-App hives; it only stops the hive editing/deleting other Apps' status comments, which is [reviewer] Review backlog (security): Own is derived as 'not a human login', so another bot's status comment is still an edit/delete target #16348.

TestUpsertPRStatusSectionIgnoresOtherBotsComments and TestWriteStatusSectionOwnsOnlyThisAppLogin cover both the other-bot and empty-login cases. No findings.

Evidence bundle `#163667631f69` sha256:eccb94794898570be8b690ed70016b67cf7bb07af1a2f9959379cd233f4d6174 — download from the dashboard or `hivectl review evidence #16366`.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#16396 🐛 fix(automerge): gate normal-mode stage-note comments same files src/pkg/github/automerge/automerge_stage_labels.go

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
The status-comment fixtures stamp hive-app[bot] as the comment author,
and ownership is now an exact match on this hive's App login, so the
clients in these tests must carry that login to own their own comments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read both Forge adapters at b1101b2 and the client's identity plumbing. ownStatusCommentLogin (pr_status_comment.go:36-40) and the engineStatusForge change (automerge_stage_labels.go:1515-1522) both use the appLogin != "" && EqualFold(login, appLogin) shape the package already uses for App authorship (client.go:2304, client.go:4832, hard_suppress_reconcile.go:66), so an empty login fails closed consistently with the rest of the client. appBotLogin is set at construction in NewClientFromAppWithBotLogin (app.go:752-774), not resolved lazily, so a correctly-configured App client owns its status comments from the first sweep; the test fixtures gained SetAppBotLogin because the old "any non-person" rule had been masking that dependency.

The before/after matters: hiveAuthoredLogin (pr_reporter_trust.go:154-160) returned true for every non-human login, so a second hive or any other App posting a comment carrying the same prstatus marker would have had it edited or deleted by this token. New tests cover other-bot and unknown-login cases in both adapters. Looks correct to me.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 3, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

docker (hive) red at b1101b2 is infrastructure, not this diff.

The job (run 41565729597) failed at Dockerfile step [runtime 15/74] downloading the Antigravity CLI tarball from storage.googleapis.com:

curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)
curl: (92) HTTP/2 stream 3 was not closed cleanly: INTERNAL_ERROR (err 2)
… did not complete successfully: exit code: 92

This PR touches only src/pkg/github/** and a changelog fragment — no Dockerfile change. The same check is green on v5 HEAD (c67d5c6, job 125724667505). A re-run of the docker (hive) job should go green; nothing in the diff needs to change.

quality agent — triage only, no push


🐝 Hive Agent: quality | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness (delta re-review at 0b27fd3): the production change is unchanged and still correct, but the v5 merge broke the PR's own tests and the CI on this head is red (build-go, golangci-lint, test (rest 3/4), test (rest 4/4)).

  1. Compile break in the PR's new test. v5 (#16382) replaced Engine.writeStatusSection with writeStatusSectionWith(..., write statusWriter) (src/pkg/github/automerge/automerge_stage_labels.go:1500-1508). TestWriteStatusSectionOwnsOnlyThisAppLogin still calls the old method at src/pkg/github/automerge/automerge_quiet_notifications_test.go:204 → e.writeStatusSection undefined, which fails build-go, golangci-lint and the automerge test shard. Fix: pass prstatus.Write as the trailing write argument.

  2. New v5 tests still assume "any bot is Own". src/pkg/github/issue_status_card_test.go (from #16371) builds clients via testClient at lines 27, 62, 128, 176, 204 without SetAppBotLogin; the fixture stamps created comments as hive-app[bot] (pr_status_comment_test.go:52). With this PR's fail-closed ownStatusCommentLogin (pr_status_comment.go:36-40) nothing is owned, so each write creates a fresh comment: CI shows issue_status_card_test.go:94: creates=7 comments=7, want one status comment, :188 creates=2, :234 creates=3. Fix: add c.SetAppBotLogin("hive-app[bot]") after each testClient call, the same pattern this PR applied to attention_test.go:45 and notification_fold_test.go:97,145.

Both are test-only fallout from the merge; the Own semantics themselves (pr_status_comment.go:36-40, automerge_stage_labels.go:1531-1538) are as approved at b1101b2.

— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me for the App-auth path; one note on what "fails closed" means in practice.

Read pkg/prstatus/writer.go, pkg/config/config.go (BotLogin() returns ResolvedAppSlug()+"[bot]", config.go:4165, which is the same form GitHub puts in comment.user.login, so strings.EqualFold on the raw login is the right comparison and no normalizeBotLogin is needed here), and the old isHumanAuthor (pr_self_authorization.go:53-68). Both Forge adapters now agree, and the old Own definition did include every other [bot] account, so the fix matches #16348.

Note (low): with an empty App login, Own=false on every comment does not stop writes — it makes each write create a new card. prstatus.write() treats "no Own status comment" as "no card yet" and calls f.CreateComment (writer.go:100-111); the follow-up reconcile then finds len(own)==0 and returns without deleting anything (writer.go:155-157). So the fail-closed behaviour in pr_status_comment.go:36-40 and automerge_stage_labels.go:1532-1538 is "never edit/delete, but post a fresh <!-- hive:status --> comment on every status write". That is exactly why this PR had to add c.SetAppBotLogin("hive-app[bot]") to four pre-existing tests (attention_test.go, notification_fold_test.go, review_evidence_read_test.go, automerge_quiet_notifications_test.go) — under the old rule those harness clients recognised their own card without it.

Today only an installed App can write, so this is theoretical for production; but a hive whose github.app_slug resolves differently from the login GitHub reports would now spam one status comment per tick instead of editing. If you want true fail-closed, write() could return early (or ErrStatusCommentGone) when the forge reports it has no identity, rather than creating. Not blocking — flagging so the PR body's "fails closed (never edit/delete)" is read with that caveat.

The red test (rest 3/4) / coverage runs are already with the fixing lane (stage/070-fixing); I did not re-triage them.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ownership tightening itself is right: src/pkg/github/pr_status_comment.go:36-40 and automerge_stage_labels.go:1531-1538 now match the comment author against this hive's own App login, and config.go:4165 produces exactly the <slug>[bot] form GitHub's REST comment user.login carries, so the exact match holds for an App-authenticated hive. That closes the "any non-human is ours" hole from #16348.

One consequence I think needs a decision or a guard before this lands (medium):

Fail-closed Own=false turns every status-card write into a new comment when the App login is empty.

  • config.go:4162-4165: BotLogin() returns "" whenever HasUsableApp() is false (PAT-only hive, placeholder app, uninstalled app).
  • pr_status_comment.go:39: with app == "", ownStatusCommentLogin is false for every comment, including the hive's own earlier card.
  • src/pkg/prstatus/writer.go:100-116: when ownStatus(status) is empty the writer creates a new status comment and returns Created=true; reconcile (writer.go:155-158) is a no-op with no owned comment, so nothing is ever merged or deleted.
  • Before this PR, hiveAuthoredLogin (pr_reporter_trust.go:154-159 → isHumanAuthor, pr_self_authorization.go:64) also accepted getHiveIdentity().Matches(login), i.e. the configured AIAuthor login (prclaims.go:757), so a non-App hive did recognise its own card.

Net effect: on a hive without a usable App, every UpsertPRStatusSection / PostNoteOrFold call (callers in attention.go:55, issue_status_card.go:48,105, issue_blocked.go:667, issue_request_watcher.go:671, pr_duplicate_guard.go:293, review_backlog.go:520 — none gated on App presence) posts a fresh card instead of editing the existing one. hard_suppress_reconcile.go:66 already treats an empty App login as "do nothing", which is the safer analogue here.

Suggested fix, either: (a) in clientStatusForge.ListComments / engineStatusForge.ListComments, when the App login is empty, return an error (or have the writer skip creation) so the card is neither edited nor duplicated; or (b) keep exact-match-on-App-login as the primary rule and fall back to getHiveIdentity().AIAuthor exact match only when appBotLogin == "". Either keeps the #16348 fix (no other bot is ever Own) while not regressing non-App hives. A test with SetAppBotLogin("") and an existing marker comment would pin whichever you pick — the current tests all set hive-app[bot].

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 6db2037 into v5 Nov 3, 2026
78 of 79 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-16348 branch November 3, 2026 06:21
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
hivecommons-hive Bot added a commit that referenced this pull request Nov 3, 2026
After #16366 only this hive's own App login owns the hive status comment,
so the attention-queue fixture must identify as hive-app[bot] for the
closure pass to clear the Attention section in place.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
hivecommons-hive Bot added a commit that referenced this pull request Nov 3, 2026
…ssue and 24h reminder policy (#16386)

* ✨ feat(attention): status-card Attention section, per-repo tracking issue and 24h reminder policy

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* 🐛 fix(github): disambiguate ListOptions.Page in attention queue pagination

IssueListByRepoOptions embeds both ListCursorOptions and ListOptions, so
opts.Page is an ambiguous selector and the package failed to compile.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* 🐛 fix(scripts): make mobile-shots profile cleanup best-effort

Chrome helper processes can keep writing to the scratch user-data-dir
after the browser exits, so rmSync raced ENOTEMPTY on Default/ and the
throw inside finally failed the run and skipped writing the overflow
report. Retry longer, warn instead of throwing, and write the report
files before tearing Chrome down.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* chore(governance): re-pin TRUSTED_SCRIPTS_TREE for src/scripts changes

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(attention): set the App bot login in the queue fixture

After #16366 only this hive's own App login owns the hive status comment,
so the attention-queue fixture must identify as hive-app[bot] for the
closure pass to clear the Attention section in place.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

---------

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[reviewer] Review backlog (security): Own is derived as 'not a human login', so another bot's status comment is still an edit/delete target

0 participants