Skip to content

feat: cross-agent diff review before auto-merge#37

Merged
robotlearning123 merged 4 commits intomainfrom
feat/cross-agent-review
Mar 5, 2026
Merged

feat: cross-agent diff review before auto-merge#37
robotlearning123 merged 4 commits intomainfrom
feat/cross-agent-review

Conversation

@robotlearning123
Copy link
Member

@robotlearning123 robotlearning123 commented Mar 4, 2026

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.

  • Claude codes → Codex reviews
  • Codex codes → Claude reviews
  • Generic agent → Claude reviews
  • Falls back to heuristic reviewDiff() on failure/timeout

Changes

File What
agent-runner.ts pickReviewAgent(), reviewDiffWithAgent(), parseReviewResponse(), normalizeReviewObj()
scheduler.ts Review gate in executeAndRelease() — blocks merge on rejection
types.ts ReviewResult interface, Task.review field
Tests 16 new tests (301 total)

Review process (3 rounds)

Round Issues found Fixed Key fixes
1 5 5 Greedy regex, review runs in /tmp, reduced timeout 120→60s
2 6 4 Removed unused cwd param, indexOf JSON extraction, task.error on rejection
3 8 3 ReviewResult → types.ts (sync hazard), normalizeReviewObj null-path test, scheduler catch test

Known follow-ups

Test plan

  • 301 tests pass (npm test)
  • TypeScript compiles clean (tsc --noEmit)
  • CI green (Node 20 + 22)
  • Claude Code review check passes

🤖 Generated with Claude Code

robotlearning123 and others added 4 commits March 5, 2026 12:12
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>
@robotlearning123 robotlearning123 force-pushed the feat/cross-agent-review branch from 6c0714e to bed5519 Compare March 5, 2026 17:12
@robotlearning123 robotlearning123 merged commit 0ce807d into main Mar 5, 2026
@robotlearning123 robotlearning123 deleted the feat/cross-agent-review branch March 5, 2026 17:12
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