Skip to content

Base sheriff stale clock on blocker age#364

Merged
pbakaus merged 1 commit into
mainfrom
codex/sheriff-blocker-age
Jul 10, 2026
Merged

Base sheriff stale clock on blocker age#364
pbakaus merged 1 commit into
mainfrom
codex/sheriff-blocker-age

Conversation

@pbakaus

@pbakaus pbakaus commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Start the sheriff stale clock from the latest contributor-action blocker, not from PR creation.
  • Require sheriff warning markers to be newer than the current blocker before allowing auto-close.
  • Update stale warning/close copy to describe days waiting on contributor action instead of days open.

Why

On #307, a maintainer requested changes on an old PR and the sheriff warned the contributor less than a day later because the PR itself was old. The contributor should get a real response window after fresh maintainer feedback.

Validation


Note

Medium Risk
Changes automated PR labeling, warnings, and auto-close behavior for all open PRs; incorrect blocker or marker logic could wrongly warn/close or leave stale PRs unmanaged, mitigated by broad test coverage.

Overview
Sheriff stale warn/close timing now uses days waiting on contributor action (waitingDays) from the latest contributor-action blocker (draft start, requested changes, unresolved threads, /sheriff wait, etc.), not total PR age—so fresh maintainer feedback on an old PR does not trigger an immediate stale warning.

Warning and auto-close gating no longer treats the stale label as proof a warning was posted. Only trusted marker comments (default github-actions / github-actions[bot]) count, and a warning must be newer than the current blocker before auto-close is allowed. Stale copy and projected close dates are anchored on the blocker timestamp plus closeDays.

Data loading paginates full issue comment history before evaluation (GraphQL comments(last: 50) is only a seed), adds draft timeline events for when draft waiting started, and splits label vs draft timeline slices in the GraphQL query. Tests cover hydration, untrusted markers, draft transitions, and the #307-style scenario.

Reviewed by Cursor Bugbot for commit 9ffb055. Bugbot is set up for automated code reviews on this repo. Configure here.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploying impeccable with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9ffb055
Status: ✅  Deploy successful!
Preview URL: https://8e3a2bb0.impeccable-2rv.pages.dev
Branch Preview URL: https://codex-sheriff-blocker-age.impeccable-2rv.pages.dev

View logs

@pbakaus pbakaus marked this pull request as ready for review July 10, 2026 17:04
Copilot AI review requested due to automatic review settings July 10, 2026 17:04
Comment thread scripts/github/sheriff.mjs Outdated
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates the GitHub sheriff bot to measure stale PR handling from contributor-action blocker age. The main changes are:

  • Stale warning and close decisions now use waitingDays instead of total days open.
  • Auto-close now requires a trusted warning marker newer than the current blocker.
  • Issue comments are fully hydrated before evaluation so older sheriff markers are included.
  • Draft and label timeline events are normalized from separate GraphQL timeline slices.
  • Tests cover blocker-age timing, trusted markers, comment hydration, and draft transition behavior.

Confidence Score: 5/5

Safe to merge with low risk.

The changes are localized to sheriff stale-state calculation and include focused tests for the main edge cases.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The focused sheriff tests completed successfully with 35 pass and 0 fail.
  • The sheriff syntax check completed successfully with exit code 0.
  • The test suite registry check completed successfully with 3 pass and 0 fail.
  • The diff check completed successfully with no issues (git diff --check exited 0).
  • The core test run failed due to missing generated hook artifacts after sheriff tests passed, and the sheriff live dry run was blocked because gh auth status reports no logged-in GitHub hosts.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
scripts/github/sheriff.mjs Updates sheriff stale evaluation to use contributor-action blocker age, hydrate full issue comments for trusted markers, and separate draft/label timeline normalization.
tests/github-sheriff.test.mjs Adds tests for blocker-age stale timing, trusted marker handling, full comment hydration, and draft transition clocks.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
  participant Workflow as Sheriff workflow
  participant GH as GitHub API
  participant Eval as evaluatePullRequest
  participant PR as Pull request

  Workflow->>GH: Fetch open PRs with labels, comments seed, reviews, timeline slices
  Workflow->>GH: Hydrate full issue comments
  Workflow->>Eval: Normalize PR and evaluate
  Eval->>Eval: Find latest contributor-action blocker
  Eval->>Eval: Compute waitingDays from blocker age
  Eval->>Eval: Check trusted warning/close markers
  Eval-->>Workflow: Plan labels, warning, close
  Workflow->>PR: Apply labels/comments/close when --apply
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
  participant Workflow as Sheriff workflow
  participant GH as GitHub API
  participant Eval as evaluatePullRequest
  participant PR as Pull request

  Workflow->>GH: Fetch open PRs with labels, comments seed, reviews, timeline slices
  Workflow->>GH: Hydrate full issue comments
  Workflow->>Eval: Normalize PR and evaluate
  Eval->>Eval: Find latest contributor-action blocker
  Eval->>Eval: Compute waitingDays from blocker age
  Eval->>Eval: Check trusted warning/close markers
  Eval-->>Workflow: Plan labels, warning, close
  Workflow->>PR: Apply labels/comments/close when --apply
Loading

Reviews (5): Last reviewed commit: "Base sheriff stale clock on blocker age" | Re-trigger Greptile

Comment thread scripts/github/sheriff.mjs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the GitHub “sheriff” automation so stale warnings/auto-close timing is based on how long a PR has been waiting on contributor action, rather than how long the PR has been open, preventing immediate warnings after fresh maintainer feedback.

Changes:

  • Compute and expose waitingDays based on the most recent contributor-action blocker timestamp.
  • Gate auto-close on a sheriff warning marker that is newer than the current blocker (not just the stale label).
  • Update stale warning/close comment copy to describe “days waiting on contributor action”.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scripts/github/sheriff.mjs Re-bases stale/warn/close logic on blocker age (waitingDays) and updates marker gating + message copy.
tests/github-sheriff.test.mjs Updates existing tests and adds new scenarios covering the new waiting-days and marker-recency behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/github/sheriff.mjs
Comment thread scripts/github/sheriff.mjs Outdated
Comment thread scripts/github/sheriff.mjs Outdated
Comment thread scripts/github/sheriff.mjs Outdated
@pbakaus pbakaus force-pushed the codex/sheriff-blocker-age branch 2 times, most recently from 1f2a880 to 85a918f Compare July 10, 2026 17:13
Comment thread scripts/github/sheriff.mjs Outdated
@pbakaus pbakaus force-pushed the codex/sheriff-blocker-age branch from 85a918f to 63a13f6 Compare July 10, 2026 17:20

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 63a13f6. Configure here.

Comment thread scripts/github/sheriff.mjs Outdated
@pbakaus pbakaus force-pushed the codex/sheriff-blocker-age branch from 63a13f6 to 0bdc3b3 Compare July 10, 2026 17:24
@pbakaus pbakaus force-pushed the codex/sheriff-blocker-age branch from 0bdc3b3 to 9ffb055 Compare July 10, 2026 17:30
@pbakaus pbakaus merged commit 630fc26 into main Jul 10, 2026
13 checks passed
@pbakaus pbakaus deleted the codex/sheriff-blocker-age branch July 10, 2026 19:02
mp3wizard added a commit to mp3wizard/impeccable that referenced this pull request Jul 15, 2026
New upstream features:
- Fix light-mode command demo contrast (pbakaus#370)
- chore(deps): bump bun-minor-and-patch group ×10 (pbakaus#368)
- Base sheriff stale clock on blocker age (pbakaus#364)

Security findings: 0 secrets, 0 dependency CVEs, 0 Semgrep findings. mcps-audit 1360 findings reviewed as heuristic false positives (execSync/delete/join idioms), consistent with prior cycles.
Security fixes: none required; bun.lock re-synced after upstream dep bump.
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.

2 participants