Skip to content

fix: make is_valid_issue close-window directional#680

Merged
anderdc merged 4 commits intoentrius:testfrom
plind-junior:fix/is-valid-issue-directional-window
Apr 21, 2026
Merged

fix: make is_valid_issue close-window directional#680
anderdc merged 4 commits intoentrius:testfrom
plind-junior:fix/is-valid-issue-directional-window

Conversation

@plind-junior
Copy link
Copy Markdown
Contributor

The previous abs() check accepted issues closed up to 24h BEFORE the PR merged. GitHub's closingIssuesReferences is keyword-parsed from the PR body and still returns references to already-closed issues, so an unrelated PR could add Closes #N pointing to an issue someone else just closed, pass every is_valid_issue gate, and inherit the 1.33x / 1.66x multiplier.

Require issue.closed_at >= pr.merged_at - 60s (clock-skew buffer) and <= pr.merged_at + 1d. The legitimate auto-close case (issue closes at or just after merge) still passes; the "already closed by unrelated work" case is rejected.

Fixes #676

The previous abs() check accepted issues closed up to 24h BEFORE the PR
merged. GitHub's closingIssuesReferences is keyword-parsed from the PR
body and still returns references to already-closed issues, so an
unrelated PR could add `Closes #N` pointing to an issue someone else
just closed, pass every is_valid_issue gate, and inherit the 1.33x /
1.66x multiplier.

Require issue.closed_at >= pr.merged_at - 60s (clock-skew buffer) and
<= pr.merged_at + 1d. The legitimate auto-close case (issue closes at
or just after merge) still passes; the "already closed by unrelated
work" case is rejected.
@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 21, 2026

Fix is correct but over-engineered. Should be a one-liner:

if days_diff > MAX_ISSUE_CLOSE_WINDOW_DAYS or days_diff < 0:

Just drop abs() and add < 0. Skip the new ISSUE_CLOSE_CLOCK_SKEW_SECONDS constant — GitHub's merge auto-close timestamps are tightly coupled; the buffer solves a problem that doesn't exist.

Tests: 6 separate functions for one boolean check is too much. Either parametrize into a single test or edit the existing close-window assertion in tests/validator/test_is_valid_issue.py. Don't add a new file.

@plind-junior
Copy link
Copy Markdown
Contributor Author

Thanks for your review @anderdc
Made an update by following your suggestion

Drop the ISSUE_CLOSE_CLOCK_SKEW_SECONDS buffer; GitHub's merge-and-auto-close
writes both timestamps in the same transaction, so the skew case is not real.
The directional check collapses to a one-liner.

Fold close-window coverage into tests/validator/test_is_valid_issue.py as a
parametrized class instead of a dedicated file.
@anderdc anderdc merged commit db585db into entrius:test Apr 21, 2026
3 checks passed
plind-junior added a commit to plind-junior/gittensor that referenced this pull request Apr 22, 2026
…us#680

Tests set closed_at before merged_at, which entrius#680 now treats as invalid.
Flipping the hour offset matches GitHub's real behavior (closing-keyword
PRs close linked issues at or after merge time).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] is_valid_issue close-window uses abs()

2 participants