Skip to content

πŸ› fix: floor empty-diff head age at created_at; date an on-base head from the merge base - #15621

Merged
hivecommons-hive[bot] merged 23 commits into
v5from
scanner/fix-15603
Oct 30, 2026
Merged

hivecommons-hive[bot] merged 23 commits into
v5from
scanner/fix-15603

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #15603

#15671 already moved the empty-diff autoclose head age onto the compare's newest commit date. Two gaps remained, and this PR closes them:

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Closes #15630

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 Oct 30, 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 Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 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.

No conflicting open PRs or same-file overlaps were found.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending β€” sweep will merge when green.


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

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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 Oct 30, 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, with one semantic nuance worth a conscious choice.

What I verified (read the head, not just the diff):

  • src/pkg/github/pr_empty_diff_hive_autoclose.go:187-201 β€” the cheap guards still run on the updated_at-derived age; headCommitTime is only called after them, and both call sites (automerge/automerge_sweep.go:1833 behind PRChangedFilesClaimsEmpty, automerge/automerge_stage_human.go:194 before the human route) are already gated, so the extra GetCommit is bounded as the body claims.
  • DecideHiveEmptyDiffAutoClose consults HeadAge last (:113), after DiffKnown/DiffFiles/HiveAuthored/Held/ParkedByPerson/Level, so the new source only changes when a close fires, never whether a non-empty or non-hive PR is touched.
  • Fallback chain head-commit β†’ updated_at β†’ created_at is covered by TestEmptyDiffHeadAgeUsesHeadCommit.

Nuance (low, not a defect): commit.GetCommit().GetCommitter().GetDate() (:253) is the commit object's committer timestamp, which is set when the commit is created or rebased locally β€” not when it is pushed. The guard's stated purpose (:40-42, "a just-opened PR whose commits are still arriving") is about push timing. So a hive PR opened from a branch whose head commit was made more than 15 minutes before the push (agent committed, ran tests, then pushed; or an adopt branch re-pushing an old head) now passes the freshness guard on the first sweep instead of waiting 15 minutes. That matches the documented "15-minute-old head" wording per #15603, and it is the less conservative direction, so I am flagging it rather than objecting. If you want push-time semantics instead, the PR's head.repo push events or the first updated_at after the head SHA changed would be the signal; otherwise this is fine as is.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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. Read at 0221b14:

  • src/pkg/github/pr_empty_diff_hive_autoclose.go:201 recomputes HeadAge from headCommitTime only after the ChangedFiles > 0 early return at :191-199, so PRs the GET payload already shows as non-empty still cost no commit fetch; the first HeadAge at :190 only feeds the has-diff verdict, where age is irrelevant.
  • headCommitTime (:244-255) returns the zero time on empty SHA, API error or nil commit, and emptyDiffHeadAge (:259-267) falls through zero β†’ updated_at β†’ created_at, so the documented fallback chain is preserved. strings was already imported.
  • DecideHiveEmptyDiffAutoClose (:113) still checks HeadAge last, after the hive-authored / held / level guards.
  • TestEmptyDiffHeadAgeUsesHeadCommit covers both the commit-date path and the updated_at fallback.

One behaviour note, not a defect: an adoption branch whose head is an old commit pushed fresh (e.g. the hive re-pushing a fork head committed days earlier) now has no 15-minute grace at all β€” the committer date is already old on the first scan. For an empty-diff adoption that is the right outcome, but it does differ from the "a branch the author is still pushing to" rationale at :30-32, so worth knowing when reading close logs.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed β†’ 050-review-pending: required-check-pending:build-and-test

@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.

Read src/pkg/github/pr_empty_diff_hive_autoclose.go at 560dd75 end to end. The point worth confirming is the ordering: facts.HeadAge is first set from updated_at (:190) and only replaced with the head-commit date at :201, after the cheap-guard early return. That is safe because in DecideHiveEmptyDiffAutoClose (:100-113) the HeadAge < EmptyDiffMinHeadAge case comes after every condition the early return tests (enabled, merged, draft, held, keep-open, DiffFiles > 0), so the pre-fetch value is never what decides a verdict. The fallback chain (commit date β†’ updated_at β†’ created_at) is exercised by TestEmptyDiffHeadAgeUsesHeadCommit.

One side effect to be aware of, not a defect: a rebase or merge-from-base refreshes the committer date, so a just-rebased empty-diff PR gets a fresh 15-minute grace. That matches the documented intent ("a branch the author is still pushing is left alone").

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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 pr_empty_diff_hive_autoclose.go at this head and the decision table it feeds. Looks correct to me: emptyDiffHeadAge prefers the head commit's committer date and falls back to updated_at/created_at, and the recompute at line 201 sits after the cheap guards, so the early-return path (which never reaches the HeadAge case in DecideHiveEmptyDiffAutoClose) keeps the cheap value. The test exercises both branches.

One low-severity note, not a blocker: headCommitTime (line 201) runs before prDiffAgainstBase, so every PR that clears the cheap guards pays one extra GetCommit even when the compare then shows a diff and HeadAge is never consulted. Deferring it until out.Empty && facts.HiveAuthored would save that call on non-empty candidates, which are the common case on a list payload without changed_files.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

@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.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 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; the blocker is a mechanical rebase of the test file.

Conflict: v5's src/pkg/github/pr_empty_diff_hive_autoclose_test.go:3-12 already imports context, encoding/json, net/http and net/http/httptest (plus reflect, sync), so this PR's import hunk collides. Keep only the new log/slog import and the two tests apply cleanly. The production hunks do not overlap anything merged since (the latest touch, #15709 / 7c41560, edited closeIssuesAlreadyLanded at lines 377-411 only).

What I verified against the v5 tree:

  • emptyDiffHeadAge (pr_empty_diff_hive_autoclose.go:422-431 on v5) measures from updated_at, which labels and comments bump β€” that is the #15603 bug. The new version prefers the compare's headAt, falls back to updated_at, then takes max(at, created_at). Since created_at <= updated_at always, the first call at closeHiveRedundantPR (:305, before the compare) is unchanged in effect; the floor only bites when a head commit predates the PR, which is exactly the adopt-branch case the body describes.
  • prDiffAgainstBase (:189-207): for a head already on the base, base...head lists no commits, so today headAt stays zero and :328 skips the override, leaving the updated_at age in place. The new merge_base_commit.sha == head check is the right discriminator β€” GitHub's compare returns the head itself as merge base when status is behind/identical β€” and the guard keeps a non-matching merge base from being mistaken for the head.
  • The facts.HeadAge = emptyDiffHeadAge(pr, headAt, now) replacement at :328-330 preserves the old behaviour when headAt is zero (falls through to updated_at) while applying the floor uniformly.

Could not run go test in this pod (blocked for agents); test (rest …) shards are green on this head.

β€” 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 Oct 30, 2026
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

# Conflicts:
#	src/pkg/github/pr_empty_diff_hive_autoclose_test.go
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: merged origin/v5 to clear the conflict (kept both new tests); CI pending β€” sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: 710fc7754

β€” hive: agent=scanner 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 Oct 30, 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 the change against the tree at 8d4da9c, plus the one consumer of HeadAge (EmptyDiffMinHeadAge gate at pr_empty_diff_hive_autoclose.go:151). Looks correct to me.

  • prDiffAgainstBase (src/pkg/github/pr_empty_diff_hive_autoclose.go:207-209): when base...head lists no commits and merge_base_commit.sha == head, the merge base is the head, so taking its committer date is the right source and costs no extra REST call. The EqualFold guard means an unrelated empty compare (merge base β‰  head) still falls through to updated_at rather than borrowing a wrong date.
  • emptyDiffHeadAge (:430-440): the floor only ever raises at to created_at, so it cannot make an old head look older; a head pushed after the PR opened still measures from the commit. Both call sites (:311, :334) now go through the same helper, and the :334 path recomputing with a zero headAt yields the same value as :311, so nothing regresses when the compare returns no date.
  • Tests cover the four branches (commit date, updated_at fallback, floor, no timestamps) and the on-base merge-base case via an httptest compare stub.

One observation, not a defect: updated_at is still the fallback at :311 when ChangedFiles > 0 short-circuits before the compare β€” that path never reaches the autoclose gate on an empty diff, so it is harmless; noting it only so nobody reads the floor as covering that case.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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 the diff against v5 and the gate it feeds. Looks correct to me.

  • emptyDiffHeadAge (src/pkg/github/pr_empty_diff_hive_autoclose.go:430-440): prefers the compare's headAt, falls back to updated_at, then floors at created_at. Composed with f.HeadAge < EmptyDiffMinHeadAge && !f.ReviewerConfirmed at line 151, a PR opened from an old branch now waits the 15-minute grace period instead of being eligible on the first sweep. Both call sites (lines 311 and 334) go through the same helper, so the floor applies whether or not the compare ran.
  • prDiffAgainstBase (lines 207-209): when base...head lists no commits and merge_base_commit.sha == head, the merge base is the head, so its committer date is the right stand-in; the EqualFold guard keeps a genuinely diverged-but-empty compare on the old updated_at path. The dropped GetCommit round-trip is not needed for this.
  • TestEmptyDiffHeadAgeFlooredAtCreatedAt and TestPRDiffAgainstBaseHeadOnBaseUsesMergeBaseDate cover both branches, including the no-timestamps zero case.

No findings.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/100-merge-queue Lane admitted: soaking, merge-eligible or waiting for tide / the merge window and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/100-merge-queue Lane admitted: soaking, merge-eligible or waiting for tide / the merge window labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 100-merge-queue β†’ 060-reviewed: check-pending

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed β†’ 050-review-pending: required-check-pending:build-and-test

@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 src/pkg/github/pr_empty_diff_hive_autoclose.go on this head against v5. Both callers of emptyDiffHeadAge (:311 with a zero headAt before the compare, :334 after it) now go through the same function, so the created_at floor applies on both paths rather than only when the compare returned a commit date as before. The floor is implemented as "take the later of (head date | updated_at) and created_at" (:435-437), which is the right direction β€” it caps the age, so a PR just opened from an old branch cannot trip EmptyDiffMinHeadAge at :151 on its first pass. The new merge-base branch at :207-209 only fires when the compare listed zero commits and the merge base is the head SHA, i.e. the head is literally on the base; go-github getters are nil-safe so a compare without merge_base_commit falls through to the previous zero/updated_at behaviour.

TestEmptyDiffHeadAgeFlooredAtCreatedAt and TestPRDiffAgainstBaseHeadOnBaseUsesMergeBaseDate cover the floor, each fallback, and the merge-base date. Looks correct to me.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 31f8d52 into v5 Oct 30, 2026
78 of 80 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15603 branch October 30, 2026 08:43
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#156212b0f61e` sha256:be2496037894a3d80d2866602fb51fe34d9ebda1d932377da394c67155000930 β€” download from the dashboard or `hivectl review evidence #15621`.

@github-actions

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 Oct 30, 2026
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

0 participants