Skip to content

feat(unic-pr-review): align code-simplifier with toolkit two-phase post-pass model#220

Open
orioltf wants to merge 3 commits into
developfrom
archon/task-feature-unic-pr-review-216-two-phase-code-simplifi
Open

feat(unic-pr-review): align code-simplifier with toolkit two-phase post-pass model#220
orioltf wants to merge 3 commits into
developfrom
archon/task-feature-unic-pr-review-216-two-phase-code-simplifi

Conversation

@orioltf
Copy link
Copy Markdown
Member

@orioltf orioltf commented Jun 5, 2026

Summary

Adopts the two-phase post-pass model from pr-review-toolkit for code-simplifier:

  • Phase 1 runs Review Aspect agents in parallel (unchanged): code-reviewer, silent-failure-hunter, type-design-analyzer, pr-test-analyzer, comment-analyzer
  • Phase 2 runs code-simplifier sequentially — only when Phase 1 has zero Critical/Important findings AND ≥3 non-test source files changed

Previously code-simplifier was included in the Phase 1 parallel fan-out, producing misleading "polish" suggestions on code that still had real correctness problems.

Changes

  • scripts/lib/changed-file-analyser.mjs — remove code-simplifier from SPAWN_TABLE; export shouldRunPhase2(changedFiles, findings) pure-function gate
  • commands/review-pr.md — add Phase 2 gate call after Phase 1 fan-out in Pre-PR (Step 7), ADO (Step 1.8), and re-review modes
  • tests/changed-file-analyser.test.mjs — add shouldRunPhase2 test suite (12 cases covering all canonical AC scenarios); assert code-simplifier absent from all decideSpawnSet outputs
  • docs/adr/0013-two-phase-code-simplifier.md — new ADR recording the two-phase decision, gate definition, and interaction with ADR-0002/0003/0007
  • CHANGELOG.md — v2.1.3 entry

Validation

Check Result
pnpm --filter unic-pr-review typecheck ✅ 0 errors
pnpm --filter unic-pr-review test ✅ 526 passed, 0 failed
pnpm -w run check (Biome + Prettier) ✅ exit 0
pnpm --filter unic-pr-review verify:changelog ✅ exit 0

Architecture

Phase 1 (parallel):
  code-reviewer | silent-failure-hunter | type-design-analyzer
  pr-test-analyzer | comment-analyzer
        │
        ▼ shouldRunPhase2(changedFiles, phase1Findings)
        │ = no Critical/Important AND ≥3 source files
        │
  true ─┤─ false (skip)
        ▼
  code-simplifier  ← Phase 2 sequential post-pass

Fixes #216

orioltf and others added 3 commits June 5, 2026 17:21
…st-pass model

Remove code-simplifier from the Phase 1 parallel fan-out and run it as a
Phase 2 post-pass only when Phase 1 yields no Critical/Important findings and
≥3 non-test source files changed (ADR-0013). Exports shouldRunPhase2() from
changed-file-analyser.mjs so the gate is unit-testable; adds 12 new tests
covering the three canonical AC scenarios plus edge cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ase2

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a two-phase orchestration model for unic-pr-review so code-simplifier runs only as a sequential post-pass after Phase 1 “Review Aspect” agents, gated by (a) zero Critical/Important Phase 1 findings and (b) ≥3 changed non-test source files—aligning behavior with the pr-review-toolkit model and Issue #216.

Changes:

  • Removes code-simplifier from the Phase 1 spawn-set decision and introduces a unit-testable shouldRunPhase2(changedFiles, findings) gate.
  • Updates the review-pr command runbook to describe Phase 2 sequencing for Pre-PR, ADO, and re-review flows; records the decision in a new ADR.
  • Adds/updates tests and bumps plugin version + changelog for the 2.1.3 release.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/claude-code/unic-pr-review/scripts/lib/changed-file-analyser.mjs Removes Phase 1 code-simplifier spawn rule; adds shouldRunPhase2 gate helper.
apps/claude-code/unic-pr-review/tests/changed-file-analyser.test.mjs Updates spawn-set assertions and adds a dedicated shouldRunPhase2 test suite.
apps/claude-code/unic-pr-review/commands/review-pr.md Documents Phase 2 gating + sequencing in Pre-PR/ADO/re-review flows and adds a gate evaluation one-liner.
apps/claude-code/unic-pr-review/docs/adr/0013-two-phase-code-simplifier.md New ADR capturing the two-phase decision, gating rules, and interaction with approval/re-review.
apps/claude-code/unic-pr-review/CHANGELOG.md Adds 2.1.3 changelog entry describing the two-phase model.
apps/claude-code/unic-pr-review/package.json Bumps package version to 2.1.3.
apps/claude-code/unic-pr-review/.claude-plugin/plugin.json Bumps plugin version to 2.1.3.
apps/claude-code/unic-pr-review/.claude-plugin/marketplace.json Bumps marketplace entry version to 2.1.3.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +639 to +644
node -e "
const {shouldRunPhase2}=await import('${CLAUDE_PLUGIN_ROOT}/scripts/lib/changed-file-analyser.mjs')
const files=JSON.parse(process.env.FILES)
const findings=JSON.parse(process.env.FINDINGS)
process.stdout.write(shouldRunPhase2(files,findings)?'true':'false')
" FILES='<JSON.stringify(changedFiles from Step 6)>' FINDINGS='<JSON.stringify(all Phase 1 findings flattened)>'
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.

feat(unic-pr-review): align code-simplifier with toolkit's two-phase post-pass model

2 participants