Skip to content

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

Merged
orioltf merged 5 commits into
developfrom
archon/task-feature-unic-pr-review-216-two-phase-code-simplifi
Jun 8, 2026
Merged

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

Conversation

@orioltf

@orioltf orioltf commented Jun 5, 2026

Copy link
Copy Markdown
Member

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 thread apps/claude-code/unic-pr-review/commands/review-pr.md Outdated
orioltf added a commit that referenced this pull request Jun 8, 2026
…216

#216 (PR #220) already takes 2.1.3; this PR is re-bumped to 2.1.4 so both
can land on develop without a duplicate version. Merge #220 before this PR.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
orioltf and others added 2 commits June 8, 2026 12:50
The Phase 2 gate one-liner placed FILES=/FINDINGS= after `node -e`, so the
shell passed them as argv rather than environment variables. process.env.FILES
was then undefined and JSON.parse(undefined) threw a SyntaxError, making the
gate always fail. Move the assignments before `node`, matching the canonical
invocation pattern used elsewhere in review-pr.md (render-summary, merger).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ADR-0013 was added without being registered in the ADR index README or the
plugin doctrine list (both stopped at ADR-0012), and its re-review section
contradicted review-pr.md on Phase 2 ordering.

- ADR-0013: state Phase 2 runs before the Re-review Coordinator and its
  findings feed into aspectFindings, matching review-pr.md Step 1.8/1.8a.
- docs/adr/README.md: add the 0013 index entry.
- AGENTS.md: add the ADR-0013 doctrine bullet; bump 'All twelve' to thirteen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@orioltf orioltf merged commit e16afd8 into develop Jun 8, 2026
9 checks passed
@orioltf orioltf deleted the archon/task-feature-unic-pr-review-216-two-phase-code-simplifi branch June 8, 2026 11:19
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