feat: cross-agent diff review before auto-merge#37
Merged
robotlearning123 merged 4 commits intomainfrom Mar 5, 2026
Merged
Conversation
This was referenced Mar 4, 2026
When a coding agent completes a task successfully, spawn a different agent to review the git diff before merging to main. Claude codes → Codex reviews, Codex codes → Claude reviews. - Add reviewDiffWithAgent() to AgentRunner with structured JSON prompt - Add pickReviewAgent() for cross-agent selection logic - Add parseReviewResponse() with non-greedy regex for robust JSON extraction - Insert review gate in scheduler's executeAndRelease() between task success and pool.release(merge) - Review runs in /tmp to prevent reviewer from modifying the worktree - Falls back to heuristic reviewDiff() if agent fails or times out - Add ReviewResult.approve field to gate merge decisions - Add task.review field to persist review results - 14 new tests (299 total, 0 failures) Closes #37 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unused `cwd` param from reviewDiffWithAgent() - Fix JSON extraction: use indexOf/lastIndexOf instead of regex (handles braces in strings correctly) - Add task.error message when review rejects merge - Add review_started event assertions to scheduler tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract duplicated JSON normalisation into normalizeReviewObj() - Add reviewAgent field to ReviewResult so consumers know which agent reviewed - Update Task.review type to include reviewAgent Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move ReviewResult interface to types.ts (single source of truth) - Task.review now references ReviewResult instead of inline duplicate - Re-export ReviewResult from agent-runner.ts for backward compat - Add test: normalizeReviewObj returns null for missing/wrong-type fields - Add test: scheduler catch block when reviewDiffWithAgent throws Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6c0714e to
bed5519
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cross-agent diff review gate: when a coding agent completes a task, spawn a different agent to review the git diff before auto-merging.
reviewDiff()on failure/timeoutChanges
agent-runner.tspickReviewAgent(),reviewDiffWithAgent(),parseReviewResponse(),normalizeReviewObj()scheduler.tsexecuteAndRelease()— blocks merge on rejectiontypes.tsReviewResultinterface,Task.reviewfieldReview process (3 rounds)
cwdparam, indexOf JSON extraction, task.error on rejectionKnown follow-ups
task.reviewto SQLitegetRunningTasks()Test plan
npm test)tsc --noEmit)🤖 Generated with Claude Code