Skip to content

fix(code-reviews): expire stale reviews#3973

Open
alex-alecu wants to merge 1 commit into
mainfrom
fix/stale-code-review-cron-cancellation
Open

fix(code-reviews): expire stale reviews#3973
alex-alecu wants to merge 1 commit into
mainfrom
fix/stale-code-review-cron-cancellation

Conversation

@alex-alecu

Copy link
Copy Markdown
Contributor

Summary

  • Stale pending and running code reviews now get cancelled by the existing cron after 75 minutes.
  • Fresh retry attempts stay active, so a new retry is not stopped just because the first review record is old.
  • The cron response now reports how many stale reviews and attempts it cancelled.

Verification

N/A (no manual verification performed).

Visual Changes

N/A

Reviewer Notes

The cron marks rows as cancelled in the database only. It does not stop an already running worker or close an external pull request check.

@kilo-code-bot

kilo-code-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The PR correctly introduces a stale-review expiry step in the dispatch cron — the CTE-based cancellation query is safe, the fresh-retry guard is correct, type definitions are consistently updated across all packages, and the race condition with in-flight workers is already handled by the existing terminal-state guard in the status callback route.

Files Reviewed (7 files)
  • apps/web/src/lib/code-reviews/db/code-reviews.ts — new cancelExpiredPendingAndRunningCodeReviews function; CTE logic looks correct
  • apps/web/src/lib/code-reviews/dispatch/dispatch-constants.ts — new CRON_STALE_CODE_REVIEW_EXPIRY_MINUTES constant and SQL helper
  • apps/web/src/lib/code-reviews/dispatch/dispatch-pending-code-review-owners.ts — orchestrator correctly calls expiry cancellation before dispatching
  • apps/web/src/lib/code-reviews/dispatch/dispatch-pending-code-review-owners.test.ts — comprehensive integration tests covering the retry-parent preservation and dispatch-window sparing logic
  • apps/web/src/app/api/cron/dispatch-pending-code-reviews/route.test.ts — updated mock to include new summary fields
  • packages/db/src/schema-types.tsdispatch_expired added to both CODE_REVIEW_TERMINAL_REASONS and CODE_REVIEW_BENIGN_TERMINAL_REASONS
  • packages/worker-utils/src/cloud-agent-next-client.tsCloudAgentTerminalReason union updated
  • services/code-review-infra/src/types.tsInternalStatusTerminalReasonSchema updated

Reviewed by claude-4.6-sonnet-20260217 · 1,122,494 tokens

Review guidance: REVIEW.md from base branch main

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.

1 participant