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
2 changes: 1 addition & 1 deletion .github/scripts/integration-governance.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const MAX_COMMITS = 1000;
const MAX_AUTHOR_BATCH = 50;
// This literal is inside the enrolled .github closure. A caller-supplied
// preparedBy.sourceSHA must never choose a new executable verifier tree.
const TRUSTED_SCRIPTS_TREE = '718b8f2888041981d0779cfd19d90484ac01b8a9';
const TRUSTED_SCRIPTS_TREE = '1f1eb904839561af15c1772e6d9106a3b8d2b028';
const SOURCE = 'https://github.com/kubernetes-sigs/kubebuilder-release-tools/tree/012269a88fa4c034a0acf1ba84c26b195c0dbab4';
const sha = value => crypto.createHash('sha256').update(value).digest('hex');
const git = (args, cwd = process.cwd()) =>
Expand Down
27 changes: 21 additions & 6 deletions .github/scripts/pr-overlap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,33 @@ report_body() {
}
}

# One-line body the existing marker comment is edited to once a PR that had
# overlaps no longer has any. A PR that never had a finding gets no comment
# at all: the full clean report goes to the step summary only (#17863).
resolved_body() {
local base=$1
# shellcheck disable=SC2016 # backticks are literal Markdown
printf '%s\n\n### Open PR overlap check\n\nβœ… Resolved: no conflicting open PRs or same-file overlaps remain against `%s`.\n' "$MARKER" "$base"
}

upsert_comment_and_label() {
local pr=$1 body=$2 has_conflicts=$3
local pr=$1 body=$2 has_conflicts=$3 has_any=${4:-1} base=${5:-}
if ((DRY_RUN)); then
printf 'DRY RUN: would update PR #%s comment and label=%s\n' "$pr" "$has_conflicts"
printf 'DRY RUN: would update PR #%s comment and label=%s findings=%s\n' "$pr" "$has_conflicts" "$has_any"
printf '%s\n' "$body"
return 0
fi

local comment_id
comment_id=$(api "repos/${REPO}/issues/${pr}/comments?per_page=100" --paginate \
--jq ".[] | select(.body | contains(\"${MARKER}\")) | .id" | head -n1)
if [[ -n "$comment_id" ]]; then
if [[ "$has_any" != '1' ]]; then
if [[ -n "$comment_id" ]]; then
api -X PATCH "repos/${REPO}/issues/comments/${comment_id}" -f body="$(resolved_body "$base")" >/dev/null
else
printf 'PR #%s: no overlap findings and no earlier comment; not posting\n' "$pr"
fi
elif [[ -n "$comment_id" ]]; then
api -X PATCH "repos/${REPO}/issues/comments/${comment_id}" -f body="$body" >/dev/null
else
api -X POST "repos/${REPO}/issues/${pr}/comments" -f body="$body" >/dev/null
Expand All @@ -276,12 +291,12 @@ write_summary() {

run_for_one_pr() {
local pr=$1 base=$2 writable=$3 truncated=${4:-0}
local rows has_conflicts _has_any base_conflict body
make_report_for_pr "$pr" "$base" rows has_conflicts _has_any base_conflict
local rows has_conflicts has_any base_conflict body
make_report_for_pr "$pr" "$base" rows has_conflicts has_any base_conflict
body=$(report_body "$pr" "$base" "$rows" "$truncated" "$base_conflict")
write_summary "$body"
if [[ "$writable" == '1' ]]; then
upsert_comment_and_label "$pr" "$body" "$has_conflicts"
upsert_comment_and_label "$pr" "$body" "$has_conflicts" "$has_any" "$base"
fi
}

Expand Down
27 changes: 25 additions & 2 deletions .github/scripts/test-pr-overlap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ case "$*" in
*'.head.repo.full_name'*) printf '%s\n' "$REPO_SLUG" ;;
*'.head.sha'*) printf '%s\n' "${FALLBACK_SHA:-}" ;;
*'.base.ref'*) printf 'v6\n' ;;
*'/comments?'*) : ;;
*'/comments?'*) if [[ -n "${EXISTING_COMMENT_ID:-}" ]]; then printf '%s\n' "$EXISTING_COMMENT_ID"; fi ;;
*) echo "unexpected gh api call: $*" >&2; exit 2 ;;
esac
GH
Expand All @@ -134,6 +134,8 @@ run_pr() { # pr -> sets OUT and WRITES

LABEL_ADD="-X POST repos/${REPO_SLUG}/issues/%s/labels -f labels[]=conflicts-with-open-pr"
LABEL_DEL="-X DELETE repos/${REPO_SLUG}/issues/%s/labels/conflicts-with-open-pr"
COMMENT_POST="-X POST repos/${REPO_SLUG}/issues/%s/comments -f body="
COMMENT_PATCH="-X PATCH repos/${REPO_SLUG}/issues/comments/%s -f body="

echo 'PR 2: real sibling conflict with PR 3, stale PR 1 is not blamed'
run_pr 2
Expand All @@ -144,6 +146,16 @@ assert_not_contains "$OUT" '| #1 |' 'does not blame PR 1 for its conflict with t
assert_not_contains "$OUT" '| #4 |' 'does not link the unrelated stale PR 4'
# shellcheck disable=SC2059
assert_contains "$WRITES" "$(printf -- "$LABEL_ADD" 2)" 'labels PR 2 conflicts-with-open-pr'
# shellcheck disable=SC2059
assert_contains "$WRITES" "$(printf -- "$COMMENT_POST" 2)" 'posts the overlap comment when there is a finding'

echo 'PR 2: an existing marker comment is edited, not duplicated'
EXISTING_COMMENT_ID=4242 run_pr 2
assert_exit0
# shellcheck disable=SC2059
assert_contains "$WRITES" "$(printf -- "$COMMENT_PATCH" 4242)" 'edits the existing marker comment'
# shellcheck disable=SC2059
assert_not_contains "$WRITES" "$(printf -- "$COMMENT_POST" 2)" 'does not post a second comment'

echo 'PR 5: add/add of the same new path with different content'
run_pr 5
Expand All @@ -167,9 +179,20 @@ assert_contains "$WRITES" "$(printf -- "$LABEL_DEL" 1)" 'removes the sibling-con
echo 'PR 4: stale but clean, no overlap'
run_pr 4
assert_exit0
assert_contains "$OUT" 'No conflicting open PRs or same-file overlaps were found.' 'reports no overlap'
assert_contains "$OUT" 'No conflicting open PRs or same-file overlaps were found.' 'reports no overlap in the summary'
# shellcheck disable=SC2059
assert_contains "$WRITES" "$(printf -- "$LABEL_DEL" 4)" 'removes the sibling-conflict label'
assert_not_contains "$WRITES" '/comments' 'posts no comment when there is nothing to report (#17863)'
assert_contains "$OUT" 'no overlap findings and no earlier comment; not posting' 'logs the skipped post'

echo 'PR 4: a clean run edits an earlier finding comment to a one-line resolved note'
EXISTING_COMMENT_ID=777 run_pr 4
assert_exit0
# shellcheck disable=SC2059
assert_contains "$WRITES" "$(printf -- "$COMMENT_PATCH" 777)<!-- hive-pr-overlap -->" 'edits the existing comment, keeping the marker'
assert_contains "$WRITES" 'Resolved: no conflicting open PRs or same-file overlaps remain against `v6`' 'collapses to the resolved line'
# shellcheck disable=SC2059
assert_not_contains "$WRITES" "$(printf -- "$COMMENT_POST" 4)" 'does not post a new comment'

echo 'PR 3: missing pull ref falls back to the API head and replaces a stale local ref'
export FALLBACK_SHA
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/feedback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,35 @@ permissions:
pull-requests: write

jobs:
# The reusable workflow thanks every merged PR unconditionally; the gate
# keeps the comment for a person's first merged PR only (#17863). Rules and
# knobs: src/scripts/feedback-gate.sh.
gate:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
outputs:
post: ${{ steps.gate.outputs.post }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Self-test feedback gate
run: bash src/scripts/test-feedback-gate.sh
- id: gate
name: Decide whether to thank the author
env:
GH_TOKEN: ${{ github.token }}
FEEDBACK_SKIP_BOTS: '1'
FEEDBACK_SKIP_BRANCHES: 'scanner/* hive/*'
FEEDBACK_SKIP_HIVE_ORIGIN: '1'
FEEDBACK_FIRST_TIME_ONLY: '1'
run: bash src/scripts/feedback-gate.sh

feedback:
needs: gate
if: needs.gate.outputs.post == 'true'
uses: hivecommons/infra/.github/workflows/reusable-feedback.yml@f1c0b61675386f54e63c04cf07b3aa933cc963eb # hivecommons/infra main as of 2026-09-02
1 change: 1 addition & 0 deletions changelog.d/changed-17863-pr-comment-quartet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- PR comment noise: the three per-PR workflow comments that survived the hive-App reducers now post only on a finding ([#17863](https://github.com/hivecommons/hive/issues/17863)). `.github/scripts/pr-overlap.sh` creates its `<!-- hive-pr-overlap -->` comment only when a sibling PR conflicts or shares a file and, when a later push clears that, edits the existing comment to a one-line "Resolved" note instead of re-posting "no overlaps found" on every PR; `src/scripts/mutation-report.sh post` does the same for `<!-- hive-mutation -->` on a `pass` verdict (the full report, clean case included, still goes to the step summary); the "Thank you for your contribution!" merge comment (`feedback.yml`) is gated by the new `src/scripts/feedback-gate.sh` to a person's first merged PR β€” bot/App authors, `scanner/*` and `hive/*` branches, hive-origin bodies and returning contributors are skipped, with `FEEDBACK_*` workflow `env` knobs. A dashboard approval on a Prow-managed PR the hive account opened now relays `/approve` only, since a self-`/lgtm` is rebuked by Prow every time (`PullRequestApprovalEvent.LGTMSkipped`). Expected effect: roughly half of the comments on a typical merged PR.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ The dashboard renders every open issue and PR's stage as one unified tracker str
## Non-label equivalents

- **Human comments and assignees** can acknowledge hive-filed directions for #5117; assignees also affect ranking.
- **Hidden comment markers** carry state that no label does. `<!-- hive:claim ... -->` records an issue claim, `<!-- hive-finding: HASH -->` dedupes a published finding, `<!-- hive-pr-overlap -->` marks an overlap notice, `<!-- hive-question-answer -->` starts the question auto-close clock, and `<!-- hive-shared-ci-<n> -->` is stamped on the single comment a fix lane leaves on a PR it defers to shared incident `#<n>` (`DEFER_TO_INCIDENT` from `bin/hive-baseline-check.sh`), so "every PR incident `#<n>` broke" stays greppable after the fix lands ([#10441](https://github.com/hivecommons/hive/issues/10441)). One marker per PR per incident; it is never edited or removed while the incident is open. While incident `#<n>` is open, the governor records it as `deferred_incident` on the PR's `ci-failing.json` row and the kick builders keep that PR out of every CI-FAILING / FIX-BEFORE-NEW repair list, naming it only as deferred; once the incident closes the PR is listed for repair again ([#10528](https://github.com/hivecommons/hive/issues/10528)). When the incident closes (not as "not planned"), the shared-CI rerun sweep re-runs the failed jobs of each still-open PR carrying that marker β€” the newest failed, timed-out or cancelled run per workflow on the PR head β€” using the hive's own credential, then stamps `<!-- hive-shared-ci-rerun-<n> -->` and `<!-- hive-shared-ci-lifted-<n> -->` on the PR so it is re-run at most once per incident; disable with `shared_ci_rerun.enabled: false` ([#12253](https://github.com/hivecommons/hive/issues/12253)).
- **Hidden comment markers** carry state that no label does. `<!-- hive:claim ... -->` records an issue claim, `<!-- hive-finding: HASH -->` dedupes a published finding, `<!-- hive-pr-overlap -->` marks the one overlap notice a PR gets (posted only when a sibling PR conflicts or shares a file, edited down to a "Resolved" line when that clears; [#17863](https://github.com/hivecommons/hive/issues/17863)), `<!-- hive-question-answer -->` starts the question auto-close clock, and `<!-- hive-shared-ci-<n> -->` is stamped on the single comment a fix lane leaves on a PR it defers to shared incident `#<n>` (`DEFER_TO_INCIDENT` from `bin/hive-baseline-check.sh`), so "every PR incident `#<n>` broke" stays greppable after the fix lands ([#10441](https://github.com/hivecommons/hive/issues/10441)). One marker per PR per incident; it is never edited or removed while the incident is open. While incident `#<n>` is open, the governor records it as `deferred_incident` on the PR's `ci-failing.json` row and the kick builders keep that PR out of every CI-FAILING / FIX-BEFORE-NEW repair list, naming it only as deferred; once the incident closes the PR is listed for repair again ([#10528](https://github.com/hivecommons/hive/issues/10528)). When the incident closes (not as "not planned"), the shared-CI rerun sweep re-runs the failed jobs of each still-open PR carrying that marker β€” the newest failed, timed-out or cancelled run per workflow on the PR head β€” using the hive's own credential, then stamps `<!-- hive-shared-ci-rerun-<n> -->` and `<!-- hive-shared-ci-lifted-<n> -->` on the PR so it is re-run at most once per incident; disable with `shared_ci_rerun.enabled: false` ([#12253](https://github.com/hivecommons/hive/issues/12253)).
- **Paused repos** (`project.paused_repos`) stop whole-repo write/merge/enumeration paths without labels.
- **Contributor queue holds** such as active leases, cooldowns, dependencies, and quota guard holds suppress contributor offers without touching GitHub labels.
- **Jira/Linear labels** map only where the work-source adapter supports them: Linear skips held work using substring hold labels; Jira skips exact configured hold labels; GitHub Projects currently imports labels but does not use a hold gate.
Expand Down
27 changes: 26 additions & 1 deletion src/docs/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,32 @@ and exits non-zero instead of posting a possible duplicate.
`.github/scripts/test-hive-status-card.sh` and
`src/scripts/test-comment-merged-refs.sh` pin this behaviour.

### Per-PR workflow comments post only on a finding

Three workflow comments used to land on every PR regardless of outcome, and
after the runtime's own reducers they were ~70% of the comments on a merged
PR ([#17863](https://github.com/hivecommons/hive/issues/17863)). Each now
posts only when it has something to say; the full report, including the
clean case, still goes to the job's step summary:

| Workflow / script | Comment | Behaviour |
| --- | --- | --- |
| Open PR Overlap (`.github/workflows/pr-overlap.yml`, `.github/scripts/pr-overlap.sh`) | `<!-- hive-pr-overlap -->` table of conflicting / same-file open PRs | **Posts** only when at least one sibling PR conflicts or shares a file; **edits** the one marker comment in place on later pushes; when a later run finds nothing and a comment exists, **edits it** to a one-line "βœ… Resolved" note; a PR that never had an overlap gets no comment. The `conflicts-with-open-pr` label is unchanged. |
| Mutation (advisory) (`.github/workflows/mutation-advisory.yml`, `src/scripts/mutation-report.sh post`) | `<!-- hive-mutation -->` surviving / uncovered mutant report | **Posts** only for a non-`pass` verdict (`lived`, `uncovered`, `misrouted`, `error`); **edits** the one marker comment on later pushes; a later `pass` **edits** the existing comment to a one-line "βœ… Resolved" note; a PR whose every run passes gets no comment. |
| Feedback Wanted (`.github/workflows/feedback.yml` β†’ `hivecommons/infra` `reusable-feedback.yml`, gated by `src/scripts/feedback-gate.sh`) | "Thank you for your contribution! Your PR has been merged." | **Posts** only for a person's first merged PR in the repo. Skipped for `[bot]` / App authors, hive-managed head branches (`scanner/*`, `hive/*`), PR bodies carrying a `<!-- hive:` marker (hive-agent PRs on any branch, e.g. `fix-*`), and any author with another merged PR. Knobs are the workflow's `env:` (`FEEDBACK_SKIP_BOTS`, `FEEDBACK_SKIP_BRANCHES`, `FEEDBACK_SKIP_HIVE_ORIGIN`, `FEEDBACK_SKIP_LOGINS`, `FEEDBACK_FIRST_TIME_ONLY`); a failed merged-PR lookup skips the comment rather than guessing. |

`.github/scripts/test-pr-overlap.sh`, `src/scripts/test-mutation-report.sh`
and `src/scripts/test-feedback-gate.sh` pin these rules.

**Outside Hive's control.** Comments from external bots, such as Prow, tide
and kubestellar-prow, are posted by their own services and cannot be edited,
folded or skipped from this repository. Hive does not try to suppress them;
configure those bots in the project that runs them.
configure those bots in the project that runs them. For hivecommons repos
that configuration is `prow/plugins.yaml` and `prow/config.yaml` in
`kubestellar/infra` (org-wide `approve` with `require_self_approval: true`
and `lgtm` with `review_acts_as_lgtm: true`; tide requires both `lgtm` and
`approved`). What Hive does control is its own relay: a dashboard approval
on a Prow-managed PR the hive account opened posts `/approve` only, because
a `/lgtm` from the PR's own author draws Prow's "you cannot LGTM your own
PR" every time (`PullRequestApprovalEvent.LGTMSkipped`, #17863); no hive
lane reads the relayed `/lgtm`.
2 changes: 1 addition & 1 deletion src/docs/running-at-level-6.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Config keys to cross-check: `project.issue_filter.require_labels`, `project.issu
| `ci-flake` | CI/Hive scripts | Flake tracking, not an L6 hold itself. | Fix/quarantine the flake while keeping required checks meaningful. |
| `user-feedback` | Dashboard/hub | Feedback provenance. | Triage reporter input; apply trust/hold policy as needed. |
| `dco` / `no-dco` (Prow's `dco-signoff: yes|no` coexist on Prow-gated repos; the hive never adds or removes them) | Hive stage pass (commit check) | Merge-eligibility display on every managed repo. Where DCO is required (detected from required/head checks or configured via `governor.labels.stage.dco.required`), `no-dco` routes by author kind: `070` (hive/self-authored), `071` (human), or `072` (clanker); the 072 nudge includes the rebase command. On ungated repos it is informational only: the lane's stage is unchanged and no DCO rebase is requested. See [DCO routing](labels-and-control-signals/stage-labels.md#dco--no-dco--the-hive-owned-sign-off-signal). | Fix commit sign-offs (`git rebase --signoff`) rather than hand-editing labels. |
| `conflicts-with-open-pr` | PR-overlap workflow | Overlap signal. | Resolve or close conflicting work before merging; same-file overlap alone may be harmless. Two open PRs that both `Fixes` one issue are resolved by the duplicate-fix sweep without a decision: the earlier green/pending PR stays, the later hive PR is closed as `duplicate-of:<keeper>`, a person's later PR is commented on and left open ([#14799](https://github.com/hivecommons/hive/issues/14799)). |
| `conflicts-with-open-pr` | PR-overlap workflow | Overlap signal (the companion `<!-- hive-pr-overlap -->` comment appears only when there is a conflict or same-file overlap). | Resolve or close conflicting work before merging; same-file overlap alone may be harmless. Two open PRs that both `Fixes` one issue are resolved by the duplicate-fix sweep without a decision: the earlier green/pending PR stays, the later hive PR is closed as `duplicate-of:<keeper>`, a person's later PR is commented on and left open ([#14799](https://github.com/hivecommons/hive/issues/14799)). |
| `has-open-pr` | Pre-dispatch guard | An open PR already links the issue with a closing keyword; the hive skipped the claim. | Nothing β€” the label is a tracker signal, not a park; see `scanner.skip_issues_with_open_pr` in [operator-reference.md](operator-reference.md#open-pr-dispatch-guard-and-duplicate-fix-sweep-scanner). |
| `no-changelog` | Dependabot/maintainer | Repo changelog exception, not a Hive safety gate. | Apply only under repo policy. |
| `human-only` remainder text (not a default label) | Agent/reviewer | Task-list sweep can park remaining issue work as `needs-human`. | Treat as a handoff; add PR `hold` if merging must stop. |
Expand Down
Loading
Loading