Repository navigation
π fix: floor empty-diff head age at created_at; date an on-base head from the merge base - #15621
Conversation
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[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 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
|
hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
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 theupdated_at-derived age;headCommitTimeis only called after them, and both call sites (automerge/automerge_sweep.go:1833behindPRChangedFilesClaimsEmpty,automerge/automerge_stage_human.go:194before the human route) are already gated, so the extraGetCommitis bounded as the body claims.DecideHiveEmptyDiffAutoCloseconsultsHeadAgelast (:113), afterDiffKnown/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_atis covered byTestEmptyDiffHeadAgeUsesHeadCommit.
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
There was a problem hiding this comment.
Looks correct to me. Read at 0221b14:
src/pkg/github/pr_empty_diff_hive_autoclose.go:201recomputesHeadAgefromheadCommitTimeonly after theChangedFiles > 0early return at:191-199, so PRs the GET payload already shows as non-empty still cost no commit fetch; the firstHeadAgeat:190only feeds thehas-diffverdict, where age is irrelevant.headCommitTime(:244-255) returns the zero time on empty SHA, API error or nil commit, andemptyDiffHeadAge(:259-267) falls through zero βupdated_atβcreated_at, so the documented fallback chain is preserved.stringswas already imported.DecideHiveEmptyDiffAutoClose(:113) still checksHeadAgelast, after the hive-authored / held / level guards.TestEmptyDiffHeadAgeUsesHeadCommitcovers both the commit-date path and theupdated_atfallback.
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
|
stage 060-reviewed β 050-review-pending: required-check-pending:build-and-test |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
|
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.
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-431onv5) measures fromupdated_at, which labels and comments bump β that is the #15603 bug. The new version prefers the compare'sheadAt, falls back toupdated_at, then takesmax(at, created_at). Sincecreated_at <= updated_atalways, the first call atcloseHiveRedundantPR(: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...headlists no commits, so todayheadAtstays zero and:328skips the override, leaving theupdated_atage in place. The newmerge_base_commit.sha == headcheck is the right discriminator β GitHub's compare returns the head itself as merge base when status isbehind/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-330preserves the old behaviour whenheadAtis zero (falls through toupdated_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
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> # Conflicts: # src/pkg/github/pr_empty_diff_hive_autoclose_test.go
|
hive/awaiting-ci: merged origin/v5 to clear the conflict (kept both new tests); CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
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): whenbase...headlists no commits andmerge_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. TheEqualFoldguard means an unrelated empty compare (merge base β head) still falls through toupdated_atrather than borrowing a wrong date.emptyDiffHeadAge(:430-440): the floor only ever raisesattocreated_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:334path recomputing with a zeroheadAtyields the same value as:311, so nothing regresses when the compare returns no date.- Tests cover the four branches (commit date,
updated_atfallback, floor, no timestamps) and the on-base merge-base case via anhttptestcompare 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
There was a problem hiding this comment.
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'sheadAt, falls back toupdated_at, then floors atcreated_at. Composed withf.HeadAge < EmptyDiffMinHeadAge && !f.ReviewerConfirmedat 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): whenbase...headlists no commits andmerge_base_commit.sha == head, the merge base is the head, so its committer date is the right stand-in; theEqualFoldguard keeps a genuinely diverged-but-empty compare on the oldupdated_atpath. The droppedGetCommitround-trip is not needed for this.TestEmptyDiffHeadAgeFlooredAtCreatedAtandTestPRDiffAgainstBaseHeadOnBaseUsesMergeBaseDatecover 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
|
stage 100-merge-queue β 060-reviewed: check-pending |
|
stage 060-reviewed β 050-review-pending: required-check-pending:build-and-test |
There was a problem hiding this comment.
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
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
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/adopt-*copy) was eligible on the first sweep.emptyDiffHeadAgenow floors the age at the PR'screated_at, matching the merge gate'sHeadCommitPushedAtconvention.base...headlists no commits (the exact empty-diff supersession case) the compare carried no commit date and the age fell back to the label/comment-bumpedupdated_atβ the Review backlog (correctness): Empty-diff head age measured from updated_at, not head commitΒ #15603 bug. The compare'smerge_base_commitis the head in that case, so its committer date is used. No extra REST call: the earlierGetCommitround-trip is gone (Review backlog (style): Prior correctness note still present: head-commit fetch precedes the compareΒ #15630).β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88
Closes #15630