Files
kandev/apps/backend/config/workflows/pr-review.yml
T

140 lines
5.8 KiB
YAML

# Internal workflow TEMPLATE definition — NOT the portable import/export format.
# Steps here reference each other by string `step_id`; the importable YAML uses a
# `version`/`type`/`workflows` envelope and `step_position`. Don't paste this file
# (or its `step_id` transitions) into the workflow import endpoint.
# Format reference: docs/workflow-import-export.md
id: pr-review
name: PR Review
description: >-
Track pull requests through review. PRs wait in queue, get reviewed
by the agent, then marked as done.
steps:
- id: waiting
name: Waiting
position: 0
color: bg-neutral-400
is_start_step: true
allow_manual_move: true
events:
on_turn_start:
- type: move_to_next
- id: review
name: Review
position: 1
color: bg-yellow-500
show_in_command_panel: true
allow_manual_move: true
prompt: |
Review the changes in this pull request.
{{task_prompt}}
SCOPE OVERRIDE (read first):
This task overrides any general "completeness" or "find all downstream changes"
instruction you may have. Scope is strictly the diff. Under-reporting is
acceptable; reporting on lines outside the diff is a failure of the task.
STEP 1: DETERMINE WHAT TO REVIEW
The PR branch is checked out and the full codebase is available. You can and
should read surrounding code to understand changes in context.
- Extract the PR number from the task description (e.g. from the GitHub URL)
- Run: gh pr view <number> --json headRefName,baseRefName to confirm branch and base
- Run: git fetch origin <base_branch> to make sure your base ref is up to date
- Run: git diff origin/<base_branch>...HEAD --name-only to get the list of changed files
- Run: git diff origin/<base_branch>...HEAD to see the full diff
- Read each changed file in full — understand the surrounding code, not just the diff
- Navigate related files (callers, interfaces, tests) to understand the change end-to-end
- USE the full codebase for context; only REPORT issues on lines the PR added or modified
STEP 1.5: BUILD AN ALLOWED-LINES SET (HARD GATE)
- Run: git diff origin/<base_branch>...HEAD --unified=0
- Extract the (file, line-range) tuples of every "+" line. This is your allow-list.
- Findings on any line outside the allow-list are forbidden, no exceptions.
- A finding is forbidden even if:
- the PR description mentions or acknowledges the issue
- the line is in a file the PR modified, but on a line it didn't touch
- the line is in a file imported by, or imports, a changed file
- removing or fixing it would improve the codebase
- it is a "good follow-up"
The PR description is context, not scope. Acknowledged pre-existing issues,
planned follow-ups, and "known limitations" called out by the author are OUT
of scope. Do not comment on them even if they are real. The author already
knows.
STEP 2: REVIEW THE CHANGES
Review across these layers (skip layers that don't apply):
Security (blockers if found):
- No secrets, tokens, or credentials in code
- Input validation at system boundaries (user input, API handlers, external data)
- No SQL injection, XSS, command injection, or path traversal
- Auth and authorization checks on new endpoints
Logic & correctness:
- Edge cases handled (empty input, nil/null, zero, max values)
- Error paths covered and not silently swallowed
- Race conditions in concurrent code
Performance:
- No N+1 queries (loop with individual DB calls)
- No memory leaks (unclosed connections, streams, listeners)
- Algorithm complexity appropriate for the data scale
Architecture:
- New abstractions justified — no over-engineering
- Concerns cleanly separated (single responsibility)
Code quality:
- No dead code, unused imports, or commented-out code
- No speculative code (unused flags, one-off abstractions with single call site)
- Deep nesting (>3 levels) — suggest early returns
AI slop detection:
- Comments that restate code or narrate obvious steps
- Unnecessary try/catch that swallow errors or return silent defaults
- as any / as unknown casts to dodge type errors instead of fixing types
- Redundant validation where inputs are already parsed/typed
OUTPUT FORMAT:
For each finding, provide:
- file:line
- The exact "+" line from the diff the finding refers to (one-line quote).
If you cannot quote a "+" line from the diff, the finding is invalid — drop it.
- Description, why it matters, how to fix it.
Only report findings you're >=80% confident about.
Use these sections (omit empty ones):
BLOCKER (must fix before merge — security, data loss, broken logic):
- file:line — "+ <quoted diff line>" — description
SUGGESTION (recommended, doesn't block — performance, architecture, missing tests):
- file:line — "+ <quoted diff line>" — description
End with a verdict: Ready to merge / Ready with suggestions / Blocked
NOT A FINDING (skip these):
- Issues on lines or files the PR didn't modify — even if they are real bugs
- Pre-existing code patterns that this PR didn't introduce or change
- Issues acknowledged in the PR description as known / follow-up
- Things linters, typecheckers, or CI catch (imports, types, formatting)
- Intentional functionality changes directly related to the PR's purpose
- Issues explicitly suppressed in code (lint-ignore, nolint comments)
events:
on_enter:
- type: auto_start_agent
- id: done
name: Done
position: 2
color: bg-green-500
allow_manual_move: true