Skip to content

feat(code-review): add graph-aware Design Critic reviewer - #170

Merged
wongk merged 2 commits into
mainfrom
feat/code-review-design-critic
Jun 29, 2026
Merged

wongk merged 2 commits into
mainfrom
feat/code-review-design-critic

Conversation

@wongk

@wongk wongk commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the Design Critic — an always-on, deep-tier conditional core reviewer that evaluates software-design craftsmanship (module depth & information hiding, SOLID, dependency direction & layer boundaries, project structure), drawing on A Philosophy of Software Design (Ousterhout), SOLID, and Clean Architecture (Martin). It's source: "core" (exempt from the domain-critic cap), runs on Sonnet, and emits category: "Code Quality" findings scoped to design flaws a change introduces or worsens.

Bumps code-review to v3.1.0 (MINOR).

What's in it

New reviewer

  • tools/prompts/design_critic_suffix.txt — the Design Critic fleet role (7-step evaluation procedure: complexity framing → project structure → dependency graph → module depth → SOLID → code-level → testability/consistency), wired into COVERAGE_CORE_CONDITIONAL with an {"type": "always"} trigger so it runs on every --depth deep review.

Domain-critic cap collapsed 5 → 3

  • Uniform DOMAIN_CRITIC_CAP = 3 across standard and deep (removed the depth-aware STANDARD_DOMAIN_CRITIC_CAP/branch). Deep's extra breadth now comes from the Design Critic + Impact Analyzer rather than a wider critic allowance.

Design Critic is graph-aware

  • Spawns on code-review-worker-graph and uses the codebase-memory-mcp knowledge graph (get_architecture for module/layer layout, query_graph for dependency direction & import cycles) when the repo is indexed, falling back to grep otherwise. The graph worker's tool set gained get_architecture + query_graph. Same safety envelope as the other graph roles (blanked when the server is absent, the project is ambiguous, or review_root is set).

Removed the dead callsite_snippet_hash field

  • Dropped external_impact[].callsite_snippet_hash and the coupled EvidenceCheck.snippet_hash_matched (LLMs can't compute sha256; the field had no working consumer). Impact callsites are now validated by reading the cited file and content-matching the verbatim callsite_snippet.

Fleet-summary fix + accuracy cleanup (surfaced by a deep self-review of this branch)

  • _render_fleet_breakdown now derives the non-partitioned core display set from _SPAWN_CORE_ROLES, so both conditional core reviewers (Impact Analyzer + Design Critic) render on the "Reviewers:" line — previously the Impact Analyzer was silently omitted. Added a regression test.
  • Comment/docstring accuracy: COVERAGE_CORE_CONDITIONAL header, resolve_coverage docstring, _SPAWN_CORE_ROLES comment, and a stale /hash prompt reference.
  • Extracted duplicated _diff/_empty_critic_gates test helpers into a shared mixin.

Validation

  • pytest plugins/code-review/tools/python/1217 passed, 3 skipped (+2 new regression tests)
  • uv run ruff check . — clean
  • uv run pyright — 0 errors
  • README + CHANGELOG updated via /update-documentation

🤖 Generated with Claude Code

wongk and others added 2 commits June 29, 2026 10:54
Add the Design Critic — an always-on, deep-tier conditional core reviewer
that evaluates software-design craftsmanship (module depth, information
hiding, SOLID, dependency direction, project structure), drawing on
A Philosophy of Software Design, SOLID, and Clean Architecture. It is
source:"core" (exempt from DOMAIN_CRITIC_CAP), runs on Sonnet, and emits
category:"Code Quality" findings scoped to flaws this change introduces.

- Cap domain critics uniformly at 3 (was 5) on both standard and deep;
  deep's extra breadth now comes from the Design Critic + Impact Analyzer.
- Make the Design Critic graph-aware: spawn it on code-review-worker-graph
  and add get_architecture + query_graph to that worker so it can read the
  real module layout and dependency edges (falls back to grep when the
  graph is unavailable or review_root is set).
- Remove the unused callsite_snippet_hash / snippet_hash_matched fields
  (LLMs cannot compute sha256; the field had no working consumer) — the
  verifier now content-matches the verbatim callsite snippet.
- Render both conditional core reviewers (Impact Analyzer + Design Critic)
  on the fleet "Reviewers:" line by deriving the set from _SPAWN_CORE_ROLES
  instead of a hand-maintained tuple.
- Comment/docstring accuracy fixes surfaced by a self-review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the v3.1.0 CHANGELOG entry (Design Critic reviewer, uniform
domain-critic cap of 3, graph-aware Design Critic, callsite_snippet_hash
removal) and refresh the README: depth-tier table (cap 5→3, Design Critic
row, Impact Analyzer now shipping), /deep description, the graph worker's
consumers/tools, and the design_critic_suffix.txt prompt listing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wongk
wongk merged commit bb41a01 into main Jun 29, 2026
5 checks passed
@wongk
wongk deleted the feat/code-review-design-critic branch June 29, 2026 16:47
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