Skip to content

feat(#85): bounded re-dispatch with review feedback on request_changes - #149

Merged
georgenijo merged 2 commits into
mainfrom
feat/85-redispatch
Jun 29, 2026
Merged

georgenijo merged 2 commits into
mainfrom
feat/85-redispatch

Conversation

@georgenijo

@georgenijo georgenijo commented Jun 29, 2026 •

Copy link
Copy Markdown
Owner

Closes #85.

Built by the dogfood mesh (Sonnet worker); the in-mesh Opus reviewer returned request_changes with a sharp, correct catch (retry budget inferred from ReviewFeedback=="" loops unboundedly when notes are empty). Director applied the reviewer's suggested fix + a regression test, then merged. (#85's own auto-redispatch isn't on main yet to self-heal this — bootstrap.)

What

  • MESH_REVIEW_RETRIES (default 2): on request_changes, the scheduler re-dispatches the same task with the reviewer's notes as feedback, on the existing branch, up to N times; only fails after exhausting retries (or on reject).
  • Worker: branch-aware worktree re-allocation + review feedback injected into the prompt.
  • Reviewer-caught fix: dedicated Record.Redispatched flag for first-dispatch detection (not feedback-emptiness) → budget always decrements. Regression test TestReviewRetriesExhaustedWithEmptyNotes.

Verification

gofmt clean · go build ./... · go vet ./... · go test ./internal/... green.

🤖 Generated with Claude Code


Note

Medium Risk
Changes review-gate terminal behavior and task state machine (running→pending via Redispatch); bounded by tests but affects job success/failure and extra worker/review LLM spend.

Overview
Adds MESH_REVIEW_RETRIES (default 2, 0 = fail immediately) so a request_changes review no longer always fails the task. The scheduler can re-dispatch the same task up to N times with reviewer notes as ReviewFeedback, on the existing worker branch so prior commits accumulate.

Scheduler splits request_changes from reject: handleRequestChanges uses persisted RetriesLeft and Redispatched (not empty feedback) to bound retries, then task.Store.Redispatch moves running → pending. Worker checks out an existing branch via addWorktreeFromBranch and injects feedback into the prompt.

Includes config/coordinator wiring, TestLoadReviewRetriesKnob, and review-gate tests including a regression for empty reviewer notes (unbounded retry trap).

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

georgenijo and others added 2 commits June 29, 2026 13:28
When a reviewer returns request_changes and retries remain (MESH_REVIEW_RETRIES,
default 2), the scheduler re-dispatches the task instead of failing it. The
re-dispatched worker continues on the task's existing branch (prior commits
accumulate) and receives the reviewer's notes injected into its prompt.

- task.Record: add RetriesLeft int + ReviewFeedback string (persisted on KV)
- task.Store.Redispatch: atomic running→pending with feedback + counter update
- scheduler.Options.ReviewRetries: wired from config.ReviewRetries
- handleReview: request_changes routes to handleRequestChanges; approve→done,
  reject→failed, error unchanged; retries exhausted request_changes→failed
- worker.Spawn: when rec.Branch != "" (re-dispatch) checks out the existing
  branch via addWorktreeFromBranch so prior commits survive
- worker.buildPrompt: injects "A reviewer requested changes..." when ReviewFeedback set
- config: MESH_REVIEW_RETRIES (non-negative int, default 2)
- coordinator: wires ReviewRetries into scheduler.Options

Tests: TestReviewRequestChangesRedispatchesWithFeedback (re-dispatch + feedback
injection), TestReviewRetriesExhaustedFailsTask (exhaustion after RETRIES
re-dispatches), TestReviewRequestChangesFailsTaskWhenRetriesZero (opt-out),
TestLoadReviewRetriesKnob (config parsing).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewer caught: ReviewFeedback=="" as the first-dispatch sentinel loops
unboundedly when a reviewer returns request_changes with empty notes. Add a
dedicated Record.Redispatched flag (set in Store.Redispatch), key the budget
init off it, and add TestReviewRetriesExhaustedWithEmptyNotes as a regression.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Jun 29, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_7b58c3bb-5fa0-4b26-ab80-a5195bee3794)

@georgenijo
georgenijo merged commit cf4a194 into main Jun 29, 2026
2 checks passed
@georgenijo
georgenijo deleted the feat/85-redispatch branch June 29, 2026 17:36
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@georgenijo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9d1332e-0454-4dd2-86f0-b2e21c23e9be

📥 Commits

Reviewing files that changed from the base of the PR and between 9e63809 and c5ed216.

📒 Files selected for processing (8)
  • internal/config/config.go
  • internal/config/config_test.go
  • internal/coordinator/coordinator.go
  • internal/scheduler/review_gate_test.go
  • internal/scheduler/scheduler.go
  • internal/task/task.go
  • internal/task/transition.go
  • internal/worker/worker.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/85-redispatch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[worker] Bounded re-dispatch with review feedback on request_changes

1 participant