fix(heartbeat): serialize same-PR review dispatch - #1014
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Hey @kkroo! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: 4f01596
Important Issues (1)
- [gstack/review]
server/src/services/heartbeat.ts:18875— Same-PR serialization is scoped only to one agent.runningRunRowscomes fromlistRunningRunsForAgent(agentId), so if the configured reviewer pool or agent eligibility changes while reviewer A still has this PR running,findActivePrReviewerForTaskcan assign the follow-up to reviewer B and B will not see A’s in-flight task key.- Enforce the task-key exclusion across the reviewer pool with an atomic DB-backed lease/claim (or query all running PR-review task keys across eligible/configured reviewers inside the serialized claim path), and add a regression test with the running review and queued follow-up assigned to different agents.
Strengths
- The in-memory task-key set is updated after each successful claim, preventing duplicate same-pass dispatches on one agent.
- Different PR task keys continue to use available concurrency, and the regression test covers that behavior.
Recommended Action
- Address the cross-agent serialization gap before merge.
|
Hey @kkroo! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: e3d3bf0
Prior Findings Dispositioned (1)
- prior:4f01596 important 1 — fixed —
server/src/services/pr-review-dispatch-lock.ts:27— The final claim now takes a transaction-scoped advisory lock keyed by the PR task and checks all running heartbeat rows, independent of reviewer identity, before either claim path transitions the queued run.
Looks good. The shared lock closes the cross-reviewer dispatch race while preserving queued follow-ups and unrelated review concurrency.
Strengths
- The advisory lock and running-row check share the same transaction as the queued-to-running transition, eliminating the check-then-act window.
- Regression coverage exercises an existing owner on another reviewer and simultaneous claims by two reviewers.
Recommended Action
- Merge after required CI checks pass.
allyblockcast
left a comment
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: e3d3bf0
Prior Findings Dispositioned (1)
- prior:4f01596 important 1 — fixed —
server/src/services/pr-review-dispatch-lock.ts:27— The final claim now takes a transaction-scoped advisory lock keyed by the PR task and checks all running heartbeat rows, independent of reviewer identity, before either claim path transitions the queued run.
Looks good. The shared lock closes the cross-reviewer dispatch race while preserving queued follow-ups and unrelated review concurrency.
Strengths
- The advisory lock and running-row check share the same transaction as the queued-to-running transition, eliminating the check-then-act window.
- Regression coverage exercises an existing owner on another reviewer and simultaneous claims by two reviewers.
Recommended Action
- Merge after required CI checks pass.
Summary
context_task_keyis already runningRoot cause
Direct GitHub reviewer wakes are issue-less. The dispatcher deduplicated only
context_issue_id, so a second wake for the samepr_review:<repo>:<number>task could be claimed while the first review was still running. Production showed duplicate running reviews for PRs 1987 and 2013 after the concurrency rollout.Validation
pnpm exec vitest run server/src/__tests__/heartbeat-dispatch-priority-sort.test.ts -t "keeps a same-PR review follow-up queued"pnpm --filter @paperclipai/server typecheckgit diff --check