Skip to content

Commit 21f23da

Browse files
committed
feat(workflows): first draft of a PR review workflow
1 parent 4cff334 commit 21f23da

1 file changed

Lines changed: 177 additions & 0 deletions

File tree

resources/workflows/pr-review.yaml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# yaml-language-server: $schema=../state-machine-schema.json
2+
---
3+
name: 'pr-review'
4+
description: 'A tech-agnostic PR or code diff review workflow: determine intent, review architecture, correctness, and quality — hierarchically gated, with findings posted inline.'
5+
initial_state: 'determine_intent'
6+
7+
metadata:
8+
domain: 'code'
9+
complexity: 'medium'
10+
bestFor:
11+
- 'Pull request reviews'
12+
- 'Merge request reviews'
13+
- 'Code review'
14+
useCases:
15+
- 'Reviewing a feature branch before merge'
16+
- 'Reviewing a bug fix'
17+
- 'Reviewing a refactoring'
18+
examples:
19+
- 'Review PR #42'
20+
- 'Review the feature/login-refactor branch'
21+
22+
states:
23+
determine_intent:
24+
description: 'Derive the intent of the PR from the diff and present it to the user for confirmation'
25+
default_instructions: |
26+
Fetch the diff (stat and full diff) for the PR or branch under review.
27+
Retrieve the PR description and any linked issue descriptions. Use gh or glab CLI tools as needed. Fallback: Read using http.
28+
29+
From the diff and any available PR description, derive in your own words:
30+
- What problem does this change solve? What does the user intend to achieve?
31+
- What is the mechanism used to solve it?
32+
33+
Present your derived intent to the user and wait for explicit confirmation before proceeding.
34+
If your derived intent contradicts the PR description or what the user responds to you, flag that explicitly — it is itself a finding.
35+
36+
Respond in the user's language.
37+
38+
transitions:
39+
- trigger: 'intent_confirmed'
40+
to: 'orient'
41+
transition_reason: 'Intent confirmed by user, ready to map the change'
42+
43+
orient:
44+
description: 'Build a structural map of the change before any judgment'
45+
default_instructions: |
46+
Map the change without evaluating it yet:
47+
- Which files changed, and what kind of change is each (new logic, refactor, configuration, tests, fixtures)?
48+
- What are the entry points of the data or control flow affected by this change?
49+
- Which existing boundaries or components does the change touch?
50+
51+
Document this map. It will be the reference for all subsequent review phases.
52+
53+
transitions:
54+
- trigger: 'oriented'
55+
to: 'review_architecture'
56+
transition_reason: 'Structural map complete, ready to review architecture'
57+
58+
review_architecture:
59+
description: 'Review whether the change is in the right place and respects existing structure'
60+
default_instructions: |
61+
Evaluate the structural decisions in the change against the confirmed intent:
62+
63+
- Is the change located in the right place, or does it belong elsewhere?
64+
- Does it respect the existing boundaries and separation of responsibilities?
65+
- Does it introduce the right abstraction, or does it over- or under-abstract?
66+
- Does it follow the patterns already established in the codebase?
67+
- If an architecture document exists ($ARCHITECTURE_DOC), verify the change is consistent with it.
68+
69+
For each finding, classify it immediately:
70+
- **Bug**: incorrect behavior or data loss
71+
- **Design issue**: correct but wrong structure, will cause pain later
72+
- **Performance**: correct but unnecessarily costly at the expected scale
73+
- **Minor**: small violations, naming, unnecessary indirection
74+
- **Nit**: style, redundant comments, cosmetics
75+
76+
Bugs and design issues are major flaws. If major flaws are found, proceed to publish_review immediately.
77+
78+
transitions:
79+
- trigger: 'no_major_flaws'
80+
to: 'review_correctness'
81+
transition_reason: 'No major architectural flaws, proceeding to correctness review'
82+
83+
- trigger: 'major_flaws_found'
84+
to: 'publish_review'
85+
additional_instructions: |
86+
Major architectural flaws were found. Do not proceed to correctness or quality review —
87+
reviewing correctness on a structurally wrong solution is wasted effort.
88+
89+
Communicate clearly to the user:
90+
- Which findings are blockers and why
91+
- What rework is expected before the review can continue
92+
transition_reason: 'Major architectural flaws found, stopping for rework before continuing'
93+
94+
review_correctness:
95+
description: 'Review whether the logic correctly achieves the confirmed intent'
96+
default_instructions: |
97+
Evaluate the logic of the change against the confirmed intent:
98+
99+
- Does the code do what the intent requires, for all inputs and states?
100+
- Are edge cases handled — boundary conditions, empty inputs, missing data?
101+
- Are things that must stay consistent changed together? Can partial updates occur?
102+
- Are error paths handled, or silently swallowed?
103+
- Do resources that grow over time have a defined cleanup strategy?
104+
- If a design document or specification exists ($DESIGN_DOC), verify the change is consistent with it.
105+
106+
For each finding, classify it immediately (same scale as review_architecture).
107+
108+
Bugs and design issues are major flaws. If major flaws are found, proceed to publish_review immediately.
109+
110+
transitions:
111+
- trigger: 'no_major_flaws'
112+
to: 'review_quality'
113+
transition_reason: 'No major correctness flaws, proceeding to quality review'
114+
115+
- trigger: 'major_flaws_found'
116+
to: 'publish_review'
117+
additional_instructions: |
118+
Major correctness flaws were found. Do not proceed to quality review —
119+
polishing incorrect code is wasted effort.
120+
121+
Communicate clearly to the user:
122+
- Which findings are blockers and why
123+
- What rework is expected before the review can continue
124+
Proceed to publish_review to deliver these findings.
125+
transition_reason: 'Major correctness flaws found, stopping for rework before continuing'
126+
127+
review_quality:
128+
description: 'Review code quality, completeness, and good practices'
129+
default_instructions: |
130+
Evaluate the quality of the change:
131+
132+
- Is the code DRY, or is logic duplicated that should be shared?
133+
- Does the code do unnecessary work — reimplementing what the platform already provides,
134+
or repeating expensive operations that could be done once?
135+
- Is naming self-explanatory at the right level of abstraction?
136+
- Do comments explain *why*, not *what*? Are there comments that merely restate the code?
137+
- Is what's absent a problem: missing tests, missing error handling, missing observability?
138+
- Are there conventions in the codebase that this change violates?
139+
140+
For each finding, classify it immediately (same scale as previous phases).
141+
142+
transitions:
143+
- trigger: 'quality_reviewed'
144+
to: 'summarize'
145+
transition_reason: 'Quality review complete, ready to summarize'
146+
147+
summarize:
148+
description: 'Compose a concise overall summary of the review'
149+
default_instructions: |
150+
Write a top-level review summary:
151+
- Restate the confirmed intent in one sentence
152+
- List blocking findings (bugs, design issues) if any remain
153+
- List non-blocking suggestions briefly — the inline comments carry the detail
154+
- State your overall recommendation: approve / request changes / comment
155+
156+
Keep it short. The inline comments are the substance; this is the orientation.
157+
158+
transitions:
159+
- trigger: 'summary_ready'
160+
to: 'publish_review'
161+
transition_reason: 'Summary ready, proceed to publish'
162+
163+
publish_review:
164+
description: 'Ask the user how to deliver the review findings'
165+
default_instructions: |
166+
Ask the user how they want the review delivered:
167+
- Post inline comments directly to the PR/MR via VCS tooling (e.g. glab, gh)?
168+
- Present findings as a structured summary in the chat?
169+
- Both?
170+
171+
Once confirmed, deliver accordingly. For inline comments, attach each finding to the
172+
specific file and line it refers to. For cross-cutting findings, use a top-level comment.
173+
174+
transitions:
175+
- trigger: 'review_published'
176+
to: 'determine_intent'
177+
transition_reason: 'Review delivered, ready for next PR'

0 commit comments

Comments
 (0)